<s>[INST] If $x \cos\theta+y\sin\theta=a$ and $x\sin\theta-y\cos\theta=b$, then $\tan\theta=\frac{bx+ay}{ax-by}$. (Math Olympiad) I tried to solve it but I can’t get the answer. Please help me in proving this trig identity: 

If 
  $$x \cos\theta+y\sin\theta=a$$
  $$x\sin\theta-y\cos\theta=b$$ 
  then $$\tan\theta=\frac{bx+ay}{ax-by}$$

I've spent many hours trying.
Thanks in advance.
 [/INST] We first try to find $\sin \theta $ in terms of $a, b, x, y$
Multiply equation first by $y$ and the equation $2^{nd}$ by $x$ and add the resultant equations to get $$\sin \theta= \frac {bx+ay}{x^2+y^2}$$
Now multiply the first equation by $x$ and second equation by $y$ to get following equations 
$$x^2\cos \theta+xy\sin \theta=ax$$
And 
$$xy\sin\theta-y^2\cos\theta=by$$
Hence we get $$\cos\theta=\frac {ax-by}{x^2+y^2}$$
By subtracting resultant $2^{nd}$ equation from the resultant $1^{st}$ equation. 
Using these values of $\sin\theta$ and $\cos\theta$ we get $$\tan\theta = \frac {bx+ay}{ax-by}$$
</s>