next up previous index
Next: 12. Extreme Values of Up: 11. Calculation of Derivatives Previous: 11.2 Some General Differentiation   Index

11.3 Composition of Functions

11.26   Definition ($f\circ g$.) Let $A,B,C,D$ be sets and let $f\colon A\to B,\; g\colon C\to D$ be functions. The composition of $f$ and $g$ is the function $f\circ g$ defined by:

\begin{eqnarray*}
{\rm codomain}(f\circ g) &=& B={\rm codomain}(f). \\
\mbox{{\...
...=& \{x\in\mbox{{\rm dom}}(g)\colon g(x)\in\mbox{{\rm dom}}(f)\};
\end{eqnarray*}



i.e., $\mbox{{\rm dom}}(f\circ g)$ is the set of all points $x$ such that $f\Big(
g(x)\Big)$ is defined. The rule for $f\circ g$ is

\begin{displaymath}(f\circ g)(x)=f\Big( g(x)\Big) \mbox{ for all } x\in\mbox{{\rm dom}}(f\circ g).\end{displaymath}

11.27   Example. If $f(x)=\sin (x)$ and $g(x)=x^2-2$, then

\begin{displaymath}(f\circ g)(x)=\sin (x^2-2)\end{displaymath}

and

\begin{displaymath}(g\circ f)(x)=\sin^2(x)-2.\end{displaymath}

Thus

\begin{displaymath}(f\circ g)(0)=\sin (-2) \mbox{ and } (g\circ f)(0)=-2\neq (f\circ g)(0).\end{displaymath}

So in this case $f\circ g\neq g\circ f$. Thus composition is not a commutative operation.



If $h(x)=\ln (x)$ and $k(x)=\vert x\vert$, then

\begin{displaymath}(h\circ k)(x)=\ln (\vert x\vert)\end{displaymath}

and

\begin{displaymath}(k\circ h)(x)=\vert\ln (x)\vert.\end{displaymath}

11.28   Exercise. For each of the functions $F$ below, find functions $f$ and $g$ such that $F = f\circ g$. Then find a formula for $g \circ f$.
a)
$F(x) = \ln(\tan(x))$.
b)
$F(x) = \sin(4(x^2 + 3))$.
c)
$F(x) = \vert\sin(x)\vert$.

11.29   Exercise. A Let

\begin{eqnarray*}
f(x) &=& \sqrt{ 1- x^2},\\
g(x) &=& {1 \over 1 - x}.\\
\end{eqnarray*}



Calculate formulas for $f\circ f$, $f\circ(f\circ f)$, $( f \circ f) \circ f $, $g\circ g$, $(g\circ g) \circ g$, and $g \circ (g\circ g)$.

11.30   Entertainment (Composition problem.) From the previous exercise you should be able to find a subset $A$ of $\mbox{{\bf R}}$, and a function $f:A \to \mbox{{\bf R}}$ such that $(f\circ f)(x) = x$for all $x\in A$. You should also be able to find a subset $B$ of $\mbox{{\bf R}}$ and a function $g:B\to \mbox{{\bf R}}$ such that $(g\circ(g\circ g))(x)
= x$ for all $x \in B$. Can you find a subset $C$ of $\mbox{{\bf R}}$, and a function $h:C \to \mbox{{\bf R}}$ such that $(h\circ (h\circ (h\circ h)))(x) = x$ for all $x \in C$? One obvious example is the function $f$ from the previous example. To make the problem more interesting, also add the condition that $(h\circ h)(x) \neq x$ for some $x$ in $C$.

11.31   Theorem (Chain rule.) Let $f,g$ be real valued functions such that
$\mbox{{\rm dom}}(f)\subset\mbox{{\bf R}}$ and $\mbox{{\rm dom}}(g)\subset\mbox{{\bf R}}$. Suppose $a\in\mbox{{\rm dom}}(g)$ and $g(a)\in\mbox{{\rm dom}}f$, and $g$ is differentiable at $a$ and $f$ is differentiable at $g(a)$. Then $f\circ g$ is differentiable at $a$, and

\begin{displaymath}(f\circ g)^\prime (a)=f^\prime \Big( g(a)\Big)\cdot g^\prime (a).\end{displaymath}

Before we prove the theorem we will give a few examples of how it is used:

11.32   Example. Let $H(x)=\sqrt{10+\sin x}$. Then $H=f\circ g$ where

\begin{displaymath}\begin{array}{ll}
f(x)=\sqrt x, & g(x)=10+\sin (x),\\
\\
f^...
...style {1\over {2\sqrt x}}, & g^\prime (x)=\cos (x).
\end{array}\end{displaymath}

Hence

\begin{eqnarray*}
H^\prime (x) &=& f^\prime \Big( g(x)\Big)\cdot g^\prime (x) \\
&=& {1\over {2\sqrt{10+\sin (x)}}}\cdot \cos (x).
\end{eqnarray*}





Let $K(x)=\ln (5x^2+1)$. Then $K=f\circ g$ where

\begin{displaymath}\begin{array}{ll}
f(x)=\ln (x), & g(x)=5x^2+1,\\
\\
f^\prime (x)=\displaystyle {1\over x}, & g^\prime (x)=10x.
\end{array}\end{displaymath}

Hence

\begin{eqnarray*}
K^\prime (x) &=& f^\prime\Big( g(x)\Big)\cdot g^\prime (x)\\
&=& {1\over {5x^2+1}}\cdot 10x={{10x}\over {5x^2+1}}.
\end{eqnarray*}



Usually I will not write out all of the details of a calculation like this. I will just write:

Let $f(x)=\tan (2x+4)$. Then $f^\prime (x)=\sec^2(2x+4)\cdot 2$.

Proof of chain rule: Suppose $g$ is differentiable at $a$ and $f$ is differentiable at $g(a)$. Then

\begin{displaymath}
{{f\Big( g(x)\Big)-f\Big(g(a)\Big)}\over
{x-a}}={{f\Big(g(x)...
...ig(g(a)\Big)}\over {g(x)-g(a)}}\cdot
{{g(x)-g(a)}\over {x-a}}.
\end{displaymath} (11.33)

Since $g$ is differentiable at $a$, we know that

\begin{displaymath}\lim_{x\to a} {g(x) - g(a) \over x-a } = g'(a). \end{displaymath}

Hence the theorem will follow from (11.33), the definition of derivative, and the product rule for limits of functions, if we can show that

\begin{displaymath}\lim_{x\to a} {f(g(x)) - f(g(a)) \over g(x) - g(a)} = f'(g(a)).\end{displaymath}

Since $g$ is differentiable at $a$, it follows from lemma 11.17 that
\begin{displaymath}
\lim_{x\to a} g(x) = g(a).
\end{displaymath} (11.34)

Let $\{x_n\}$ be a generic sequence in $\mbox{{\rm dom}}(f\circ g)\setminus\{a\}$, such that $\{x_n\}\to a$. Then by (11.34), we have
\begin{displaymath}
\lim \{g(x_n)\} = g(a).
\end{displaymath} (11.35)

Since $f$ is differentiable at $g(a)$, we have

\begin{displaymath}\lim_{t \to g(a)} {f(t) - f(g(a)) \over t - g(a)} = f'(g(a)). \end{displaymath}

From this and (11.35) it follows that

\begin{displaymath}\lim \left\{ {f(g(x_n)) - f(g(a)) \over g(x_n) - g(a) }\right\}
= f'(g(a)).\end{displaymath}

Since this holds for a generic sequence $\{x_n\}$ in $\mbox{{\rm dom}}(f\circ g)\setminus\{a\}$, we have

\begin{displaymath}\lim_{x\to a} {f(g(x)) -f(g(a)) \over x-a} = f'(g(a)),\end{displaymath}

which is what we wanted to prove. To complete the proof, I should show that $a$ is an interior point of $\mbox{{\rm dom}}(f\circ g)$. This turns out to be rather tricky, so I will omit the proof.

Remark: Our proof of the chain rule is not valid in all cases, but it is valid in all cases where you are likely to use it. The proof fails in the case where every interval $\Big(
g(a)-\epsilon,\; g(a)+\epsilon\Big)$ contains a point $b\neq a$ for which $g(b)=g(a)$. (You should check the proof to see where this assumption was made.) Constant functions $g$ satisfy this condition, but if $g$ is constant then $f\circ g$ is also constant so the chain rule holds trivially in this case. Since the proof in the general case is more technical than illuminating, I am going to omit it. Can you find a non-constant function $g$ for which the proof fails?

11.36   Example. If $f$ is differentiable at $x$, and $f(x)\neq 0$, then

\begin{displaymath}{d\over {dx}}\Big(\vert f(x)\vert\Big)={{f(x)}\over {\vert f(x)\vert}}f^\prime (x).\end{displaymath}

Also

\begin{eqnarray*}
{d\over {dx}}\Bigg(\ln\Big(\vert f(x)\vert\Big)\Bigg) &=& {1\o...
...{{f(x)f^\prime (x)}\over
{f(x)^2}}={{f^\prime (x)}\over {f(x)}};
\end{eqnarray*}



i.e.,
\begin{displaymath}
{d\over {dx}}\Big(\ln \vert f(x)\vert\Big)={{f^\prime (x)}\over {f(x)}}
\end{displaymath} (11.37)

I will use this relation frequently.

11.38   Example (Logarithmic differentiation.) Let
\begin{displaymath}
h(x)= {{\sqrt{(x^2+1)}(x^2-4)^{10}}\over {(x^3+x+1)^3}}.
\end{displaymath} (11.39)

The derivative of $h$ can be found by using the quotient rule and the product rule and the chain rule. I will use a trick here which is frequently useful. I have

\begin{displaymath}\ln\Big( \vert h(x)\vert\Big)={1\over 2}\ln (x^2+1)+10\ln (\vert x^2-4\vert)-3\ln
(\vert x^3+x+1\vert).\end{displaymath}

Now differentiate both sides of this equation using (11.37) to get

\begin{displaymath}{{h^\prime (x)}\over {h(x)}}={1\over 2}{{2x}\over {x^2+1}}+10 {{2x}\over
{x^2-4}}-3 {{3x^2+1}\over {x^3+x+1}}.\end{displaymath}

Multiply both sides of the equation by $h(x)$ to get

\begin{displaymath}h^\prime (x)= {{\sqrt{x^2+1}(x^2-4)^{10}}\over {(x^3+x+1)^3}}...
...x^2+1}}+{{20x}\over {x^2-4}}-{{3(3x^2+1)}\over {x^3+x+1}}\Big].\end{displaymath}

This formula is not valid at points where $h(x)=0$, because we took logarithms in the calculation. Thus $h$ is differentiable at $x=2$, but our formula for $h^\prime (x)$ is not defined when $x=2$.

The process of calculating $f'$ by first taking the logarithm of the absolute value of $f$ and then differentiating the result, is called logarithmic differentiation.

11.40   Exercise. A Let $h$ be the function defined in (11.39) Show that $h$ is differentiable at $2$, and calculate $h'(2)$.

11.41   Exercise. Find derivatives for the functions below. (Assume here that $f$ is a function that is differentiable at all points being considered.)

a)
$F(x) = \sin(f(x))$.
b)
$G(x) = \cos(f(x))$.
c)
$\displaystyle { H(x) = (f(x))^r}$, where $r$ is a rational number.
d)
$K(x) = \ln((f(x))$.
e)
$L(x) = \vert f(x)\vert$.
f)
$M(x) = \tan(f(x))$.
g)
$N(x) = \cot(f(x))$.
h)
$P(x) = \sec(f(x))$.
i)
$Q(x) = \csc(f(x))$.
j)
$R(x) = \ln(\vert f(x)\vert)$.

11.42   Exercise. Find derivatives for the functions below. (Assume here that $f$ is a function that is differentiable at all points being considered.)
a)
$F(x) = f(\sin(x))$.
b)
$G(x) = f(\cos(x))$.
c)
$\displaystyle { H(x) = f(x^r)}$, where $r$ is a rational number.
d)
$K(x) = f(\ln(x))$.
e)
$L(x) = f(\vert x\vert)$.
f)
$M(x) = f(\tan(x))$.
g)
$N(x) = f(\cot(x))$.
h)
$P(x) = f(\sec(x))$.
i)
$Q(x) = f(\csc(x))$.
j)
$R(x) = f(\ln(\vert x\vert)$.

11.43   Exercise. A Calculate the derivatives of the following functions. Simplify your answers.
a)
$\displaystyle {a(x) = \sin^3(x) = (\sin(x))^3}$.
b)
$\displaystyle {b(x) = \sin(x^3)}$.
c)
$\displaystyle {c(x) = (x^2 + 4)^{10}}$.
d)
$f(x)=\sin (4x^2+3x)$.
e)
$g(x)=\ln\Big( \vert\cos (x)\vert \Big)$.
f)
$h(x)=\ln\Big(\vert \sec (x)\vert \Big)$.
g)
$k(x)=\ln\Big(\vert \sec (x)+\tan (x)\vert \Big)$.
h)
$l(x)=\ln\Big(\vert \csc (x)+\cot (x)\vert \Big)$.
i)
$m(x)=3x^3\ln (5x)-x^3$.
j)
$\displaystyle { n(x)=\sqrt{x^2+1}+\ln \Big( {{\sqrt{x^2+1}-1}\over x}\Big)}$.
k)
$\displaystyle { p(x)={1\over 2}(x+4)^2-8x+16\ln (x+4)}$.
l)
$\displaystyle { q(x)={x\over 2}\Big[ \sin \Big(\ln (\vert 6x\vert)\Big)-\cos\Big(\ln
(\vert 6x\vert)\Big)\Big]}$.


next up previous index
Next: 12. Extreme Values of Up: 11. Calculation of Derivatives Previous: 11.2 Some General Differentiation   Index
Ray Mayer 2007-09-07