## Section4.3The Chain Rule

In the last two sections we learned rules to symbolically differentiate some functions. To summarize, we have established some elementary formulas and some arithmetic rules.

### Elementary Formulas.

If $$f(x)=a\text{,}$$ then $$f'(x)=0\text{.}$$

If $$f(x)=ax\text{,}$$ then $$f'(x)=a\text{.}$$

If $$f(x)=a*x^n\text{,}$$ then $$f(x)=a*n*x^{n-1}\text{,}$$ for any nonzero number n.

If $$f(x)=e^x\text{,}$$ then $$f'(x)=e^x\text{.}$$

If $$f(x)=a^x\text{,}$$ then $$f'(x)=a^x \ln(a)\text{.}$$

If $$f(x)=\ln(x)\text{,}$$ then $$f'(x)=1/x$$

### Arithmetic derivative rules.

Arithmetic derivative rules:

Scalar multiple rule: The derivative of $$c*f(x)$$ is $$c*f'(x)\text{.}$$

Sum and difference rule: The derivative of $$f(x)\pm g(x)$$ is $$f'(x)\pm g'(x)\text{.}$$

Product Rule: The derivative of $$f(x)g(x)$$ is $$f' (x) g(x)+f(x)g'(x)\text{.}$$

Quotient Rule: The derivative of $$f(x)/g(x)$$ is $$\frac{f'(x)g(x)-f(x)g'(x)}{(g(x))^2} \text{.}$$

The other way we traditionally build functions from simpler functions is by use of composition. We want to be able to take derivatives of functions like $$(2x+3)^{52}\text{,}$$ $$\sqrt{(x^2 )+5x+7}\text{,}$$ and $$1.06^{.2x}\text{.}$$

Find the derivative of the following functions:

1. $$\displaystyle f(p)=(p^3+2 p+5)^7.$$

2. $$\displaystyle g(q)=\sqrt{q^2+6}.$$

3. $$\displaystyle h(x)=e^{2 x+5}.$$

Solution.
1. We could do this problem by expanding it to a polynomial and using rules from the previous section, but that is much too hard. We can write $$f(p)$$ as $$g(h(p))$$ where $$h(p)=p^3+2 p+5$$ and $$g(p)=p^7\text{.}$$ We use the rules from the previous section to compute $$h'(p)=3 p^2+2$$ and $$g'(p)=7p^6\text{.}$$ Composing we get $$g'(h(p))=7(p^3+2 p+5)^6\text{.}$$ Thus

\begin{equation*} f'(p)=g'(h(p))h'(p)=7(p^3+2 p+5)^6(3 p^2+2 )\text{.} \end{equation*}
2. We can write $$g(q)$$ as $$f(h(q))$$ where $$h(q)=q^2+6$$ and $$f(q)=\sqrt{q}\text{.}$$ We use the rules from the previous section to compute $$h'(q)=2 q$$ and $$f'(q)= 1/(2\sqrt{q})\text{.}$$ Composing we get $$f'(h(q))= 1/(2\sqrt{(q^2+6 )})\text{.}$$ Thus

\begin{equation*} g'(q)=f'(h(q)) h'(q)=(2 q)/(2\sqrt{(q^2+6 )}) \end{equation*}
3. We can write $$h(t)$$ as $$f(g(t))$$ where $$g(x)=2 t+5$$ and $$f(x)=e^t\text{.}$$ We use the rules from the previous section to compute $$g'(t)=2$$ and $$f'(t)=e^t\text{.}$$ Composing we get $$f' (h(t))= e^(2 t+5)\text{.}$$ Thus

\begin{equation*} g'(t)=f'(h(t)) h' (t)= 2 e^{2 t+5}\text{.} \end{equation*}

### Theory and justification.

As in the previous section, we will use local linearity to justify our derivative rule.

To simplify notation, we will let $$g(x)=u=b x+d\text{.}$$ We will be substituting $$g(x)$$ into $$f(x)$$ and so we will be using the functions $$f(u)=a u+c \text{,}$$ with $$a=f' (u)=f' (g(x_0 ))$$ and $$g(x)=b x+d\text{,}$$ with $$b=g'(x_0 )\text{.}$$

The composition of $$f$$ and $$g$$ can then be written as

\begin{equation*} f(g(x))=a (b x+d)+c=(a b) x+(a d+c)\text{.} \end{equation*}

The coefficient of the linear term is the product of the coefficients of the two linear terms we began with. Hence we find that $$[f(g(x_0 ))]'=a b=f'(g(x_0 ))*g'(x_0)\text{.}$$

### The Chain rule in other notation.

For the problems above, we used the prime notation, $$f'(x)\text{,}$$ $$f'(q)\text{,}$$ $$f'(t)\text{,}$$ etc, for derivatives. There is also a fractional notation for derivatives, $$\frac{df}{dx}\text{,}$$ $$\frac{df}{dq}\text{,}$$ $$\frac{df}{dt}$$ or $$\frac{dy}{dx}\text{,}$$ $$\frac{dp}{dq}\text{,}$$ $$\frac{dq}{dt}\text{,}$$ etc. that is commonly used. Intuitively, when we have zoomed in far enough for the graph of $$f(x)$$ to look like a straight line, then the derivative is the small unit of rise over the small unit of run. With that notation the chain rule has a nice formulation where it reduces to the usual rules for multiplying fractions.

#### Chain Rule (fractional notation version).

If $$z=g(x)$$ and $$y=f(z)$$ so $$y=f(g(x))\text{,}$$ then

\begin{equation*} \frac{dy}{dx}=\frac{dy}{dz} \frac{dz}{dx} \text{ or } \frac{df}{dx}=\frac{df}{dg} \frac{dg}{dx}\text{.} \end{equation*}

We have two processes that need to be run in succession to produce gizmos. The yields of the two processes are given by:

\begin{equation*} \operatorname{intermediate}(\raw)=-25+7.3 \raw+.2 \raw^2 \end{equation*}
\begin{equation*} \operatorname{gizmos}(\intermediate)=-5+12\intermediate\text{.} \end{equation*}

Find the rate of production in terms of the amount of raw material.

Solution.

We want to find the derivatives of the individual processes and then use the chain rule.

\begin{equation*} \frac{d\intermediate}{d\raw}=7.3 +.4 \raw \end{equation*}
\begin{equation*} \frac{d\gizmos}{d\intermediate}=12\text{.} \end{equation*}

Thus

\begin{align*} \frac{d\gizmos}{d\raw}\amp =\frac{d\gizmos}{d\intermediate}\frac{d\intermediate}{d\raw}\\ \amp =12*(7.3 +.4 \raw)=87.6+4.8 raw\text{.} \end{align*}

The rate of production is a linear function of the amount of raw material used.

Find $$h'(x)$$ for $$h(x)=f(g(x))$$ for the given $$f(z)$$ and $$g(x)\text{.}$$

1. $$f(z)=2z+7$$ and $$g(x)=z=3 x+5\text{.}$$

2. $$f(z)=z^3$$ and $$g(x)=x^2+7\text{.}$$

3. $$f(z)=e^z$$ and $$g(x)=x^2+3\text{.}$$

Solution.
1. $$\displaystyle \frac{dh}{dx}=\frac{dh}{dz}\frac{dg}{dx}=2*3=6.$$

2. $$\frac{dh}{dx}=\frac{dh}{dz}\frac{dg}{dx}=3z^2*2x=3(x^2+7)^2*2x\text{.}$$

(Notice that the two derivatives are in terms of different variables. We need to convert to a single variable.)

3. $$\displaystyle \frac{dh}{dx}=\frac{dh}{dz}\frac{dg}{dx}=e^z*2x=e^{(x^2+3)}*2x.$$

Warning for this method:

We tend to use x as the variable for almost all functions. When we use the chain rule we need to remember that the input for the second function is the output from the first function. It is safest to use separate variable for the two functions.

Special cases:

Two special cases of the chain rule come up so often, it is worth explicitly noting them.

The general power rule

$$[(f(x))^n ]'=n (f(x))^{n-1} f'(x)\text{.}$$ This is simply the chain rule when the second function is a power.

The chain rule with a linear function

$$\displaystyle [(f(a x+b))]'=(f'(a x+b))*a$$

### ExercisesExercises: The Chain Rule

#### Exercise Group.

Find the derivatives of the following functions.

##### 1.

$$f(x)=(x^3+5 x+7)^4\text{.}$$

Solution.

Let $$u=x^3+5 x+7\text{,}$$ then $$f(x)=(u)^4\text{,}$$ and

\begin{equation*} f'(x)=4u^3 du=4(x^3+5 x+7)^3 (3x^2+5)\text{.} \end{equation*}
##### 2.

$$g(x)=(x^2-6x+8)^{123}\text{.}$$

##### 3.

$$h(x)=\sqrt{(5x^7+3x-2)}\text{.}$$

Solution.

Let $$h(x)=\sqrt{5x^7+3x-2}=u^{1/2}\text{,}$$ with $$u= 5x^7+3x-2\text{.}$$

\begin{equation*} h'(x)=1/2 u^{-1/2} du=1/2 (5x^7+3x-2)^{-1/2} (35x^6+3)\text{.} \end{equation*}

Another way to think of the chain rule is that we need to take derivatives of the different functions that make up the composite function:

\begin{align*} h(x)\amp =\sqrt{5x^7+3x-2}=(5x^7+3x-2)^{1/2}\\ h'(x)\amp =\text{"derivative outside function"}*\text{"derivative inside function"}\\ \amp =[1/2 (5x^7+3x-2)^{-1/2} ][(35x^6+3)]\text{.} \end{align*}
##### 4.

$$k(x)=\ln(e^x+5)\text{.}$$

##### 5.

$$m(x)=\ln(\ln(\ln(x^2+3)))\text{.}$$

Solution.
\begin{align*} m'(x)\amp =\frac{1}{\ln(\ln(x^2+3))} \frac{d}{dx} \ln(\ln(x^2+3) )\\ \amp =\frac{1}{\ln(\ln(x^2+3))}* \frac{1}{\ln(x^2+3)}*\frac{d}{dx} \ln(x^2+3)\\ \amp =\frac{1}{\ln(\ln(x^2+3))}* \frac{1}{\ln(x^2+3)}*\frac{1}{x^2+3}*\frac{d}{dx} (x^2+3)\\ \amp =\frac{1}{\ln(\ln(x^2+3))}* \frac{1}{\ln(x^2+3)}*\frac{1}{x^2+3}*2x\text{.} \end{align*}
##### 6.

$$n(x)=(((x^2+2)^2+3)^2+4)^2+5\text{.}$$

##### 7.

$$f(x)=e^{2x+3}\text{.}$$

$$f'(x)=e^(2x+3) (2)$$

##### 8.

$$g(x)=(\ln(10x-15))^2\text{.}$$

##### 9.

$$h(x)=\ln((10x-15)^2)\text{.}$$

Solution.
\begin{equation*} h'(x)=\frac{1}{(10x-15)^2}[2(10x-15)]*10 =\frac{20}{10x-15}\text{.} \end{equation*}

Hint: It is easier to simplify $$h(x)$$ to $$2\ln(10x-15)$$ first.

##### 10.

$$k(x)=((\ln(x))(e^x))^3\text{.}$$

##### 11.

$$m(x)=\ln(e^{(x^2+x)}+x)\text{.}$$

Solution.
\begin{align*} m'(x)\amp =\frac{1}{e^{(x^2+x)}+x} [e^{(x^2+x)}*(2x+1)+1]\\ \amp=\frac{(2x+1) e^{(x^2+x)}+1}{e^{(x^2+x)}+x}\text{.} \end{align*}
##### 12.

$$n(x)=\left(\frac{x^2-5x+3}{e^x }\right)^5\text{.}$$

##### 13.

$$f(x)=\left(\frac{\ln(x)}{(2x+7)}\right)^4\text{.}$$

Solution.
\begin{align*} f'(x)\amp=4\left(\frac{\ln(x)}{2x+7}\right)^3*\frac{d}{dx} \left(\frac{\ln(x)}{2x+7}\right)\\ \amp =4\left(\frac{\ln(x)}{2x+7}\right)^3*\frac{(\ln(x) )' (2x+7)-(\ln(x) ) (2x+7)'}{(2x+7)^2}\\ \amp =4\left(\frac{\ln(x)}{2x+7}\right)^3*\frac{\frac{1}{x} (2x+7)-(\ln(x) )(2)}{(2x+7)^2}\\ \amp =4\left(\frac{\ln(x)}{2x+7}\right)^3*\frac{ (2x+7)-(x\ln(x) )(2)}{x(2x+7)^2}\text{.} \end{align*}
##### 14.

$$g(x)=\ln\left(\frac{x^3+2x+9}{1.07^x} \right)\text{.}$$

#### Exercise Group.

For the following problems, use the following data to find the indicated derivative.

 x 0 1 2 3 4 5 6 7 8 9 f(x) 3 5 7 1 9 8 4 2 0 6 f'(x) 7 6 5 4 3 2 1 0 9 8 g(x) 8 4 0 6 2 9 5 1 7 3 g'(x) 6 8 4 2 0 7 9 3 5 1
##### 15.

$$h'(2)\text{,}$$ where $$h(x)=f(g(x))\text{.}$$

Solution.
\begin{align*} h'(x)\amp =f'(g(x)) g'(x)\\ h'(2)\amp =f'(g(2)) g' (2)\\ \amp =f' (0)*4 =7*4=28\text{.} \end{align*}
##### 16.

$$h'(5)\text{,}$$ where $$h(x)=f(f(x))\text{.}$$

##### 17.

$$h'(7)\text{,}$$ where $$h(x)=g(g(x))\text{.}$$

Solution.
\begin{align*} h' (x)\amp =g' (g(x)) g' (x)\\ h' (7)\amp =g' (g(7)) g' (7)\\ \amp =g' (1)*3=8*3=24\text{.} \end{align*}
##### 18.

$$h'(4)\text{,}$$ where $$h(x)=g(f(x))\text{.}$$

#### 19.

The pretax profit function is $$\profit(q)=-q^2+300q-2500$$ at the widget factory. The tax function is $$\tax(\profit)=0.4(\profit-1000)\text{.}$$ Find the equation of the line tangent to the graph of after tax profits when $$q=100\text{.}$$

Solution.

We will need a point and a slope to construct the tangent line.

Point: when $$q=100\text{,}$$ we have $$\profit(100)=-100^2+300(100)-2500=-10,000+30,000-2500=18,500$$

Also $$\tax(\profit)=0.4(\profit-1000),$$ gives

\begin{equation*} \tax(18,500)=0.4(18,500-1000)= 7,000\text{.} \end{equation*}

So the point is $$q = 100\text{,}$$ $$tax = 7,000\text{.}$$

Slope: $$\frac{d\tax}{dq}= {d\tax}{d\profit}*\frac{d\profit}{dq}=(0.4)*(-2q+300)$$

So at $$q =100$$ we have $$m=\frac{d\tax}{dq}= 0.4*(-200+300)= 40\text{.}$$

Tangent line: $$\tax-\tax_0=m(q-q_0)$$

So $$\tax=tax_0+m(q-q_0 )= 7000+40(q-100)$$

In slope-intercept form we have

\begin{equation*} \tax(q)=40q+3000\text{.} \end{equation*}

Note that here we have approximated a composite function by something much simpler. Finding tax meant we had to first find the profit, and then plug that profit into the tax function. Now, all we have to do is plug our value of $$q$$ into the linear equation!

#### 20.

The revenue function for gizmos is $$\revenue(q)=.2q^2+500q\text{.}$$ The commission cost to the sales force is $$\operatorname{commissions}(\revenue)=0.1\revenue+\revenue^2/3,000,000\text{.}$$ Find the equation of the tangent line to commissions as a function of quantity, when $$q=1000\text{.}$$