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!!

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)}$.
