# Chain Rule

## Introduction

Our goal is to find the derivatives of compositions of functions such as $$\cos\left(e^{x^2}+3x\sin x\right)$$ and $$\cos(x^2+9)$$.

## Composition of functions

We will first review the composition of functions. If you want to read more on this, please follow this link Functions in Mathematics.

Assume that $$u(x)=x^3+4x$$ and $$v(x)=\cos x$$. Then $$v$$ is a function that maps a real number $$x$$ to $$\cos x$$. The function $$u$$ maps any real number $$x$$ to $$x^3+4x$$. In particular $$u(7)=7^3+4\cdot 7$$, $$u(\star)=\star^3+4\cdot \star$$, and $$u(v(x))=(v(x))^3+4\cdot v(x)= \cos^3x+4\cos x$$. The composition $$u(v(x))$$ is another function and it maps $$x$$ to $$\cos^3x+4\cos x$$. If we call $$f(x)=\cos^3x+4\cos x$$ we can talk about the derivative of $$f$$.

Example Assume that $$f(x)=2^x$$ and $$g(x)=5\cdot x-6$$. Let $$h$$ be the function defined as $$h(x)=f(g(x))$$ and let $$m$$ be the function defined as $$m(x)=g(f(x))$$. Determine $$h(3)$$ and $$m(3)$$.

## Derivative of a composition of functions

We will now derive a formula for the derivative of a composition of functions $$f(x)=u(v(x))$$ that involves the derivatives of $$u$$ and $$v$$. This formula is known as the chain rule.

Theorem (Chain rule) Assume that $$u$$ and $$v$$ are two functions such that $$v$$ is differentiable at point $$a$$, and $$u$$ is differentiable at point $$v(a)$$. Then the function $$f(x)=u(v(x))$$ is differentiable at $$a$$ and its derivative satisfies: $f^{\prime}(a)=u^{\prime}(v(a))\cdot v^{\prime}(a).$

Let us consider the following example.

Example Prove that the function $$f(x)=\cos(3x+x^2)$$ is differentiable and find its derivative $$f^{\prime}(x)$$ for $$x\in\mathbb R$$.

## Derivative of the inverse function

We will derive a formula that will help us in finding derivatives of $$\ln$$ and inverse trigonometric functions.

Theorem (Derivative of inverse function) Let $$f:\mathbb R\to\mathbb R$$ be a continuously differentiable function at $$a\in\mathbb R$$ for which $$f^{\prime}(a)\neq 0$$. Then its inverse $$g(z)=f^{-1}(z)$$ is differentiable at $$b=f^{-1}(a)$$ and its derivative satisfies $g^{\prime}(b)=\frac1{f^{\prime}\left(f^{-1}(b)\right)}.$

We can now find the derivative of $$\ln$$, $$\arcsin$$, $$\arccos$$, and $$\arctan$$.

Let $$f(x)=e^x$$. Then $$f^{-1}(x)=\ln x$$ and according to the previous theorem we have $\left(\ln x\right)^{\prime}=\frac1{f^{\prime}(\ln x)}=\frac1{e^{\ln x}}=\frac1x.$

Let $$f(x)=\sin x$$. Then $$f^{-1}(x)=\arcsin x$$, hence $\left(\arcsin x\right)^{\prime}=\frac1{f^{\prime}(\arcsin x)}=\frac1{\cos(\arcsin x)}=\frac1{\sqrt{1-x^2}},\;\; \;\mbox{for }x\in(-1,1).$

## Practice problems

Problem 1. If $$u(x)=\sin x$$ and $$v(x)=x^2$$, determine the $$u(v(x))$$.

Problem 2. If $$u(x)= x^3$$ and $$v(x)=x+4$$, and $$w(x)=\cos (x+1)$$, determine the $$u(v(w(x)))$$.

Problem 3. Find the derivative of the function $$f(x)=\cos(x^3)$$.

Problem 4. Find the derivative of the function $$f(x)=e^{-\frac{x^2}2}$$.

Problem 5. Assume that $$u$$ and $$v$$ are the functions that satisfy: $$u(0)=1$$, $$u(1)=2$$, $$u(2)=3$$, $$v(0)=2$$, $$v(1)=3$$, $$v(2)=4$$, $$u^{\prime}(0)=4$$, $$u^{\prime}(1)=5$$, $$u^{\prime}(2)=6$$, $$v^{\prime}(0)=7$$, $$v^{\prime}(1)=8$$, $$v^{\prime}(2)=9$$. Let $$f(x)=u(v(x))$$. Find $$f^{\prime}(0)$$.