Two ways of solving same equation $$\cos x - \sin x = -1$$
There are 2 methods to solve the equation:


*

*Dividing by $\sqrt{2}$ to get $\cos (\frac{\pi}{4} + x) = \cos(\frac{3 \pi}{4} \rightarrow x=(2n(\pi)+ \frac{\pi}{2} ~\text{or} ~((2n-1)\pi)$

*Squaring to get $\sin 2x = 0 \rightarrow x=\frac{n(\pi)}{2}$
Are both the solutions true and why does such a situation arise?
Thanks in advance
 A: When you square an equation you often introduce extraneous roots.  The simplest example is $x=1$.  If you square it, you get $x^2=1$, which is also satisfied by $x=-1$.  Squaring is non-reversible, so you need to check solutions in the original equation if you use it.
A: No. They are not the same. 
In a), you get the correct solution. 
In b), while squaring, you are considering the case $\cos x-\sin x=1$ as well, which are will not satisfy your given equation.
A: Let's be absolutely clear and transparent: We can solve the equation two ways: $$\sqrt{2}\left(\sin(\pi/4)\cos(x)-\cos(\pi/4)\sin(x)\right)=-1\Longrightarrow \sin(\pi/4-x)=-(1/\sqrt{2}).$$ Simplifying this yields $$\pi/4-x=-\pi/4+2n\pi\Longrightarrow x=\pi/2+2n\pi$$
or$$\pi/4-x=-3\pi/4+2n\pi\Longrightarrow x=(2n-1)\pi.$$ 
Alternatively, we can square the equation, and we get $$\cos^2(x)-2\sin(x)\cos(x)+\sin^2(x)=1-\sin(2x)=1\Longrightarrow \sin(2x)=0.$$ Again, simplifying, we have $$2x=n\pi\Longrightarrow x=\frac{n\pi}{2}.$$Since we've squared a term here, we have to go back and plug in our terms, but notice that all of the solutions for this first method are included here (precisely for $n=4k+1$), we just happen to have extraneous solutions gained from squaring the equation. Now, we want $$\cos(n\pi/2)-\sin(n\pi/2)=-1.$$ From here, it is easy to see this is precisely when $n\equiv 1\pmod{4}$ since at $n\equiv 3\pmod{4}$ we have the equation equal to $1$, not $(-1)$, or when or $n\equiv 2\pmod{4}$ and not $n\equiv 0\pmod{4}$ for the same reason as before.
