Derivative of $f(x) = \csc(x)\cot(x)$ using first principles. How to find derivative of $f(x) = \csc(x)\cot(x)$ using First principle of derivative?

I tried the following method.
$f(x) = \csc(x)\cot(x) = \dfrac{\cos(x)}{\sin^2(x)}$
Now using the limit,
$f'(x) = \lim\limits_{h\to0}\dfrac{\dfrac{\cos(x+h)}{\sin^2(x+h)} - \dfrac{\cos(x)}{\sin^2(x)}}{h}$
$f'(x) = \lim\limits_{h\to0}\dfrac{\cos(x+h)\sin^2(x) - \cos(x) \sin^2(x+h)}{h\sin^2(x+h)\sin^2(x)}$

Now, what should I do with this limit?  I tried to apply the following identities,

*

*$\cos(A+B)= \cos(A)\cos(B) - \sin(A)\sin(B)$

*$\sin(A+B) = \sin(A) \cos(B) + \cos(A) \sin(B)$
I also tried to change $\sin^2(x) $ into $\dfrac{1 - \cos(2x)}{2}$,
But all of these formulas seem not to work here. Can anyone guide me for the same?
 A: If $$f(x) = \csc(x)\cot(x)\\= \dfrac{\cos(x)}{\sin^2(x)},$$ then
$$f'(x) = \lim_{h\to0}\dfrac{\dfrac{\cos(x+h)}{\sin^2(x+h)} - \dfrac{\cos(x)}{\sin^2(x)}}{h}\\
= \lim_{h\to0}\dfrac{\cos(x+h)\sin^2(x) - \cos(x) \sin^2(x+h)}{h\sin^2(x+h)\sin^2(x)}\\
= \lim_{h\to0}\left(\dfrac{\cos(x+h) -\cos(x)}{h}\frac{\sin^2(x)}{\sin^2(x+h)\sin^2(x)} \\-\dfrac{ \sin^2(x+h)-\sin^2(x)}h\frac{\cos(x)}{\sin^2(x+h)\sin^2(x)}\right)\\
= \lim_{h\to0}\dfrac{\cos(x+h) -\cos(x)}{h}\lim_{h\to0}\frac1{\sin^2(x+h)} \\-\lim_{h\to0}\dfrac{ \sin^2(x+h)-\sin^2(x)}h\lim_{h\to0}\frac{\cos(x)}{\sin^2(x+h)\sin^2(x)}\\
= \csc^2(x)\lim_{h\to0}\dfrac{\cos(x+h) -\cos(x)}{h}-\frac{\cos(x)}{\sin^4(x)}\lim_{h\to0}\dfrac{ \sin^2(x+h)-\sin^2(x)}h\\
= \csc^2(x)[\color{red}{-\sin(x)}]-\frac{\cos(x)}{\sin^4(x)}\lim_{h\to0}\left(\left(\sin(x+h)+\sin(x)\right)\dfrac{ \sin(x+h)-\sin(x)}h \right)\\
= -\csc(x)-\frac{\cos(x)}{\sin^4(x)}\lim_{h\to0}\left(\sin(x+h)+\sin(x)\right)\lim_{h\to0}\dfrac{ \sin(x+h)-\sin(x)}h\\
= -\csc(x)-\frac{2\cos(x)}{\sin^3(x)}[\color{red}{\cos(x)}]\\
= -\csc(x)-\frac{2\cos^2(x)}{\sin^3(x)}\\
= -\frac{\sin^2(x)+2\cos^2(x)}{\sin^3(x)}.$$
Answer verified by WolframAlpha.
A: Your $\sin x$ in the last denominator you found should be $\sin^2x$.
Act on the numerator:
$$
\cos(x+h)\sin^2x=\cos x\sin^2x\cos h-\sin^3x\sin h
$$
and
\begin{align}
\cos x\sin^2(x+h)
&=\cos x(\sin x\cos h+\cos x\sin h)^2 \\
&=\cos x\sin^2x\cos^2h+2\sin x\cos^2x\sin h\cos h+\cos^3x\sin^2h
\end{align}
Now subtract and collect the terms with $\sin h$ and those with $\cos h$:
\begin{align}
&(-\sin^3x-2\sin x\cos^2x\cos h+\cos^3x\sin h)\sin h \\
&+\cos x\sin^2x\cos h(1-\cos h)
\end{align}
Now you want
\begin{multline}
\lim_{h\to0}\frac{1}{\sin^2(x+h)\sin^2x}\Bigl((-\sin^3x-2\sin x\cos^2x\cos h+\cos^3x\sin h)\frac{\sin h}{h}\\+\cos x\sin^2x\cos h\frac{1-\cos h}{h}\Bigr)
\end{multline}
Since
$$
\lim_{h\to 0}\frac{\sin h}{h}=1,\qquad \lim_{x\to0}\frac{1-\cos h}{h}=0
$$
your limit evaluates to
$$
\frac{-\sin^3x-2\sin x\cos^2x}{\sin^4x}=-\frac{\sin^2x+2\cos^2x}{\sin^3x}
$$
