Simultaneous equation of trig functions If I have the two following equations:
$$\begin{align}
A &= F\sin(x)+ G\cos(x)\\
B &= G\sin(x)+ F\cos(x)
\end{align}$$
and $A$,$B$,$F$,$G$ and are all constants, what is the easiest method of calculating $x$?
I've had a look at Cramers rule and the $R\cos(x-\alpha)$ rule. I need to find the most effective method for a program I am writing!

If $F\ne G$, then subtracting the second equation from the first gives
\begin{eqnarray}
(F-G)\sin x-(F-G)\cos x&=&A-B\\\
\sin x-\cos x&=&\frac{A-B}{F-G}\\\
\sqrt{2}\left(\frac{1}{\sqrt{2}}\sin x-\frac{1}{\sqrt{2}}\cos x\right)&=&\frac{A-B}{F-G}\\\
\sqrt{2}\left(\sin x\cos\frac{\pi}{4}-\cos x\sin\frac{\pi}{4}\right)&=&\frac{A-B}{F-G}\\\
\sqrt{2}\sin\left(x-\frac{\pi}{4}\right)&=&\frac{A-B}{F-G}\\\
\sin\left(x-\frac{\pi}{4}\right)&=&\frac{\sqrt{2}}{2}\cdot\frac{A-B}{F-G}\tag{1}
\end{eqnarray}
In the case $F=G$ it follows that $A=B$ and the equation reduces to the form
$$\sin x+\cos x=C $$
which can be reformed into
$$ \cos\left(x-\frac{\pi}{4}\right)=\frac{\sqrt{2}}{2}C $$
ADDENDUM Due to the comment by @GCab
If $F\ne-G$ and the first equation is added to the second a similar process gives the result
$$ \cos\left(x-\frac{\pi}{4}\right)=\frac{\sqrt{2}}{2}\cdot\frac{A+B}{F+G} \tag{2}$$
These equations can be solved for $x$ over whichever range is required.
In the case that $G=-G$ it follows that $A=-B$ and the equation will be of the form
$$\sin x-\cos x=C $$
which has solution 
$$ \sin\left(x-\frac{\pi}{4}\right)=\frac{\sqrt{2}}{2}C $$
