How to find $\tan x $ from $(a+1)\cos x + (a-1)\sin x=2a+1$? How do I find $\tan x$ from this equation?

$$(a+1)\cos x + (a-1)\sin x=2a+1$$

Thanks for any help!!
 A: using the so-called Weierstrass substitution we get this here
$${\frac { \left( a+1 \right)  \left( 1- \left( \tan \left( x/2 \right) 
 \right) ^{2} \right) }{1+ \left( \tan \left( x/2 \right)  \right) ^{2
}}}+2\,{\frac { \left( a-1 \right) \tan \left( x/2 \right) }{1+
 \left( \tan \left( x/2 \right)  \right) ^{2}}}=2\,a+1
$$
further use that $$\tan(x+y)={\frac {\tan \left( x \right) +\tan \left( y \right) }{1-\tan \left( x
 \right) \tan \left( y \right) }}
$$
A: Hint...try writing the LHS in the form $$R\cos(x-\alpha)$$ and solving for $x$ so you can get $\tan x$
A: Expressing the trigonometric functions $\sin(x)$ and $\cos(x)$ as a function of $\tan(\frac{x}{2})$, we get:
$\tan(\frac{x}{2})=+\frac{a-1+\sqrt{1-4a-2a^2}}{3a+2}$,
$\tan(\frac{x}{2})=-\frac{-a+1+\sqrt{1-4a-2a^2}}{3a+2}$.
Applying the tangent duplication formula:
$\tan(x)=\tan(\frac{x}{2}+\frac{x}{2})=\frac {\tan (\frac{x}{2})+\tan(\frac{x}{2})}{1-\tan(\frac{x}{2})\tan(\frac{x}{2})}$
$\tan(x)=\frac{a^2-1+(2a+1)\sqrt{1-4a-2a^{2}}}{3a(a+2)}$,
$\tan(x)=-\frac{-a^2+1+(2a+1)\sqrt{1-4a-2a^{2}}}{3a(a+2)}$.
A: If $a=1$, we obtain $2\cos x=3$, which is invalid (unless you want to consider complex values). Set $X=\cos x$ and $Y=\sin x$ to get
$$
\begin{cases} (a+1)X+(a-1)Y=2a+1 \\[6px] X^2+Y^2=1 \end{cases}
$$
Therefore $(a-1)Y=2a+1-(a+1)X$ and therefore
$$
(a-1)^2X^2+(2a+1-(a+1)X)^2=(a-1)^2
$$
With standard steps we find
$$
(2a^2-4a+2)X^2 - 2(2a^2-a-1)X + 3a^2 + 6a=0
$$
and it's possible to factor as
$$
2(a-1)^2X^2-2(a-1)(2a+1)X+3a^2+6a=0
$$
Now we have
$$
(a-1)^2(2a+1)^2-2(a-1)^2(3a^2+6a)=(a-1)^2(1-8a-2a^2)
$$
and therefore
$$
X=\frac{(a-1)(2a+1)\pm(a-1)\sqrt{1-8a-2a^2}}{2(a-1)^2}=
\frac{2a+1\pm\sqrt{1-8a-2a^2}}{2(a-1)}
$$
Now compute the corresponding values for $Y$.
By the way, the condition for the equation to have real solutions is that
$$
\frac{|2a+1|}{\sqrt{(a+1)^2+(a-1)^2}}\le1
$$
hence
$$
\frac{-2-\sqrt{6}}{2}\le a\le\frac{-2+\sqrt{6}}{2}
$$
