# Find the derivative of $\cos(x^2+1)$ by first principle of derivative.

The question from my textbook requires to find the derivative of the following function with respect to $x$ by the first priciple of derivative (or by the definition of derivative).

$$f(x) = \cos(x^2 + 1)$$

By simply differentiating it with respect to $x$ using the chain rule, we get

$f'(x) = -2x \sin(x^2 + 1) \tag 1$

Here's how I tried solving the problem:

$$f'(x) = \lim \limits_{h \to 0} \frac{\cos[(x+h)^2 + 1] - \cos(x^2 + 1)}h$$

Using the trigonometric identity $\cos A - \cos B = -2\sin(\frac{A+B}2)\sin(\frac{A-B}2)$ we get:

$$f'(x) = -2 \lim \limits_{h \to 0} \left[ \Big( \sin[(x^2 + 1) + h(x+ \frac h2)] \Big) \left( \frac{\sin[hx + \frac {h^2}2]}h \right) \right]$$

Substituting $h$ by $0$ in the first term of the limit we get:

$f'(x) = -2 \sin(x^2 + 1) \lim \limits_{h \to 0} \frac{\sin[hx + \frac {h^2}2]}h \tag 2$

That is how far I could solve.

Now, on comparing equations $(1)$ and $(2)$ I observe that all that's left to do is to prove:

$$\lim \limits_{h \to 0} \frac{\sin[hx + \frac {h^2}2]}h = x$$

This is precisely what I'm unable to do. You may help me prove the above equation or just tell me another way to solve the problem. Any help would be appreciated.

You have correctly solved the problem, for your last limit use the standard result: $$\lim_{h\to 0} \frac{\sin(h)}{h}=1$$

So in your question, we have:

\begin{align}\lim \limits_{h \to 0} \frac{\sin(hx + \frac {h^2}2)}h &= \lim \limits_{h \to 0} \frac{\sin(hx + \frac {h^2}2)}{hx + \frac {h^2}2} \times \frac{hx + \frac {h^2}2}{h}\\ &= \lim \limits_{h \to 0} \frac{\sin(hx + \frac {h^2}2)}{hx + \frac {h^2}2} \times \lim \limits_{h \to 0}\frac{hx + \frac {h^2}2}{h}\\ &= 1 \times x=x \end{align}