TITLE: How should I be avoiding this mistake? (To avoid missing solutions)
QUESTION [40 upvotes]: First of all, I am sorry if this is a question too simple or stupid.
Consider the equation:
$$
\log((x+2)^2) = 2 \log(5)
$$
If I apply the logarithm law $ \log_a(b^c) = c \log_a(b) $
$$
\begin{align}
2 \log(x+2) & = 2 \log(5) \\
\log(x+2) &= \log(5) \\
x+2 &= 5 \\
x &= 3
\end{align}
$$
But I can see that I am missing a solution, $x = -7$.
I noticed that 
$$
\begin{align}
\log((x+2)^2) &= 2 \log(5) \\
\Updownarrow \\
2 \log(x+2) &= 2 \log(5)
\end{align}
$$
Is NOT true. The domain of the first equation is $x \in \mathbb{R}$ but the second equation's is $x \geq -2$.
I know the correct solution.

So I understand that this is not an equivalent transformation of the equation. What I don't know is how I should avoid this. Is there something to keep in mind that would help me evade this mistake? Naturally, I wouldn't have noticed the missing solution, unless I checked the domain of the second equation, which I wouldn't really have had a reason for...

REPLY [10 votes]: Congratulations on understanding why the other solution exists and why you missed it.
How to avoid this:
Whenever you see a real number squared, or raised to any even power, (make sure it's not a complex number that you're dealing with!), perform the following substitution:
$$x^2 \iff |x|^2$$
Note that both expressions are always equal (in real numbers), so it is 100% correct to make this substitution at any time.
Only then, perform your rules.
In other words, never "take the square out" unless it's surrounded by the absolute-value function.
In your example, $(x+2)^2$ would first become $|x+2|^2$, and only then you should proceed as you did, and this way you wouldn't miss any solutions.