# The Chain Rule

With our current derivative rules, there are still some functions that we can't take the derivative of. Take for example $f(x) = sin(x + 3)$. We know how to take the derivate of sin(x), but when we create a composite function out of it, we have no strategy to solve the problem.

The chain rule is a way of taking derivatives of composite functions. It will enable us to determine derivates for functions such as $f(x) = sin(x + 3)$.

**The Chain Rule: **If g is differentiable at x and f is differentiable at g(x), then the composite function, f(g(x)) is differentiable at x, and is defined as: $\frac{dy}{dx}(f(g(x)) = f'(g(x))*g'(x)$.

Essentially, what we are doing is taking the derivative of the first function in the composition, then multiplying by the derivative of the second function in composition. The proof of chain rule involves some concepts that we have not covered yet, and is rather complicated. For those reasons, we will focus more on the application of the rule for this section.

Let's take a look at some examples of where chain rule is helpful for us.

**Example: **Suppose $f(x) = sin(x + 3)$. Find f'(x)

For this problem, it is useful to identify f(x) and g(x) before trying to apply the chain rule. The function f(x) is the outside function, and g(x) is the inside function. In this case, $f(x) = sin(x)$ and $g(x) = x+3$. We can confirm this is true by calculating $f(g(x)) = sin(x + 3)$.

From here we can apply the chain rule: $\frac{dy}{dx}(f(g(x)) = f'(g(x))*g'(x) = cos(x + 2) * (1) = cos(x + 2)$

**Example: **Suppose $f(x) = \sqrt{x^2+2x}$. Find f'(x)

In this case, $f(x) = \sqrt{x}$ and $g(x) = (x^2 + 2x$).

$\frac{dy}{dx}(\sqrt{x^2+2x}) = \frac{1}{2}(x^2+2x)^{-\frac{1}{2}}*(2x+2)$

Chain rule not only makes it possible to calculate new derivatives, but also makes some other derivatives significantly easier to calculate.

**Example: **Suppose $f(x) = (x^2+3x)^{10}$. Find f'(x)

This is a problem we could solve without chain rule, however, that involves expanding out the 10^{th} power, which is very time-consuming.

Instead of doing that, we can apply chain rule. Let $f(x) = x^{10}$ and let $g(x) = x^2+3x$. You will see that doing this, $f(g(x)) = (x^2 + 3x)^{10}$

Now we can apply chain rule.

$\frac{dy}{dx}(x^2+3x)^{10} = 10(x^2+3x)^9*(2x+3)$