<s>[INST] tricky system of trigonometric equations I am not very fresh in math, but I need to solve this system:
\begin{gather}
A\sin(x-y)+B\sin(z-y)=C\\
A\cos(x-y)+B\cos(z-y)=D
\end{gather}
where $A,B,C,D$ and $x$ are given.
I tried to expand and combine the bracket terms and I suppose that there are some tricky substitutions to get it out, but I am lost!
Thank you all!
 [/INST] Let $x-y=U, z-y=V$. Then 
$$A\sin U+B \sin V=C$$
$$A\cos U+B \cos V=D$$
Square both equations:
\begin{align}
A^2\sin^2 U + B^2 \sin^2 V + 2 AB \sin U \sin V&=C^2\\
A^2\cos^2 U + B^2 \cos^2 V + 2AB \cos U \cos V &=D^2
\end{align}
Add to get
\begin{align}
A^2(\sin^2 U + \cos^2 U) + B^2 (\sin^2 V + cos^2 V) + 2 AB (\sin U \sin V + \cos U \cos V) &=C^2 + D^2\\
A^2 + B^2  + 2 AB (\sin U \sin V + \cos U \cos V) &=C^2 + D^2\\
2 AB (\sin U \sin V + \cos U \cos V) &=C^2 + D^2 - A^2 - B^2\\
\sin U \sin V + \cos U \cos V &=\frac{C^2 + D^2 - A^2 - B^2}{2AB}\\
\cos (U-V) &=\frac{C^2 + D^2 - A^2 - B^2}{2AB}\\
(U-V) &=\cos^{-1} \frac{C^2 + D^2 - A^2 - B^2}{2AB}\\
\end{align}
Since $U - V = (x-y) - (z-y) = x - z$, this gives you 
\begin{align}
z &=x - \cos^{-1} \frac{C^2 + D^2 - A^2 - B^2}{2AB}.
\end{align}
Now you can plug in $z$ and $x$ in either of your first two equations to find $y$. 
Of course, this all depends on $AB \ne 0$. 
If either $A$ or $B$ is zero, then you can solve the first equation directly to find $U$ or $V$, and work from there. 
</s>