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.
 A: For fun, here's a trigonograph:


$$\tan\theta = \tan(\phi + \psi) = \frac{\tan\phi+\tan\psi}{1-\tan\phi\tan\psi} = \frac{\;\dfrac{y}{x}+\dfrac{b}{a}\;}{\;1-\dfrac{y}{x}\dfrac{b}{a}\;}=\frac{ay+bx}{ax-by}$$

A: 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}$$
A: $x \cos\theta + y\sin\theta = a, \,\, x \sin\theta - y\cos\theta = b$. Therefore:
$$\dfrac{x \cos\theta + y\sin\theta}{x \sin\theta - y\cos\theta} = \dfrac{a}{b}$$
$$\implies \dfrac{x + y\tan\theta}{x \tan\theta - y} = \dfrac{a}{b}$$
$$\implies bx + by\tan\theta = ax \tan\theta - ay$$
$$\implies (ax - by) \tan\theta = bx + ay$$
$$\implies \tan\theta = \dfrac{bx + ay}{ax - by}$$
A: Hint:
Solve the two simultaneous linear equation for $\sin\theta,\cos\theta$
See  https://brilliant.org/wiki/system-of-linear-equations/ or   https://revisionmaths.com/gcse-maths-revision/algebra/simultaneous-equations
A: $$x\cos \theta+y\sin\theta=a$$
$$\implies x+y\tan\theta=a\sec\theta$$
$$\implies \sec \theta=\frac{x+y\tan\theta}{a} ...(1)$$
$$x\sin\theta-y\cos\theta=b$$
$$\implies x\tan\theta-y=b\sec\theta$$
$$\implies \sec\theta=\frac{x\tan\theta-y}{b}...(2)$$
From $1$ and $2$,
$$\frac{x+y\tan\theta}{a}=\frac{x\tan\theta-y}{b}$$
$$\implies bx+by\tan\theta=ax\tan\theta-ay$$
$$\implies \tan\theta(ax-by)=bx+ay$$
$$\tan\theta=\frac{bx+ay}{ax-by}$$
A: We may write the given equations as:
$$\begin{pmatrix}\cos \theta & - \sin \theta \\ \sin \theta & \cos \theta \end{pmatrix}   \begin{pmatrix}x \\ - y  \end{pmatrix}  = \begin{pmatrix}a \\ b  \end{pmatrix}  $$
and recognise that the first matrix represents a counterclockwise rotation by $\theta$ about the origin.
We can then use the formula for the tangent of the difference of two angles to see that
$$\tan \theta = \frac{\frac{b}{a}- \frac{-y}{x}}{1+\frac{b}{a} \frac{-y}{x}}=\frac{bx+ay}{ax-by}$$
