<s>[INST] Solutions of sin(x) = cos(x) I know that the solutions to the equation $\sin(x) = \cos(x)$ are :
$ x= \frac{\pi}{4}$  (45°) ; $ x= \frac{5 \pi}{4}$ (225°)
However when I try to solve it algebraically I get the following :
$$  \sin x = \cos x$$
$$  \sin^2 x = \cos^2 x$$
$$  \sin^2 = 1 - \sin^2 x$$
$$  2\sin^2 x = 1$$
$$  sin^2 x = \frac{1}{2}$$
$$ \sqrt {sin^2 x} = \sqrt{\frac{1}{2}}$$
$$ \sqrt {sin^2 x} = \sqrt{\frac{1}{2}}$$
$$ \sin x= \lvert\frac{1}{\sqrt2}\rvert$$
$$ \sin x= \frac{\sqrt2}{2}  ;  \sin x= -\frac{\sqrt2}{2}$$
So if I look for all the values of $x$ that solve the above I should get not only $ x= \frac{\pi}{4}$  (45°) ; $ x= \frac{5 \pi}{4}$ (225°) but also $ x= \frac{3\pi}{4}$  (135°) ; $ x= \frac{7 \pi}{4}$ (315°).
What am I doing wrong?
 [/INST] The problem is a pretty generic one. By squaring both sides of the equation earlier on, you introduced extraneous solutions. It's sort of like how in solving the equation
$$x+\sqrt{x+9} = 2$$
you can get to
$$\sqrt{x+9} = 2-x$$
and then square both sides to get
$$x+9 = 4 - 4x + x^2 \implies x^2 - 5x - 5 = 0$$
You should get
$$x = \frac{5 \pm 3\sqrt 5}{2}$$
Not the cleanest expression, but you'll notice that, if you substitute the positive root into the original equation, it won't work, though the negative root does. This applies beyond the context of polynomials. For example, if we have
$$x = x$$
we can square and get
$$x^2 = x^2$$
Obvious, right? But a problem: if you wanted to work backward, how would you know whether either is positive or negative? After all, $x^2 = (-x)^2$ in the usual arithmetic. Same problem here: 
$$(\sin(x))^2 = (-\sin(x))^2 = (\cos(x))^2 = (-\cos(x))^2$$
Extra solutions galore. 

This doesn't make your method of solution invalid, necessarily, but you have to be conscious of extraneous solutions, and always substitute each solution back in to check its validity. In fact, substituting both $x=3\pi/4$ and $x = 7\pi/4$ into the original equation, you should notice that the two differ by $\sqrt 2$ and $-\sqrt 2$, respectively, so you don't have equality in those cases!
</s>