solve $\sin x+\cos x=1$ 
How do we solve $\sin x+\cos x=1$?

I have solved it easily by making the substitution,
$\sin x+\cos x=1=R\sin(x+a)$ which gives the solutions $x=2n\pi, 2n\pi+\pi/2$. But when I do as follows
$$
(\sin x+\cos x)^2=1\implies 2\sin x\cos x=0\implies \sin 2x=0\implies2x=n\pi
$$
For even and odd
$$
2x=2m\pi\text{ or }2x=(2m+1)\pi\\x=m\pi\text{ or } x=m\pi+\frac{\pi}{2}
$$
What am I missing here ?
 A: You squared your equation. That gives you extra solutions. Specifically, your second approach picks up all solutions to $\sin x+\cos x=-1$ as well.
A: This method gives the solution to $\sin x+\cos x=1$ or $\sin x+\cos x=-1$. 
Both the equations becomes $(\sin x+ \cos x) ^2=1$ after squaring. 
A: $x=1$ is not equal to $x^2=1$. 
For example: $-1=1$ is wrong, but $(-1)^2=1^2$ is true.
I think it's better to solve your equation by the following way.
We need to solve
$$\frac{1}{\sqrt2}\sin{x}+\frac{1}{\sqrt2}\cos{x}=\frac{1}{\sqrt2}$$ or
$$\sin(45^{\circ}+x)=\sin45^{\circ},$$
which gives
$$45^{\circ}+x=45^{\circ}+360^{\circ}k,$$
which is $x=360^{\circ}k$, $k\in\mathbb Z$ or
$$45^{\circ}+x=135^{\circ}+360^{\circ}k,$$
which is $x=90^{\circ}+360^{\circ}k$, $k\in\mathbb Z$ and we got the answer:
$$\{90^{\circ}+360^{\circ}k,360^{\circ}k|k\in\mathbb Z\}$$
A: One way is this: if $\sin x + \cos x = 1$, then both $\sin x$ and $\cos x$ are non negative, otherwise the other one would be greater than $1$. If one of them is different from $0$ or $1$, one has
$$1 = \sin^2 x + \cos^2 x \lt \sin x + \cos x = 1$$
This is impossible. The only remaining possibilities are $(\sin x, \cos x) = (0, 1) $ or $(1, 0)$, hence $x = 2 k \pi$ or $\frac{\pi}{2} + 2 k \pi$.
A: HINT: use that $$\sin(x)+\cos(x)=\sqrt{2} \sin \left(x+\frac{\pi }{4}\right)$$
A: HINT:
Avoid squaring as it generally introduces extraneous root(s).
Here use double angle formula $\sin2A=2\sin A\cos A$ and $\cos2A=12-\sin^2A$
OR in general cases $$A\sin x+B\cos x=C$$ use Weierstrass Substitution
A: You can divide both sides by $\sqrt 2$ to get $$\cos (\frac {π}{4}-x) =1$$ which can be further be solved easily. 
