If $\sin(x)=\sin(\pi/4 + x)$, then why isn't $x=x+\pi/4$? I've been solving a question, 

If $\cos(x) + \sin(x)=\sqrt{2} \cos(\pi/2 - x)$ then find the value of $x$.

We know that $\cos(x) + \sin(x)= \sqrt{2} \sin(\pi/4 + x)$. So, $$\sin(\pi/4 + x) =  \cos(\pi/2 - x)$$ But $\cos(\pi/2 - x) = \sin x$, so we must have $$\sin(\pi/4 + x)=\sin(x).$$
Now if I change $\sin(x)$ to $\sin(\pi - x)$ then the correct answer will come, i.e.
$$\sin(\pi/4 + x)=\sin(\pi - x) \implies \pi/4 + x = \pi -x \implies x=3\pi/8.$$ But why is $\pi/4 + x=x$ not true. My book says, if $\sin(x)=\sin(y)$ then $ x = (-1)^ny + n\pi $. If I put $n=0$ then $x=y$ but this is not true in my case. Why?
I also looked on the relevant Wikipedia article but could not understand why these formulas are true for any value of $\theta$ that may be more that $\pi/2$ and less than $0$. 
 A: 
My book says, if $\sin(x)=\sin(y)$ then $ x = (-1)^ny + n\pi $.

Yes, that means if $\sin(x)=\sin(y)$, then there exists some $n$ such that $ x = (-1)^ny + n\pi $, not that you get to choose which $n$, or that the statement is true for every $n$. For example,
$$\sin(0)=0=\sin(7\pi)$$
and we do indeed have that $0=(-1)^{n}\pi+n\pi$ for $n=7$, but that is the only $n$ that works.
More generally, you should be aware that most functions do not have the property that $f(x_1)=f(x_2)\implies x_1=x_2$. Take a look at the Wikipedia page on injective functions.
A: See, If $\sin \theta =0,$ then $\theta=n\pi, \forall n \in \Bbb Z$. Similarly if $\cos\theta=0$, then $\theta=\frac {(2n+1)\pi}{2}, \forall n \in \Bbb Z$.
Now, If $\sin x=\sin y$, then $\sin x - \sin y=0$ $\Rightarrow$ $2\cos(\frac{x+y}{2})\sin(\frac{x-y}{2})=0$ $\Rightarrow$ $\cos(\frac{x+y}{2})=0$ or $\sin(\frac{x-y}{2})=0$.
If $\cos(\frac{x+y}{2})=0$, then $\frac {x+y}{2}=\frac {(2n+1)\pi}{2}, \forall n \in \Bbb Z$ $\Rightarrow$ $x=(2n+1)\pi-y, \forall n  \in \Bbb Z$.
If $\sin(\frac{x-y}{2})=0$, then $\frac {x-y}{2}=n\pi, \forall n \in \Bbb Z$ $\Rightarrow$ $x=2n\pi + y, \forall n\in \Bbb Z$.
Combining these two results, we see that $x=(-1)^{n}y+n\pi, \forall n \in \Bbb Z. $ 
