Differentiation

Differentiate the function $f\left(x\right)=\sin \left(x^2 + 1\right)$ 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{\sin \left[\left(x+h\right)^2 + 1\right]-\sin \left(x^2+1\right)}{h} \\ & \left[\text{Note: }\sin C - \sin D = 2 \cos \left(\dfrac{C+D}{2}\right) \sin \left(\dfrac{C-D}{2}\right)\right] \\ & = \lim\limits_{h \to 0} \; \dfrac{2 \cos \left[\dfrac{\left(x+h\right)^2 + 1 + x^2 + 1}{2}\right] \sin \left[\dfrac{\left(x+h\right)^2 + 1 - x^2 - 1}{2}\right]}{h} \\ & = \lim\limits_{h \to 0} \; \dfrac{2 \cos \left(\dfrac{2x^2 + 2xh+ h^2 + 2}{2}\right) \sin \left(\dfrac{2hx+h^2}{2}\right)}{h} \\ & = 2 \lim\limits_{h \to 0} \cos \left(x^2 + xh + 1 + \dfrac{h}{2}\right) \times \lim\limits_{h \to 0} \; \dfrac{\sin \left(hx+\dfrac{h^2}{2}\right)}{h\left(x+\dfrac{h}{2}\right)} \times \lim\limits_{h \to 0} \; \left(x+\dfrac{h}{2}\right) \\ & = 2 \times \cos \left(x^2+1\right) \times 1 \times x \\ & = 2 x \cos \left(x^2+1\right) \end{aligned}$