How to prove that a diffrensiation of a formula equals to another formula. QUESTION 1) if $y =\dfrac{ \sin x-x\cos x}{x\sin x+\cos x}$  show that $\dfrac{dy}{dx}= \dfrac{x^2}{(x\sin x+\cos x)^2}$
QUESTION 2) if $y = \dfrac{\tan x+1}{\tan x-1}$ show that $\dfrac{dy}{dx}= \dfrac{-2}{1-\sin 2x}$
 A: For the first, we get
\begin{align}
    \frac{d}{dx}\left(\frac{ \sin x-x\cos x}{x\sin x+\cos x}\right)
    &= \frac{(x\sin x + \cos x)(\cos x + x\sin x-\cos x)-(\sin x - x\cos x)(\sin x + x\cos x - \sin x)}{(x\sin x + \cos x)^2} \\
    &= \frac{x^2\sin^2 x + x\sin x\cos x - (x\sin x\cos x - x^2\cos^2 x)}{(x\sin x + \cos x)^2} \\
    &= \frac{x^2(\sin^2 x + \cos^2 x)}{(x\sin x + \cos x)^2} \\
    &= \frac{x^2}{(x\sin x + \cos x)^2} .
\end{align}
A: for the second, we get
$$\begin{align}
y&=\frac{\tan x+1}{\tan x-1}\\
\frac{dy}{dx}&=\frac{d}{dx}\left(\frac{\tan x+1}{\tan x-1}\right)\\&
=\frac{\frac{d}{dx}(\tan x+1)(\tan x-1)-(\tan x+1)\frac{d}{dx}(\tan x-1)}{(\tan x-1)^2}\\&
=\frac{\sec^2 x(\tan x-1)-(\tan x+1)\sec^2 x}{(\tan x-1)^2}\\&
=\frac{\sec^2x\tan x-\sec^2 x-\sec^2 x\tan x-\sec^2 x}{(\tan x-1)^2}\\&
=\frac{-2\sec^2 x}{(\tan x-1)^2}\\&
=-2\sec^2 x\frac{1}{(\tan x-1)^2}\\&
=-2\frac{1}{\cos^2 x}\frac{1}{\left(\frac{\sin x}{\cos x}-1\right)^2}\\&
=-2\frac{1}{\cos^2 x}\frac{1}{\frac{(\sin x-\cos x)^2}{\cos^2 x}}\\&
=-2\frac{1}{\cos^2 x}\frac{\cos^2 x}{(\sin x-\cos x)^2}\\&
=-2\frac{1}{(\sin x-\cos x)^2}\\&
=-2\frac{1}{\sin^2x-2\sin x\cos x+\cos^2x}\\&
=-2\frac{1}{\color{red}{\sin^2x+\cos^2x}-\color{blue}{2\sin x\cos x}}\\&
=\frac{-2}{\color{red}{1}-\color{blue}{\sin2x}}
\end{align}$$
