Differentiate $f(x)=\dfrac{\sin^2(3x)}{2x}$ Consider following function

$$ f(x) =
\begin{cases}
\dfrac{\sin^2(3x)}{2x},  & x\neq0 \\
0, & x=0
\end{cases}$$

Evaluate $f'(0)$.

Is this function differentiable  at $x=0$ ?
 A: Take the derivative first, using the quotient rule:
$$\frac{d}{dx}\left(\frac{\sin^2(3x)}{2x}\right)=\frac{2x\cdot2\sin(3x)\cdot\cos(3x)\cdot3-\sin^2(3x)\cdot2}{4x^2}$$
Then we need to take the limit as x approaches 0 of this expression:
$$\lim_{x\rightarrow 0} \frac{2x\cdot2\sin(3x)\cdot\cos(3x)\cdot3-\sin^2(3x)\cdot2}{4x^2}$$
If we directly plug in the numbers, we find a fraction of the form $\frac{0}{0}$, which is a case in which we can use L'Hospital's Rule:$\frac{f}{g}\rightarrow\frac{f'}{g'}$.
So now we differentiate the top and bottom independently:
$$\lim_{x\rightarrow 0} \frac{2x\cdot2\sin(3x)\cdot\cos(3x)\cdot3-\sin^2(3x)\cdot2}{4x^2}=
\lim_{x\rightarrow 0} \frac{12\sin(3x)\cos(3x)+36x\cos^2(3x)-36\sin^2(3x)-12\sin(3x)\cos(3x)}{8x}$$
This form is again $\frac{0}{0}$, so we need to apply L'Hospital's Rule again:
$$\lim_{x\rightarrow 0} \frac{36x\cos^2(3x)-36\sin^2(3x)}{8x}=
\lim_{x\rightarrow 0} \frac{36\cos^2(3x)-72\cos(3x)\sin(3x)3-72\sin(3x)\cos(3x)3}{8}
$$
This final form removes the $0$ in the denominator, so we can now evaluate the left and right-hand sides of the limit.
$$\lim_{x\rightarrow 0} \frac{36\cos^2(3x)-432\cos(3x)\sin(3x)}{8}=
\lim_{x\rightarrow 0} \frac{9\cos^2(3x)-108\cos(3x)\sin(3x)}{2}$$
$$\rightarrow_{x\rightarrow0^+}\frac{9\cos^2(3\cdot0^+)-108\cos(3\cdot0^+)\sin(3\cdot0^+)}{2}=
\frac{9\cos^2(0^+)-108\cos(0^+)\sin(0^+)}{2}=\frac{9\cdot1-108\cdot1\cdot0^+}{2}=\frac{9}{2}
$$
$$\rightarrow_{x\rightarrow0^-}\frac{9\cos^2(3*0^-)-108\cos(3\cdot0^-)\sin(3\cdot0^-)}{2}=
\frac{9\cos^2(0^-)-108\cos(0^-)\sin(0^-)}{2}=\frac{9\cdot1-108\cdot1\cdot0^-}{2}=\frac{9}{2}
$$
Therefore, the limit does exist. It approaches $\frac{9}{2}$ from below on the right, and from above on the left.
Since the derivative at $0$ is $0$, the derivative does not exist.
A: Why not go by the definition? First check the continuity. We will be using the fact that $\displaystyle\lim\limits_{z\to 0}\frac{\sin z}{z} =1$.
$$\lim_{x\to 0}\frac{\sin^2(3x)}{2x}=\lim_{x\to 0} \frac{\sin^2(3x)}{(3x)^2}\cdot \frac{9x^2}{2x}=0$$
This ensures continuity. Next differentiablity
$$\lim_{x\to 0} \frac{f(x)-f(0)}{x}=\lim_{x\to o}\frac{f(x)}{x}=\lim_{x\to 0}\frac{\sin^2(3x)}{(3x)^2}\cdot \frac{9x^2}{2x^2} =\frac92$$
Hence $f'(0)=\frac92$
A: For $x\ne0$, you can compute the derivative with the quotient and chain rules:
$$
f'(x)=\frac{2\sin3x\cos3x\cdot 3\cdot 2x-\sin^23x\cdot2}{4x^2}
$$
At $0$ you can use the definition and compute
$$
\lim_{h\to0}\frac{f(0+h)-f(0)}{h}=
\lim_{h\to0}\frac{1}{h}\frac{\sin^23h}{2h}=
\lim_{h\to0}\frac{\sin3h}{3h}\frac{\sin3h}{3h}\frac{9}{2}=\frac{9}{2}
$$
Thus $f'(0)=9/2$. In particular the function is continuous at $0$.

Since, for $x\ne0$, you can simplify
$$
f'(x)=\frac{6x\sin3x\cos3x-\sin^23x}{2x^2}
$$
and
$$
\lim_{x\to0}f'(x)=
\lim_{x\to0}\left(9\frac{\sin3x}{3x}\cos3x-
\frac{9}{2}\frac{\sin3x}{3x}\frac{\sin3x}{3x}
\right)=\frac{9}{2}
$$
you might suspect that you could compute directly $\lim_{x\to0}f'(x)$. This suspect is right, provided you prove first that $f$ is continuous at $0$: you're  using l'Hôpital's theorem, in this way.
