# Chain Rule

## Introduction

It is relatively easy to calculate the derivatives of simple functions, like polynomials or trigonometric functions.

But, what about more complicated functions?

For example,  $f(x)=\sin(3x)$ or  $g(x)=(x+1)^{8}?$ Well, the key to calculating the derivatives of these functions is to recognize that these functions are compositions.

For  $f(x)=\sin(3x),$ it is the composition of the function  $y=3x$ with  $y=\sin(x).$ Similarly, for  $g(x)=(x+1)^{8},$ it is the composition of  $y=x+1$ and  $y=x^{8}.$ So, how do we take the derivative of compositions?

The answer to this question is exactly the Chain Rule.

Chain Rule

Let  $y=f(u)$ be a differentiable function of  $u$ and let  $u=g(x)$ be a differentiable function of  $x.$ Then,  $y=f\circ g(x))$ is a differentiable function of  $x$ and

$y'=(f'\circ g(x))\cdot g'(x).$ ## Warm-Up

Calculate  $h'(x).$ 1)   $h(x)=\sin(3x)$ Solution:
Let  $f(x)=\sin(x)$ and  $g(x)=3x.$ Then,  $f'(x)=\cos(x)$ and  $g'(x)=3.$ Now,  $h(x)=f\circ g(x).$ Using the Chain Rule, we have
${\begin{array}{rcl}\displaystyle {h'(x)}&=&\displaystyle {(f'\circ g(x))\cdot g'(x)}\\&&\\&=&\displaystyle {\cos(3x)\cdot 3}\\&&\\&=&\displaystyle {3\cos(3x).}\end{array}}$ $h'(x)=3\cos(3x)$ 2)   $h(x)=(x+1)^{8}$ Solution:
Let  $f(x)=x^{8}$ and  $g(x)=x+1.$ Then,  $f'(x)=8x^{7}$ and  $g'(x)=1.$ Now,  $h(x)=f\circ g(x).$ Using the Chain Rule, we have
${\begin{array}{rcl}\displaystyle {h'(x)}&=&\displaystyle {(f'\circ g(x))\cdot g'(x)}\\&&\\&=&\displaystyle {8(x+1)^{7}\cdot 1}\\&&\\&=&\displaystyle {8(x+1)^{7}.}\end{array}}$ $h'(x)=8(x+1)^{7}.$ 3)   $h(x)=\ln(x^{2})$ Solution:
Let  $f(x)=\ln(x)$ and  $g(x)=x^{2}.$ Then,  $f'(x)={\frac {1}{x}}$ and  $g'(x)=2x.$ Now,  $h(x)=f\circ g(x).$ Using the Chain Rule, we have
${\begin{array}{rcl}\displaystyle {h'(x)}&=&\displaystyle {(f'\circ g(x))\cdot g'(x)}\\&&\\&=&\displaystyle {{\frac {1}{x^{2}}}\cdot 2x}\\&&\\&=&\displaystyle {{\frac {2}{x}}.}\end{array}}$ $h'(x)={\frac {2}{x}}$ ## Exercise 1

Calculate the derivative of  $h(x)=(\sin x+\cos x)^{4}.$ Using the Chain Rule, we have

${\begin{array}{rcl}\displaystyle {h'(x)}&=&\displaystyle {4(\sin x+\cos x)^{3}(\sin x+\cos x)'}\\&&\\&=&\displaystyle {4(\sin x+\cos x)^{3}((\sin x)'+(\cos x)')}\\&&\\&=&\displaystyle {4(\sin x+\cos x)^{3}(\cos x-\sin x)}.\end{array}}$ So, we have

$h'(x)=4(\sin x+\cos x)^{3}(\cos x-\sin x).$ ## Exercise 2

Calculate the derivative of  $h(x)=\sin ^{3}(2x^{2}+x+1).$ First, notice  $h(x)=(\sin(2x^{2}+x+1))^{3}.$ Using the Chain Rule, we have

$h'(x)=3(\sin(2x^{2}+x+1))^{2}\cdot (\sin(2x^{2}+x+1))'.$ Now, we need to use the Chain Rule a second time. So, we get

${\begin{array}{rcl}\displaystyle {h'(x)}&=&\displaystyle {3(\sin(2x^{2}+x+1))^{2}\cos(2x^{2}+x+1)\cdot (2x^{2}+x+1)'}\\&&\\&=&\displaystyle {3\sin ^{2}(2x^{2}+x+1)\cos(2x^{2}+x+1)(4x+1).}\end{array}}$ So, we have

$h'(x)=3\sin ^{2}(2x^{2}+x+1)\cos(2x^{2}+x+1)(4x+1).$ ## Exercise 3

Calculate the derivative of  $h(x)=\cos(2x+1)\sin(x^{2}+3x).$ Using the Product Rule, we have

$h'(x)=\cos(2x+1)(\sin(x^{2}+3x))'+(\cos(2x+1))'\sin(x^{2}+3x).$ For the two remaining derivatives, we need to use the Chain Rule.

So, using the Chain Rule, we have

${\begin{array}{rcl}\displaystyle {h'(x)}&=&\displaystyle {\cos(2x+1)\cos(x^{2}+3x)\cdot (x^{2}+3x)'-\sin(2x+1)\cdot (2x+1)'\sin(x^{2}+3x)}\\&&\\&=&\displaystyle {\cos(2x+1)\cos(x^{2}+3x)(2x+3)-\sin(2x+1)(2)\sin(x^{2}+3x).}\end{array}}$ So, we get

$h'(x)=\cos(2x+1)\cos(x^{2}+3x)(2x+3)-\sin(2x+1)(2)\sin(x^{2}+3x).$ ## Exercise 4

Calculate the derivative of  $h(x)={\frac {\sin(3x)+x\cos(2x)}{x^{2}+1}}.$ First, using the Quotient Rule, we have

${\begin{array}{rcl}\displaystyle {h'(x)}&=&\displaystyle {\frac {(x^{2}+1)(\sin(3x)+x\cos(2x))'-(\sin(3x)+x\cos(2x))(x^{2}+1)'}{(x^{2}+1)^{2}}}\\&&\\&=&\displaystyle {{\frac {(x^{2}+1)[(\sin(3x))'+(x\cos(2x))']-(\sin(3x)+x\cos(2x))(2x)}{(x^{2}+1)^{2}}}.}\end{array}}$ Using the Product Rule, we get

${\begin{array}{rcl}\displaystyle {h'(x)}&=&\displaystyle {\frac {(x^{2}+1)[(\sin(3x))'+x(\cos(2x))'+(x)'\cos(2x)]-(\sin(3x)+x\cos(2x))(2x)}{(x^{2}+1)^{2}}}\\&&\\&=&\displaystyle {{\frac {(x^{2}+1)[(\sin(3x))'+x(\cos(2x))'+1\cos(2x)]-(\sin(3x)+x\cos(2x))(2x)}{(x^{2}+1)^{2}}}.}\end{array}}$ For the remaining derivatives, we need to use the Chain Rule. So, we get

${\begin{array}{rcl}\displaystyle {h'(x)}&=&\displaystyle {\frac {(x^{2}+1)[\cos(3x)(3x)'+x(-\sin(2x))(2x)'+\cos(2x)]-(\sin(3x)+x\cos(2x))(2x)}{(x^{2}+1)^{2}}}\\&&\\&=&\displaystyle {{\frac {(x^{2}+1)[\cos(3x)(3)-x\sin(2x)(2)+\cos(2x)]-(\sin(3x)+x\cos(2x))(2x)}{(x^{2}+1)^{2}}}.}\end{array}}$ So, we have

$h'(x)={\frac {(x^{2}+1)[\cos(3x)(3)-x\sin(2x)(2)+\cos(2x)]-(\sin(3x)+x\cos(2x))(2x)}{(x^{2}+1)^{2}}}.$ 