Differentiation

Differentiate the function $f\left(x\right)=\sqrt{\cos 3x}$ with respect to x from first principles.


$\begin{aligned} f'\left(x\right) & = \lim\limits_{h \to 0} \; \dfrac{f\left(x+h\right)-f\left(x\right)}{h} \\ & = \lim\limits_{h \to 0} \; \dfrac{\sqrt{\cos \left(3x+3h\right)}-\sqrt{\cos 3x}}{h} \\ & = \lim\limits_{h \to 0} \; \dfrac{\left[\sqrt{\cos \left(3x+3h\right)}-\sqrt{\cos 3x}\right] \left[\sqrt{\cos \left(3x+3h\right)}+\sqrt{\cos 3x}\right]}{h \left[\sqrt{\cos \left(3x+3h\right)}+\sqrt{\cos 3x}\right]} \\ & = \lim\limits_{h \to 0} \; \dfrac{\cos \left(3x+3h\right)-\cos 3x}{h \left[\sqrt{\cos \left(3x+3h\right)}+\sqrt{\cos 3x}\right]} \\ & \left[\text{Note: } \cos C - \cos D = 2 \sin \left(\dfrac{C+D}{2}\right) \sin \left(\dfrac{D-C}{2}\right)\right] \\ & = \lim\limits_{h \to 0} \; \dfrac{2 \sin \left(\dfrac{3x+3h+3x}{2}\right)\sin \left(\dfrac{3x-3x-3h}{2}\right)}{h\left[\sqrt{\cos \left(3x+3h\right)}+\sqrt{\cos 3x}\right]} \\ & = \lim\limits_{h \to 0} \; \dfrac{2 \sin \left(3x+\dfrac{3h}{2}\right) \sin \left(-\dfrac{3h}{2}\right)}{h \left[\sqrt{\cos \left(3x+3h\right)}+ \sqrt{\cos 3x}\right]} \\ & = -2 \; \lim\limits_{h \to 0} \; \dfrac{1}{\sqrt{\cos \left(3x+3h\right)}+\sqrt{\cos 3x}} \times \lim\limits_{h \to 0} \; \dfrac{\sin \left(\dfrac{3h}{2}\right)}{\dfrac{3h}{2}} \times \dfrac{3}{2} \times \lim\limits_{h \to 0} \; \sin \left(3x + \dfrac{3h}{2}\right) \\ & = -2 \times \dfrac{1}{\sqrt{\cos 3x}+\sqrt{\cos 3x}} \times 1 \times \dfrac{3}{2} \times \sin \left(3x\right) \\ & = \dfrac{-3\sin \left(3x\right)}{2\sqrt{\cos 3x}} \end{aligned}$