Question: I have been trying to solve $\sin x - \cos x = 1$ by squaring both sides but has not been able to obtain the solution. Here is what I did:

$$\begin{align}(\sin x - \cos x)^2 &=1^2\\\sin^2x-2\sin x\cos x+\cos^2x&=1\\1-\sin 2x&=1\\\sin2x&=0\end{align}$$

Obviously $x=0$ is not a solution. May I ask why this is the case or where did things go wrong?

Thank You

Answer: 
Note that : $$\sin x - \cos x = \sqrt2 \sin(x - \frac{\pi}{4})$$ In this case, $$\sin x - \cos x = \sqrt2 \sin(x-\frac{\pi}{4})=1 \implies \sin(x-\frac{\pi}{4})=\frac{1}{\sqrt2}$$

Thus, two possible solutions are:

* $$x - \frac{\pi}{4}=\frac{\pi}{4} \implies x = \frac{\pi}{2}+2k\pi \, ,k \in \mathbb{Z}$$
* $$x -\frac{\pi}{4}=\frac{3\pi}{4} \implies x = \pi + 2k\pi \, , k \in \mathbb{Z}$$
After squaring both sides of the equarion, we get
$$
1=\sin^2x+\cos^2x-2\sin x\cos x=1-\sin2x.
$$
Hence
$$
\sin 2x=0
$$
i.e.
$$
x=x\_k=\frac{\pi}{2}k, \qquad k \in \mathbb{Z}.
$$
Checking with the original equation, we have:

If $k=2n$, then
$$
\sin(x\_{2n})-\cos(x\_{2n})=(-1)^n
$$
If $k=2n+1$, then
$$
\sin(x\_{2n+1})-\cos(x\_{2n+1})=(-1)^n
$$
Hence, the solutions are 
$$
x\_{4n}=2\pi n, \quad x\_{4n+1}=\frac{\pi}{2}+2\pi n, \qquad n \in \mathbb{Z}.
$$