In an equation like $\sin(2x) = 3\cos(2x)$ for $0\leq x \leq \pi$, why can I divide by $\cos(2x)$? For every solution I see of

$\sin(2x)$ = $3\cos(2x)$ for $0\leq x \leq \pi$

they divide by $\cos(2x)$ to get

$\tan(2x) = 3$

and then solve from there.
But I have always been told not to divide by $0$, and surely $\cos(2x)$ can $= 0$ if $x = \pi/4$.
So why is this allowed?
 A: Whenever you divide by a variable quantity, you have to split off the cases that cause division by zero.  You're saying to yourself, ``Either this is zero or I can divide by it." So when you divide your equation by $\cos 2x$ you're assuming that $x \neq \pi/4.$
You treat the $x = \pi/4$ case separately.  And since $\pi/4$ is not a solution, you're done.
An easier example:
$$x^2 = 2x$$
Either $x=0$ or I can divide by it.
If I divide, I get $x=2$ which is a solution.
If $x=0$ I try it, and it's another solution.
A: For the values of $x$ where $\cos(2x)=0$, one must have $\sin(2x)\ne 0$ and the equation cannot hold. So in order to find the solutions, one can divide on both sides by $\cos(2x)$ where $x$ takes the values so that $\cos(2x)\ne 0$.
A: One way of thinking about it is that the equation can be rewritten as $\sin 2x-3\cos2x =0$. If we then factor that as $\cos 2x(\tan 2x -3)=0$, then we know that one of the factors are zero, so we can split it up into two equations $\cos 2x=0$ and $\tan2x-3=0$$^{[1]}$. The first yields $2x = \frac{\pi}2$ and hence $x=\frac{\pi}4$, but as that doesn't satisfy the original equation, it is an extraneous solution and can be discarded.
[1] Remember, if we have $ab=0$, then at least one of $a$ and $b$ must be zero (this is true for real numbers, but there are other mathematical objects such as matrices for which it is not true). Since $\cos 2x$ can't be zero, it must be the case that $\tan 2x-3$ is).
A: 
$\sin2x = 3\cos2x$ for $0≤x≤π$

Assume that $\cos2x$ is indeed $0,$ i.e., the RHS equals $0;$ then, the LHS, $\sin2x,$ is also $0,$ i.e., $2x$ is a multiple of $\pi;$ then, $\cos2x$ is not $0.$ We have derived a contradiction (that $\cos2x$ is both $0$ and not $0$), so, our assumption must have been wrong, i.e., $\cos2x$ is actually not zero; so, it is valid (no solutions will be discarded) to divide the given equation by $\cos2x.$
