Using the definition of derivative, find $f'(x)$ where $f(x) = \frac{\cos x}{x}$ I have attempted to solve the problem, but got stuck on the way, see below.
\begin{align*}
f'(x)&=\lim_{h\to 0} \frac{f(x+h)-f(x)}{h}\\
&= \lim_{h\to 0}\frac{\frac{\cos(x+h)}{x+h}-\frac{\cos x}{x}}{h}\\
&=\lim_{h\to 0}\frac{x\cos(x+h)-(h+x)\cos x}{xh(x+h)}\\
&=\lim_{h\to 0}\frac{x\cos h\cos x-x\sin h\sin x-(h+x)\cos x}{xh(x+h)}\\
&=\lim_{h\to 0}\frac{1}{x(x+h)}\left(\frac{x\cos x(\cos h-1)-h\cos x}{h}-\frac{x\sin x\sin h}{h}\right)\\
&=\lim_{h\to 0}\frac{1}{x(x+h)}\left(\frac{x\cos x(\cos h-1)}{h}-\cos x-\left(\frac{\sin h}{h}\right)x\sin x\right)
\end{align*}
From here I cannot solve $$\lim_{h\to 0}\frac{x\cos x(\cos h-1)}{h}.$$
Any suggestions? Or maybe I have taken the wrong route.
 A: Here 
$
\frac{\cos h-1}{h}= \frac{\cos h-1}{h}\frac{\cos h+1}{\cos h+1}=\frac{(\cos h)^2-1}{h(\cos h +1)}=\frac{\sin h}{h}\frac{\sin h}{(\cos+1)}$.
By
$
\lim_{h\to 0}\frac{\sin h}{h}=1 
$ we have $\lim_{h\to 0}\frac{\cos h-1}{h}=0$ . Then
\begin{align}
&\lim_{h\to 0}\frac{1}{x(x+h)}
\left[
x\cos x\left(\frac{\cos h-1}{h}\right)-\cos x-\left(\frac{\sin h}{h}\right)x\sin x
\right]=
\\=&
\lim_{h\to 0}\frac{1}{x(x+h)}
x\cos x\left(\frac{\cos h-1}{h}\right)
-\lim_{h\to 0}\frac{1}{x(x+h)}\cos x
-\lim_{h\to 0}\frac{1}{x(x+h)}\left(\frac{\sin h}{h}\right)x\sin x
\\=&
\lim_{h\to 0}\frac{1}{x+h}
\cos x\left(\frac{\cos h-1}{h}\right)
-\lim_{h\to 0}\frac{1}{x(x+h)}\cos x
-\lim_{h\to 0}\frac{1}{x+h}\left(\frac{\sin h}{h}\right)\sin x
\\=&
\frac{\cos x}{x^2}-\sin x\end{align}
A: We have $$\frac{\cos(h)-1}{h}=\frac{\cos^2(h)-1}{h(\cos(h)+1)}=\frac{-\sin^2(h)}{h^2}\frac{h}{\cos(h)+1}.$$
A: You can multiply the limit by $(\cos h + 1)/(\cos h + 1)$ and rearrange it into more manageable forms.
$$\begin{aligned}
\lim_{h\to0}\frac{x\cos x \left(\cos h-1\right)}{h}
&=x\cos x \lim_{h\to0}\frac{(\cos h-1)}{h}
\\&=x\cos x \lim_{h\to0}\frac{(\cos h-1)(\cos h+1)}{h(\cos h +1)}
\\&=x\cos x \lim_{h\to0}\frac{-\sin^2 h}{h(\cos h +1)}
\\&=-x\cos x \bigg(\lim{\sin h}\bigg)\left(\lim\frac{\sin h}{h}\right)\left(\lim\frac{1}{\cos h +1}\right)
\end{aligned}$$
