# Computing derivatives - special – Serlo

Zur Navigation springen Zur Suche springen

## Special cases of the chain rule

Now we want to list a few special cases of the chain rule, which occur frequently in practice. For the derivation of the derivatives of ${\displaystyle \exp }$, ${\displaystyle \ln }$, ${\displaystyle \sin }$, ${\displaystyle \cos }$, ${\displaystyle x\mapsto x^{n}}$ etc. we refer to the following chapter Examples for derivatives (missing).

### Case: ${\displaystyle f}$ is linear

Let ${\displaystyle a,b\in \mathbb {R} }$ and let ${\displaystyle g:\mathbb {R} \to \mathbb {R} }$ be differentiable. Then also ${\displaystyle h:\mathbb {R} \to \mathbb {R} ,\ h(x)=g(ax+b)}$ is differentiable ad at ${\displaystyle x\in \mathbb {R} }$ there is

${\displaystyle h'(x)=ag'(ax+b)}$

Proof

${\displaystyle f:\mathbb {R} \to \mathbb {R} ,\ f(x)=ax+b}$ is differentiable with ${\displaystyle f'(x)=a}$ for all ${\displaystyle x\in \mathbb {R} }$. The chain rule implies differentiablilty of ${\displaystyle h=g\circ f:\mathbb {R} \to \mathbb {R} }$ , where

${\displaystyle h'(x)=g'(f(x))\cdot f'(x)=g'(ax+b)\cdot a=ag'(ax+b)}$

Example

Let ${\displaystyle h:\mathbb {R} \to \mathbb {R} ,\ h(x)=(2x+1)^{2}}$ with ${\displaystyle g(x)=x^{2}}$. Then ${\displaystyle g'(x)=2x}$ for all ${\displaystyle x\in \mathbb {R} }$ so

${\displaystyle h'(x)=2(2x+1)\cdot 2=4(2x+1)}$

### Case: ${\displaystyle g}$ is a power function

Let ${\displaystyle f:D\to \mathbb {R} }$ be differentiable. The also ${\displaystyle f^{n}:D\to \mathbb {R} }$ is differentiable for all ${\displaystyle n\in \mathbb {N} }$, where at ${\displaystyle x\in D}$ there is

${\displaystyle (f^{n})'(x)=nf^{n-1}(x)\cdot f'(x)}$

Proof

${\displaystyle g:\mathbb {R} \to \mathbb {R} ,\ g(x)=x^{n}}$ is differentiable with ${\displaystyle g'(x)=nx^{n-1}}$ for all ${\displaystyle x\in \mathbb {R} }$. The chain rule implies differentiablility of ${\displaystyle f^{n}:D\to \mathbb {R} }$, where

${\displaystyle (f^{n})'(x)=g'(f(x))\cdot f'(x)=nf^{n-1}(x)\cdot f'(x)=nf(x)f^{n-1}(x)}$

Example (Deriving a power function)

Let ${\displaystyle h:\mathbb {R} \to \mathbb {R} ,\ h(x)=\sin ^{2}(x)=(\sin(x))^{2}}$ with ${\displaystyle f(x)=\sin(x)}$. Then ${\displaystyle f'(x)=\cos(x)}$ and for all${\displaystyle x\in \mathbb {R} }$ we have

${\displaystyle h'(x)=2\sin(x)^{2-1}\cos(x)=2\sin(x)\cos(x)}$

### Case: ${\displaystyle g}$ is a root function

Let ${\displaystyle f:D\to \mathbb {R} ^{+}}$ be differentiable. then ${\displaystyle {\sqrt {f}}:D\to \mathbb {R} ^{+}}$ with ${\displaystyle x\mapsto {\sqrt {f(x)}}}$ is differentiable as well and for all ${\displaystyle x\in D}$ there is

${\displaystyle ({\sqrt {f}})'(x)={\frac {f'(x)}{2{\sqrt {f(x)}}}}}$

Proof

${\displaystyle g:\mathbb {R} ^{+}\to \mathbb {R} ,\ g(x)={\sqrt {x}}}$ is differentiable with ${\displaystyle g'(x)={\tfrac {1}{2{\sqrt {x}}}}}$ for all ${\displaystyle x\in \mathbb {R} ^{+}}$. The chain rule implies differentiability of ${\displaystyle {\sqrt {f}}:D\to \mathbb {R} ^{+}}$ where

${\displaystyle ({\sqrt {f}})'(x)=(g\circ f)'(x)=g'(f(x))\cdot f'(x)={\frac {1}{2{\sqrt {f(x)}}}}\cdot f'(x)={\frac {f'(x)}{2{\sqrt {f(x)}}}}}$

Example (Deriving a root function)

Let ${\displaystyle h:\mathbb {R} \to \mathbb {R} ,\ h(x)={\sqrt {\exp(x)}}}$ with ${\displaystyle f(x)=\exp(x)}$. Then ${\displaystyle f'(x)=\exp(x)}$ and for all ${\displaystyle x\in \mathbb {R} }$ there is

${\displaystyle h'(x)={\frac {\exp(x)}{2{\sqrt {\exp(x)}}}}={\frac {\sqrt {\exp(x)}}{2}}}$

### Case: ${\displaystyle g=\exp }$

Let ${\displaystyle f:D\to \mathbb {R} }$ be differentiable. Then ${\displaystyle \exp \circ f:D\to \mathbb {R} }$ is differentiable as well and for all ${\displaystyle x\in D}$ there is

${\displaystyle (\exp \circ f)'(x)=\exp(f(x))\cdot f'(x)}$

Proof

Let ${\displaystyle g=\exp :\mathbb {R} \to \mathbb {R} }$ , which is differentiable with ${\displaystyle \exp '=\exp }$. Since ${\displaystyle f:D\to \mathbb {R} }$ is differentiable by assumption, we also get differentiability of ${\displaystyle \exp \circ f:D\to \mathbb {R} }$. By the chain rule,

${\displaystyle (\exp \circ f)'(x)=(g\circ f)'(x)=g'(f(x))\cdot f'(x)=\exp(f(x))\cdot f'(x)}$

Example (Deriving exponential functions)

1. Let ${\displaystyle h:\mathbb {R} \to \mathbb {R} ,\ h(x)=\exp(x^{2})}$ with ${\displaystyle f(x)=x^{2}}$. Then, ${\displaystyle f'(x)=2x}$ for all ${\displaystyle x\in \mathbb {R} }$ and we have

${\displaystyle h'(x)=\exp(x^{2})\cdot 2x=2x\exp(x^{2})}$

2. Let ${\displaystyle h:\mathbb {R} \to \mathbb {R} ,\ h(x)=\exp(\sin(x))}$ with ${\displaystyle f(x)=\sin(x)}$. Then, ${\displaystyle f'(x)=\cos }$ for all ${\displaystyle x\in \mathbb {R} }$ and we have

${\displaystyle h'(x)=\exp(\sin(x))\cdot \cos(x)=\cos(x)\exp(\sin(x))}$

### Special case: Differentiating "function to the power of a function"

Consider the function

${\displaystyle f_{1}^{f_{2}}=\exp \circ (f_{2}\cdot (\ln \circ f_{1}))}$

which is a special case of an exponential function. The inner function is ${\displaystyle f=f_{2}\cdot (\ln \circ f_{1})}$. We may again just use the chain rule.

Example (Deriving exponential functions 2)

1. Let ${\displaystyle h:(0,\infty )\to \mathbb {R} ,\ h(x)=x^{a}=\exp(a\ln(x))}$ with ${\displaystyle f(x)=a\ln(x)}$. Then, ${\displaystyle f'(x)=a\cdot {\tfrac {1}{x}}={\tfrac {a}{x}}}$ for all ${\displaystyle x\in (0,\infty )}$ and by the chain rule

${\displaystyle h'(x)=\exp(a\ln(x)))\cdot {\frac {a}{x}}=ax^{a-1}}$

2. Let ${\displaystyle h:(0,\infty )\to \mathbb {R} ,\ h(x)=a^{x}=\exp(x\ln(a))}$ with ${\displaystyle f(x)=x\ln(a)}$. Then, ${\displaystyle f'(x)=\ln(a)}$ for all ${\displaystyle x\in (0,\infty )}$ and by the chain rule

${\displaystyle h'(x)=\exp(x\ln(a))\cdot \ln(a)=\ln(a)a^{x}}$

3. Let ${\displaystyle h:(0,\infty )\to \mathbb {R} ,\ h(x)=x^{x}=\exp(x\ln(x))}$ with ${\displaystyle f(x)=x\ln(x)}$. Then, ${\displaystyle f'(x)=1\cdot \ln(x)+x\cdot {\tfrac {1}{x}}=\ln(x)+1}$ for all ${\displaystyle x\in (0,\infty )}$ and by the chain rule

${\displaystyle h'(x)=\exp(x\ln(x))\cdot (\ln(x)+1)=x^{x}(\ln(x)+1)}$

### Case: ${\displaystyle g=\ln }$

Let ${\displaystyle f:D\to \mathbb {R} \setminus \{0\}}$ be and by the chain rule. Then, ${\displaystyle \ln \circ |f|:D\to \mathbb {R} }$ is and by the chain rule as well and for all ${\displaystyle x\in D}$ there is

${\displaystyle (\ln \circ |f|)'(x)={\frac {f'(x)}{f(x)}}}$ (logarithmic derivative)

Proof

Let ${\displaystyle g:\mathbb {R} \setminus \{0\}\to \mathbb {R} ,\ g(x)=\ln(|x|)}$ , which is and by the chain rule with ${\displaystyle g'(x)={\tfrac {1}{x}}}$ for all ${\displaystyle x\in \mathbb {R} \setminus \{0\}}$. Since ${\displaystyle f:D\to \mathbb {R} \setminus \{0\}}$ is and by the chain rule by assumption, the chain rule implies differentiability of ${\displaystyle \ln \circ |f|:D\to \mathbb {R} }$ and

${\displaystyle (\ln \circ |f|)'(x)=g'(f(x))\cdot f'(x)={\frac {1}{f(x)}}\cdot f'(x)={\frac {f'(x)}{f(x)}}}$

Example (Logarithmic derivatives)

1. Let ${\displaystyle h:\mathbb {R} \setminus \{{\tfrac {\pi }{2}}+k\pi \mid k\in \mathbb {Z} \}\to \mathbb {R} ,\ h(x)=\ln(|\cos(x)|)}$ with ${\displaystyle f(x)=\cos(x)}$. Then, ${\displaystyle f'(x)=-\sin(x)}$ for all ${\displaystyle x\in \mathbb {R} \setminus \{{\tfrac {\pi }{2}}+k\pi \mid k\in \mathbb {Z} \}}$ and by the chain rule

${\displaystyle h'(x)={\frac {-\sin(x)}{\cos(x)}}=-\tan(x)}$

2. Let ${\displaystyle h:(1,\infty )\to \mathbb {R} ,\ h(x)=\ln(\ln(x))}$ with ${\displaystyle f(x)=\ln(x)}$. Then, ${\displaystyle f'(x)=\cos }$ for all ${\displaystyle x\in (1,\infty )}$ and by the chain rule

${\displaystyle h'(x)={\frac {\frac {1}{x}}{\ln(x)}}={\frac {1}{x\ln(x)}}}$

Questions for understanding: Answer the questions:

1. Why is the domain of ${\displaystyle h}$ only ${\displaystyle (1,\infty )}$?
2. What of domain of ${\displaystyle {\tilde {h}}:D\to \mathbb {R} ,\ {\tilde {h}}(x)=\ln(\ln |x|)}$?

Solutions:

1. There is ${\displaystyle x>1\iff \ln(x)>0\iff \ln(\ln(x))}$ is well-defined
2. There is ${\displaystyle x>1\vee x<-1\iff |x|>1\iff \ln(|x|)>0\iff \ln(\ln |x|)}$ is well-defined. So ${\displaystyle D=(-\infty ,-1)\cup (1,\infty )}$. For the derivative of ${\displaystyle {\tilde {h}}}$ there is
${\displaystyle {\tilde {h}}'(x)={\frac {1}{\ln |x|}}\cdot {\frac {1}{x}}={\frac {1}{x\ln |x|}}}$

Hint

Below we will see how we can use the logarithmic derivative to calculate easily the derivatives of product, quotient or power functions. This makes sense especially if the function consists of several products, for example. (${\displaystyle f=f_{1}\cdot f_{2}\cdot \ldots f_{k}}$)

## Linear combinations of functions

The factor and sum rule state that the derivative is linear. If we apply this linearity to ${\displaystyle n}$ functions, we get:

Theorem (Differentiating linear combinations of functions)

Let ${\displaystyle n\in \mathbb {N} _{0}}$, ${\displaystyle f_{0},\ldots f_{n}:D\to \mathbb {R} }$ be differentiable and ${\displaystyle a_{0},\ldots ,a_{n}\in \mathbb {R} }$. Then,

${\displaystyle a_{0}f_{0}+a_{1}f_{1}+\ldots +a_{n}f_{n}=\sum _{k=0}^{n}a_{k}f_{k}:D\to \mathbb {R} }$

is differentiable as well and for all ${\displaystyle x\in D}$ there is

${\displaystyle \left(\sum _{k=0}^{n}a_{k}f_{k}\right)'(x)=\sum _{k=0}^{n}a_{k}f_{k}'(x)}$

Proof (Differentiating linear combinations of functions)

We show the assertion by induction over ${\displaystyle n}$:

Induction base: ${\displaystyle n=0}$. For ${\displaystyle x\in D}$ there is

${\displaystyle \left(\sum _{k=0}^{0}a_{k}f_{k}\right)'(x)=(a_{0}f_{0})'(x){\underset {\text{rule}}{\overset {\text{factor-}}{=}}}a_{0}f_{0}'(x)=\sum _{k=0}^{0}a_{k}f_{k}'(x)}$

Induction assumption:

${\displaystyle \left(\sum _{k=0}^{n}a_{k}f_{k}\right)'(x)=\sum _{k=0}^{n}a_{k}f_{k}'(x)}$ shall hold for some ${\displaystyle n\in \mathbb {N} _{0}}$

Induction step: ${\displaystyle n\to n+1}$.

${\displaystyle \left(\sum _{k=0}^{n+1}a_{k}f_{k}\right)'(x){\underset {\text{rule}}{\overset {\text{factor}}{=}}}\left(\sum _{k=0}^{n}a_{k}f_{k}\right)'(x)+(a_{n+1}f_{n+1})'(x)={\underset {\text{factor rule}}{\overset {\text{induction assumption}}{=}}}\sum _{k=0}^{n}a_{k}f_{k}'(x)+a_{n+1}f_{n+1}'(x)=\sum _{k=0}^{n+1}a_{k}f_{k}'(x)}$

Example (Differentiability of polynomial functions)

The power function ${\displaystyle f_{k}:\mathbb {R} \to \mathbb {R} ,\ f_{k}(x)=x^{k}}$ is differentiable for all ${\displaystyle k\in \mathbb {N} _{0}}$ where

${\displaystyle f_{k}'(x)=kx^{k-1}}$

The theorem from above applied to polynomial functions yields

${\displaystyle p:\mathbb {R} \to \mathbb {R} ,\ k(x)=\sum _{k=0}^{n}a_{k}x^{k}}$

for ${\displaystyle n\in \mathbb {N} _{0}}$ and ${\displaystyle a_{1},\ldots ,a_{n}\in \mathbb {R} }$ differentiable with

${\displaystyle p'(x)=\sum _{k=0}^{n}a_{k}kx^{k-1}=\sum _{k=1}^{n}a_{k}kx^{k-1}}$

## Application: Deriving sum formulas

We can use the linearity of the derivative to obtain new sum formulas from already known ones. Let us consider as an example the geometric sum formula (missing) for ${\displaystyle x\in \mathbb {R} \setminus \{1\}}$ and ${\displaystyle n\in \mathbb {N} }$:

${\displaystyle \sum _{k=0}^{n}x^{k}={\frac {1-x^{n+1}}{1-x}}}$

Both sides of the equation can be understood as differentiable functions ${\displaystyle \mathbb {R} \setminus \{1\}}$ or ${\displaystyle f}$ or ${\displaystyle g}$:

{\displaystyle {\begin{aligned}f:\mathbb {R} \setminus \{0\}\to \mathbb {R} ,\ f(x)&=\sum _{k=0}^{n}x^{k}\\g:\mathbb {R} \setminus \{0\}\to \mathbb {R} ,\ g(x)&={\frac {1-x^{n+1}}{1-x}}\end{aligned}}}

Since ${\displaystyle f}$ is a polynomial, we have for ${\displaystyle x\in \mathbb {R} \setminus \{1\}}$:

${\displaystyle f'(x)=\sum _{k=1}^{n}kx^{k-1}}$

Furthermore, by the quotient rule

${\displaystyle g'(x)={\frac {-(n+1)x^{n}(1-x)-(1-x^{n+1})(-1)}{(1-x)^{2}}}={\frac {-(n+1)x^{n}+(n+1)x^{n+1}+1-x^{n+1}}{(1-x)^{2}}}={\frac {1-(n+1)x^{n}+nx^{n+1}}{(1-x)^{2}}}}$

Since now ${\displaystyle f\equiv g}$, we also have ${\displaystyle f'\equiv g'}$. So for ${\displaystyle x\in \mathbb {R} \setminus \{1\}}$ there is:

${\displaystyle \sum _{k=1}^{n}kx^{k-1}={\frac {1-(n+1)x^{n}+nx^{n+1}}{(1-x)^{2}}}}$

Additional question: Which sum formulas do we get for ${\displaystyle x=2}$ and ${\displaystyle x=-1}$?

For ${\displaystyle n=2}$ we get

${\displaystyle \sum _{k=1}^{n}k2^{k-1}={\frac {1-(n+1)2^{n}+n2^{n+1}}{(1-2)^{2}}}={\frac {1-(n+1)2^{n}+2n2^{n}}{(-1)^{2}}}=1+(n-1)2^{n}}$

and for ${\displaystyle n=-1}$

${\displaystyle \sum _{k=1}^{n}(-1)^{k-1}k={\frac {1-(n+1)(-1)^{n}+n(-1)^{n+1}}{(1+1)^{2}}}={\frac {1-(n+1)(-1)^{n}-n(-1)^{n}}{4}}={\tfrac {1}{4}}(1-(-1)^{n}(2n+1))={\begin{cases}-{\tfrac {n}{2}}&{\text{ for even }}n\\{\tfrac {n+1}{2}}&{\text{ for odd }}n\end{cases}}}$

## Generalized product rule

The product rule ${\displaystyle (f_{1}f_{2})'=f_{1}'f_{2}+f_{1}f_{2}'}$ can also be applied to more than two differentiable functions by first combining several functions and then applying the product rule several times in succession. For three functions we get

{\displaystyle {\begin{aligned}(f_{1}f_{2}f_{3})'&=((f_{1}f_{2})f_{3})'\\&{\underset {\text{rule}}{\overset {\text{product}}{=}}}(f_{1}f_{2})'f_{3}+(f_{1}f_{2})f_{3}'\\&{\underset {\text{rule}}{\overset {\text{product}}{=}}}(f_{1}'f_{2}+f_{1}f_{2}')f_{3}+(f_{1}f_{2})f_{3}'\\&=f_{1}'f_{2}f_{3}+f_{1}f_{2}'f_{3}+f_{1}f_{2}f_{3}'\end{aligned}}}

For four functions we get analogously

{\displaystyle {\begin{aligned}(f_{1}f_{2}f_{3}f_{4})'&=((f_{1}f_{2})(f_{3}f_{4}))'\\&{\underset {\text{rule}}{\overset {\text{product}}{=}}}(f_{1}f_{2})'(f_{3}f_{4})+(f_{1}f_{2})(f_{3}f_{4})'\\&{\underset {\text{rule}}{\overset {\text{product}}{=}}}(f_{1}'f_{2}+f_{1}f_{2}')(f_{3}f_{4})+(f_{1}f_{2})(f_{3}'f_{4}+f_{3}f_{4}')\\&=f_{1}'f_{2}f_{3}f_{4}+f_{1}f_{2}'f_{3}f_{4}+f_{1}f_{2}f_{3}'f_{4}+f_{1}f_{2}f_{3}f_{4}'\end{aligned}}}

We now recognize a clear formation law for derivatives: the product of the functions is added up, whereby in each summand the derivative "moves forward" by one position. In general, the derivative of a product function of ${\displaystyle n}$ functions is:

Theorem (Generalized product rule)

Let ${\displaystyle n\in \mathbb {N} }$ and let ${\displaystyle f_{1},f_{2},\ldots ,f_{n}:D\to \mathbb {R} }$ be differentiable. The the product function ${\displaystyle f_{1}f_{2}\cdot \ldots \cdot f_{n}:D\to \mathbb {R} }$ is also differentiable with

${\displaystyle (f_{1}f_{2}\cdot \ldots \cdot f_{n})'=\sum _{k=1}^{n}(f_{1}\cdot \ldots \cdot f_{k}'\cdot \ldots \cdot f_{n})}$

Exercise (Proof of the generalized product rule)

Prove the generalized product rule by induction over ${\displaystyle n}$.

Proof (Proof of the generalized product rule)

Induction base: ${\displaystyle n=1}$. Es gilt

${\displaystyle f_{1}'=\sum _{k=1}^{1}f_{k}'}$

Induction assumption:

${\displaystyle (f_{1}f_{2}\cdot \ldots \cdot f_{n})'=\sum _{k=1}^{n}(f_{1}\cdot \ldots \cdot f_{k}'\cdot \ldots \cdot f_{n})}$ is assumed for some ${\displaystyle n\in \mathbb {N} _{0}}$

Induction step: ${\displaystyle n\to n+1}$.

{\displaystyle {\begin{aligned}(f_{1}f_{2}\cdot \ldots \cdot f_{n}\cdot f_{n+1})'&=((f_{1}f_{2}\cdot \ldots \cdot f_{n})\cdot f_{n+1})'\\&={\underset {\text{rule}}{\overset {\text{product}}{=}}}(f_{1}f_{2}\cdot \ldots \cdot f_{n})'\cdot f_{n+1}+(f_{1}f_{2}\cdot \ldots \cdot f_{n})\cdot f_{n+1}'\\&={\underset {\text{assumption}}{\overset {\text{induction}}{=}}}\left(\sum _{k=1}^{n}(f_{1}\cdot \ldots \cdot f_{k}'\cdot \ldots \cdot f_{n})\right)\cdot f_{n+1}+(f_{1}f_{2}\cdot \ldots \cdot f_{n})\cdot f_{n+1}'\\&=\sum _{k=1}^{n}(f_{1}\cdot \ldots \cdot f_{k}'\cdot \ldots \cdot f_{n}\cdot f_{n+1})+(f_{1}f_{2}\cdot \ldots \cdot f_{n})\cdot f_{n+1}'\\&=\sum _{k=1}^{n+1}(f_{1}\cdot \ldots \cdot f_{k}'\cdot \ldots \cdot f_{n}\cdot f_{n+1})\end{aligned}}}

Example (Generalized product rule)

The function

${\displaystyle f:\mathbb {R} ^{+}\to \mathbb {R} ,\ f(x)=x\exp(x)\ln(x)}$

is differentiable, since ${\displaystyle f_{1}(x)=x}$, ${\displaystyle f_{2}(x)=\exp(x)}$ and ${\displaystyle f_{3}(x)=\ln(x)}$ are differentiable for all ${\displaystyle x\in \mathbb {R} ^{+}}$ . In addition

${\displaystyle f_{1}'(x)=1}$, ${\displaystyle f_{2}'(x)=\exp(x)}$ and ${\displaystyle f_{3}'(x)={\frac {1}{x}}}$

The generalized product rule yields for ${\displaystyle x\in \mathbb {R} ^{+}}$:

{\displaystyle {\begin{aligned}f'(x)&=1\cdot \exp(x)\ln(x)+x\exp(x)\ln(x)+x\exp(x)\cdot {\frac {1}{x}}\\&=\exp(x)\ln(x)+x\exp(x)\ln(x)+\exp(x)\\&=\exp(x)(\ln(x)+x\ln(x)+1)\end{aligned}}}

Exercise (Generalized product rule)

Determine the domain of definition and the derivative of

${\displaystyle f:D\to \mathbb {R} ,\ f(x)=\exp(-x)\sin(x)\cos(x)\tan(x)}$

Solution (Generalized product rule)

Domain of definition: The functions ${\displaystyle x\mapsto \exp(-x)}$, ${\displaystyle \sin }$ and ${\displaystyle \cos }$ are defined on all of ${\displaystyle \mathbb {R} }$. by contrast, ${\displaystyle \tan }$ is only defined on ${\displaystyle \mathbb {R} \setminus \{{\tfrac {\pi }{2}}+k\pi \mid k\in \mathbb {Z} \}}$. Hence

${\displaystyle D=\mathbb {R} \setminus \{{\tfrac {\pi }{2}}+k\pi \mid k\in \mathbb {Z} \}}$

Derivative: ${\displaystyle f}$ is differentiable, as the functions ${\displaystyle f_{1}:x\mapsto \exp(-x)}$, ${\displaystyle f_{2}=\sin }$, ${\displaystyle f_{3}=\cos }$ and ${\displaystyle f_{4}=\tan }$ are differentiable. In addition, for all ${\displaystyle x\in D}$ there is:

${\displaystyle f_{1}'(x)=-\exp(-x)}$, ${\displaystyle f_{2}(x)=\cos(x)}$, ${\displaystyle f_{3}(x)=-\sin(x)}$ and ${\displaystyle f_{4}'(x)={\frac {1}{\cos ^{2}(x)}}}$

The generalized product rule yields:

{\displaystyle {\begin{aligned}f'(x)&=-\exp(-x)\sin(x)\cos(x)\tan(x)+\exp(-x)\cos(x)\cos(x)\tan(x)+\exp(-x)\sin(x)(-\sin(x))\tan(x)+\exp(-x)\sin(x)\cos(x){\frac {1}{\cos ^{2}(x)}}\\&=-\exp(-x)\sin(x)\cos(x)\tan(x)+\exp(x)\cos ^{2}(x)\tan(x)-\exp(x)\sin ^{2}(x)\tan(x)+{\frac {\exp(x)\sin(x)}{\cos(x)}}\\&=\exp(-x)(-\sin(x)\cos(x)\tan(x)+\cos ^{2}(x)\tan(x)-\sin ^{2}(x)\tan(x)+\tan(x))\\&=\exp(-x)\tan(x)(-\sin(x)\cos(x)+\cos ^{2}(x)-\sin ^{2}(x)+1)\end{aligned}}}

Hint

If additionally ${\displaystyle f_{1}(x)\cdot f_{2}(x)\cdot \ldots \cdot f_{n}(x)\neq 0}$ for all ${\displaystyle x\in D}$, we can divide both sides by this product, and thus obtain the form

${\displaystyle {\frac {(f_{1}f_{2}\cdot \ldots \cdot f_{n})'}{f_{1}\cdot f_{2}\cdot \ldots \cdot f_{n}}}=\sum _{k=1}^{n}{\frac {f_{1}\cdot \ldots \cdot f_{k}'\cdot \ldots \cdot f_{n}}{f_{1}\cdot f_{2}\cdot \ldots \cdot f_{n}}}=\sum _{k=1}^{n}{\frac {f_{k}'}{f_{k}}}}$

The advantage of this representation is that the sum on the right side is much clearer. This is already the idea behind the logarithmic derivative, which we present in the next section.

## Logarithmic derivatives

The logarithmic derivative is a very elegant tool to calculate the derivative of some functions of a special form. For a differentiable function ${\displaystyle f}$ without zeros, the logarithmic derivative is defined by

${\displaystyle L(f)=(\ln \circ |f|)'}$

We have already shown above that the chain rule yields:

${\displaystyle L(f)={\frac {f'}{f}}}$

The following table lists some standard examples of logarithmic derivatives:

${\displaystyle f}$ ${\displaystyle \operatorname {L} (f)}$ Domain of definition
${\displaystyle c\in \mathbb {R} \setminus \{0\}}$ ${\displaystyle {\tfrac {0}{c}}=0}$ ${\displaystyle \mathbb {R} }$
${\displaystyle x^{n}}$, ${\displaystyle n\in \mathbb {N} }$ ${\displaystyle {\tfrac {nx^{n-1}}{x^{n}}}={\tfrac {n}{x}}}$ ${\displaystyle \mathbb {R} \setminus \{0\}}$
${\displaystyle \exp(x)}$ ${\displaystyle {\tfrac {\exp(x)}{\exp(x)}}=1}$ ${\displaystyle \mathbb {R} }$
${\displaystyle \ln(x)}$ ${\displaystyle {\tfrac {\tfrac {1}{x}}{\ln(x)}}={\tfrac {1}{x\ln(x)}}}$ ${\displaystyle \mathbb {R} ^{+}\setminus \{1\}}$
${\displaystyle \sin(x)}$ ${\displaystyle {\tfrac {\cos(x)}{\sin(x)}}=\cot(x)}$ ${\displaystyle \mathbb {R} \setminus \{k\pi \mid k\in \mathbb {Z} \}}$
${\displaystyle \cos(x)}$ ${\displaystyle {\tfrac {-\sin(x)}{\cos(x)}}=-\tan(x)}$ ${\displaystyle \mathbb {R} \setminus \{{\tfrac {\pi }{2}}+k\pi \mid k\in \mathbb {Z} \}}$
${\displaystyle \tan(x)}$ ${\displaystyle {\tfrac {\tfrac {1}{\cos ^{2}(x)}}{\tan(x)}}={\tfrac {1}{\sin(x)\cos(x)}}}$ ${\displaystyle \mathbb {R} \setminus \{k{\tfrac {\pi }{2}}\mid k\in \mathbb {Z} \}}$

Exercise (Computing logarithmic derivatives)

Determine the logarithmic derivative (with domain of definition) of the following functions

1. ${\displaystyle f(x)={\sqrt {x}}}$
2. ${\displaystyle g(x)=\cot(x)={\tfrac {\cos(x)}{\sin(x)}}}$
3. ${\displaystyle h(x)=x^{a}=\exp(a\ln(x))}$ with ${\displaystyle a\in \mathbb {R} }$

Solution (Computing logarithmic derivatives)

Part 1: There is ${\displaystyle f'(x)={\tfrac {1}{2{\sqrt {x}}}}}$ for all ${\displaystyle x\in \mathbb {R} ^{+}}$. So

${\displaystyle L(f)(x)={\frac {f'(x)}{f(x)}}={\frac {\frac {1}{2{\sqrt {x}}}}{\sqrt {x}}}={\frac {1}{2x}}}$

Since ${\displaystyle f(x)={\sqrt {x}}\neq 0}$ for all ${\displaystyle x\in \mathbb {R} ^{+}}$, the domain of definition for our logarithmic derivative of ${\displaystyle f}$ is equal to ${\displaystyle \mathbb {R} ^{+}}$.

Part 2: The quotient rule yields

${\displaystyle g'(x)={\tfrac {-\sin(x)\sin(x)-\cos(x)\cos(x)}{\sin ^{2}(x)}}=-{\tfrac {\sin ^{2}(x)+\cos ^{2}(x)}{\sin ^{2}(x)}}=-{\tfrac {1}{\sin ^{2}(x)}}}$ for all ${\displaystyle x\in \mathbb {R} \setminus \{k\pi \mid k\in \mathbb {Z} \}}$

So

${\displaystyle L(g)(x)={\frac {g'(x)}{g(x)}}={\frac {-{\frac {1}{\sin ^{2}(x)}}}{\frac {\cos(x)}{\sin(x)}}}=-{\frac {1}{\sin(x)\cos(x)}}}$

Since ${\displaystyle g(x)={\tfrac {\cos(x)}{\sin(x)}}\neq 0\iff x\neq {\tfrac {\pi }{2}}+k\pi \ (k\in \mathbb {Z} )}$ for all ${\displaystyle x\in \mathbb {R} \setminus \{k\pi \mid k\in \mathbb {Z} \}}$, the domain of definition for our logarithmic derivative of ${\displaystyle g}$ is equal to ${\displaystyle \mathbb {R} \setminus \{k{\tfrac {\pi }{2}}\mid k\in \mathbb {Z} \}}$.

Part 3: For ${\displaystyle x\in \mathbb {R} ^{+}}$ there is

${\displaystyle L(h)(x)=[\ln(|h(x)|)]'=[\ln(\exp(a\ln(x)))]'=(a\ln(x))'={\frac {a}{x}}}$

Since ${\displaystyle h(x)=\exp(a\ln(x))\neq 0}$ for all ${\displaystyle x\in \mathbb {R} ^{+}}$, the domain of definition for our logarithmic derivative of ${\displaystyle L(h)}$ is equal to ${\displaystyle \mathbb {R} ^{+}}$.

By direct computation we obtain the following rules for the logarithmic derivative:

Theorem (Computation rules for logarithmic derivatives)

For two differentiable functions ${\displaystyle f}$ and ${\displaystyle g}$ without zeros, there is

1. ${\displaystyle L(f\cdot g)=L(f)+L(g)}$
2. ${\displaystyle L({\tfrac {1}{f}})=-L(f)}$
3. ${\displaystyle L({\tfrac {f}{g}})=L(f)-L(g)}$
4. ${\displaystyle L(f^{n})=nL(f)}$ for ${\displaystyle n\in \mathbb {N} }$
5. ${\displaystyle L({\sqrt {f}})={\tfrac {1}{2}}L(f)}$ for ${\displaystyle f>0}$

Note: The rules are analogous to the computation rules for the logarithm function.

Proof (Computation rules for logarithmic derivatives)

We will only prove rule 1 and rule 4, the other three we leave to you "as an exercise" (don't worry, there is a solution, here).

Rule 1: Since ${\displaystyle f}$ and ${\displaystyle g}$ are differentiable and free of zeros, ${\displaystyle f\cdot g}$ is also differentiable and free of zeros. Thus the following applies

${\displaystyle L(fg)={\frac {(fg)'}{fg}}{\underset {\text{rule}}{\overset {\text{product}}{=}}}{\frac {f'g+fg'}{fg}}={\frac {f'g}{fg}}+{\frac {fg'}{fg}}={\frac {f'}{f}}+{\frac {g'}{g}}=L(f)+L(g)}$

Rule 4: Since ${\displaystyle f}$ is differentiable and zero-free, ${\displaystyle f^{n}}$ is also differentiable and zero-free for ${\displaystyle n\in \mathbb {N} }$. Further above we have already shown ${\displaystyle (f^{n})'=nf^{n-1}f'}$ by the chain rule. So

${\displaystyle L(f^{n})={\frac {(f^{n})'}{f^{n}}}={\frac {nf^{n-1}f'}{f^{n}}}=n{\frac {f'}{f}}=nL(f)}$

Exercise (Computation rules for logarithmic derivatives)

Prove rules 2, 3 and 5 of the previous theorem

Proof (Computation rules for logarithmic derivatives)

Rule 2: Since ${\displaystyle f}$ are differentiable and zero-free, ${\displaystyle {\frac {1}{f}}}$ is also differentiable and zero-free. By the chain rule, ${\displaystyle ({\tfrac {1}{f}})'=-{\tfrac {1}{f^{2}}}\cdot f'=-{\tfrac {f'}{f^{2}}}}$. Thus, there is

${\displaystyle L({\tfrac {1}{f}})={\frac {({\tfrac {1}{f}})'}{\tfrac {1}{f}}}={\frac {-{\tfrac {f'}{f^{2}}}}{\tfrac {1}{f}}}=-{\frac {f'f}{f^{2}}}=-{\frac {f'}{f}}=-L(f)}$

Rule 3: Since ${\displaystyle f}$ and ${\displaystyle g}$ are differentiable and zero-free, ${\displaystyle {\tfrac {f}{g}}}$ is also differentiable and zero-free. Using rules 1 and 2 we get

${\displaystyle L({\tfrac {f}{g}})=L(f\cdot {\tfrac {1}{g}}){\overset {\text{Rule 1}}{=}}L(f)+L({\tfrac {1}{g}}){\overset {\text{Rule 2}}{=}}L(f)-L(g)}$

Alternatively, the rule can be proved by using the quotient rule.

Rule 5: Since ${\displaystyle f}$ are differentiable and positive, ${\displaystyle {\sqrt {f}}}$ is also differentiable and positive. With the chain rule, ${\displaystyle ({\sqrt {f}})'={\tfrac {1}{2{\sqrt {f}}}}\cdot f'={\tfrac {f'}{2{\sqrt {f}}}}}$ applies. Thus,

${\displaystyle L({\sqrt {f}})={\frac {({\sqrt {f}})'}{\sqrt {f}}}={\frac {\tfrac {f'}{2{\sqrt {f}}}}{\sqrt {f}}}={\frac {f'}{2{\sqrt {f}}{\sqrt {f}}}}={\frac {f'}{2f}}={\frac {1}{2}}L(f)}$

Hint

The summation rule can still be generalized to zero-free and differentiable ${\displaystyle f_{1},\ldots ,f_{n}}$ (${\displaystyle n\in \mathbb {N} )}$ as

${\displaystyle L(f_{1}\cdot \ldots \cdot f_{n})=L(f_{1})+\ldots +L(f_{n})\iff {\frac {(f_{1}\cdot \ldots \cdot f_{n})'}{f_{1}\cdot \ldots \cdot f_{n}}}={\frac {f_{1}'}{f_{1}}}+\ldots +{\frac {f_{n}'}{f_{n}}}}$

Using those rules, we can now easily calculate derivatives. The transition to logarithmic derivatives does not usually require less computational effort, but it is much clearer than calculating with the usual rules, and therefore less susceptible to errors!

Example (Logarithmic derivatives 1)

First we differentiate the following product function by means of the logarithmic derivation

${\displaystyle f(x)=xe^{x}\cos(x)}$

First we determine the domain of definition: there is ${\displaystyle f_{1}(x)=x}$, ${\displaystyle f_{2}(x)=e^{x}}$ and ${\displaystyle f_{3}(x)=\cos(x)}$. In order to be able to form the logarithmic derivative, ${\displaystyle f_{1},f_{2}}$ and ${\displaystyle f_{3}}$ must be zero-free. Because of ${\displaystyle f_{3}}$ we will choose ${\displaystyle D=\mathbb {R} \setminus \{{\tfrac {\pi }{2}}+k\pi \mid k\in \mathbb {Z} \}}$.

Now take the logarithmic derivative of ${\displaystyle f}$: There is

${\displaystyle \underbrace {L(f(x))} _{\frac {f'(x)}{f(x)}}=L(f_{1}\cdot f_{2}\cdot f_{3}){\underset {\text{rule}}{\overset {\text{product}}{=}}}L(f_{1}(x))+L(f_{2}(x))+L(f_{3}(x))={\frac {f_{1}'(x)}{f_{1}(x)}}+{\frac {f_{2}'(x)}{f_{2}(x)}}+{\frac {f_{3}'(x)}{f_{3}(x)}}={\frac {1}{x}}+{\frac {e^{x}}{e^{x}}}+{\frac {-\sin(x)}{\cos(x)}}={\frac {1}{x}}+1-{\frac {\sin(x)}{\cos(x)}}}$

Finally, we multiply the equation by ${\displaystyle f(x)=xe^{x}\cos(x)}$ and obtain

${\displaystyle f'(x)={\frac {1}{x}}\cdot f(x)+1\cdot f(x)-{\frac {\sin(x)}{\cos(x)}}\cdot f(x)=e^{x}\cos(x)+xe^{x}\cos(x)-xe^{x}\sin(x)=e^{x}(\cos(x)+x\cos(x)-x\sin(x))}$

Example (Logarithmic derivatives 2)

Next, we differentiate the following quotient function:

${\displaystyle {\tilde {f}}(x)={\frac {(x-1)^{2}}{x^{2}+1}}}$

Concerning the domain: The denominator is always different from zero. In order for ${\displaystyle {\tilde {f}}}$ to be free of zeros, the numerator must be unequal to zero. Therefore:

${\displaystyle (x-1)^{2}\neq 0\iff x\neq 1}$

Hence, the domain of definition is ${\displaystyle D=\mathbb {R} \setminus \{1\}}$.

With ${\displaystyle f(x)=(x-1)^{2}}$ and ${\displaystyle g(x)=x^{2}+1}$ we have for the logarithmic derivative of ${\displaystyle {\tilde {f}}}$:

${\displaystyle \underbrace {L({\tilde {f}}(x))} _{\frac {{\tilde {f}}'(x)}{{\tilde {f}}(x)}}=L({\tfrac {f(x)}{g(x)}}){\underset {\text{rule}}{\overset {\text{quotient}}{=}}}L(f(x))-L(g(x))={\frac {f'(x)}{f(x)}}-{\frac {g'(x)}{g(x)}}={\frac {2(x-1)}{(x-1)^{2}}}-{\frac {2x}{x^{2}+1}}={\frac {2}{x-1}}-{\frac {2x}{x^{2}+1}}}$

Multiplication by ${\displaystyle {\tilde {f}}(x)={\frac {(x-1)^{2}}{x^{2}+1}}}$ yields:

{\displaystyle {\begin{aligned}{\tilde {f}}'(x)&={\frac {2}{x-1}}\cdot {\tilde {f}}(x)-{\frac {2x}{x^{2}+1}}\cdot {\tilde {f}}(x)={\frac {2(x-1)}{x^{2}+1}}-{\frac {2x(x-1)^{2}}{(x^{2}+1)}}={\frac {2(x-1)(x^{2}+1)-2x(x-1)^{2}}{(x^{2}+1)^{2}}}\\&={\frac {2(x-1)[(x^{2}+1)-x(x-1)]}{(x^{2}+1)^{2}}}={\frac {2(x-1)[x+1]}{(x^{2}+1)^{2}}}={\frac {2(x^{2}-1)}{(x^{2}+1)^{2}}}\end{aligned}}}

Example (Logarithmic derivatives 3)

Finally, we differentiate with the logarithmic derivative

${\displaystyle {\hat {f}}(x)=x^{\tfrac {1}{x}}=\exp({\tfrac {1}{x}}\ln(x))=\exp({\tfrac {\ln(x)}{x}})}$

Concerning the domain: In order for ${\displaystyle {\hat {f}}}$ to be defined, ${\displaystyle x>0}$ must hold. The function ${\displaystyle {\hat {f}}}$ is zero-free on all of ${\displaystyle \mathbb {R} ^{+}}$. So ${\displaystyle D=\mathbb {R} ^{+}}$.

The logarithmic derivative of ${\displaystyle {\hat {f}}}$ is

${\displaystyle \underbrace {L({\hat {f}}(x))} _{={\frac {{\hat {f}}'(x)}{{\hat {f}}(x)}}}=[\ln(f(x))]'=[\ln(\exp({\tfrac {\ln(x)}{x}}))]'=[{\tfrac {\ln(x)}{x}}]'={\frac {{\tfrac {1}{x}}\cdot x-\ln(x)\cdot 1}{x^{2}}}={\frac {1-\ln(x)}{x^{2}}}}$

Multiplication by ${\displaystyle {\hat {f}}(x)=x^{\tfrac {1}{x}}}$ yields:

${\displaystyle {\hat {f}}'(x)=x^{\tfrac {1}{x}}({\tfrac {1-\ln(x)}{x^{2}}})=x^{{\tfrac {1}{x}}-2}(1-\ln(x))}$

Exercise (Logarithmic derivatives)

Using the logarithmic derivatives, differentiate the following functions on their domain of definition:

1. ${\displaystyle f(x)=\sin(x)\cos(x)\tan(x)}$
2. ${\displaystyle g(x)={\frac {\sqrt {x-1}}{(x+1)^{2}}}}$
3. ${\displaystyle h(x)=x^{\sqrt {x}}}$

## Generalized chain rule

Just like the sum and product rule, the chain rule can be generalized to the composition of more than two functions. For two differentiable functions ${\displaystyle f_{1}}$ and ${\displaystyle f_{2}}$ the chain rule reads

${\displaystyle (f_{1}\circ f_{2})'(x)=(f_{1}'(f_{2}(x))\cdot f_{2}'(x)}$

If we have three functions ${\displaystyle f_{1}}$, ${\displaystyle f_{2}}$ and ${\displaystyle f_{3}}$, then by applying the rule twice we obtain

${\displaystyle (f_{1}\circ f_{2}\circ f_{3})'(x)=(\underbrace {(f_{1}\circ f_{2})} _{=h}\circ f_{3})'(x)=\underbrace {(f_{1}\circ f_{2})'(f_{3}(x))} _{=h'(f_{3}(x))}\cdot f_{3}'(x)=f_{1}'(f_{2}(f_{3}(x)))\cdot f_{2}'(f_{3}(x))\cdot f_{3}'(x)}$

If we now take a closer look, we can see a law of formation: First the outermost function is differentiated and the two inner ones are inserted into the derivative function. Then the second function is differentiated and the innermost function is inserted, and the whole thing is multiplied by the first derivative. Finally, the innermost function is differentiated and multiplied. If we now generalize this to ${\displaystyle n}$ functions, we get:

Theorem (Generalized chain rule)

Let ${\displaystyle f_{i}:D_{i}\to \mathbb {R} }$ be differentiable for all ${\displaystyle i\in \{1,\ldots ,n\}}$, and ${\displaystyle f_{i+1}(D_{i+1})\subseteq D_{i}}$ for all ${\displaystyle i\in \{0,\ldots ,n-1\}}$. Then ${\displaystyle f_{1}\circ f_{2}\circ \ldots \circ f_{n}:D_{1}\to \mathbb {R} }$ is also differentiable, and its derivative at ${\displaystyle x\in D_{1}}$ is given by

${\displaystyle (f_{1}\circ f_{2}\circ \ldots \circ f_{n})'(x)=f_{1}'(f_{2}(\ldots f_{n-1}(f_{n}(x))\ldots ))\cdot f_{2}'(f_{3}(\ldots f_{n-1}(f_{n}(x))\ldots ))\cdot \ldots \cdot f_{n-1}'(f_{n}(x))\cdot f_{n}'(x)}$

Proof (Generalized chain rule)

We prove the theorem by induction over ${\displaystyle n}$:

Induction base: ${\displaystyle n=1}$. There is

${\displaystyle f_{1}'=f_{1}'}$

${\displaystyle n=2}$. The chain rule yields

${\displaystyle (f_{1}\circ f_{2})'(x)=f_{1}'(f_{2}(x))\cdot f_{2}'(x)}$

Induction assumption:

${\displaystyle (f_{1}\circ f_{2}\circ \ldots \circ f_{n})'(x)=f_{1}'(f_{2}(\ldots f_{n-1}(f_{n}(x))\ldots ))\cdot f_{2}'(f_{3}(\ldots f_{n-1}(f_{n}(x))\ldots ))\cdot \ldots \cdot f_{n-1}'(f_{n}(x))\cdot f_{n}'(x)}$ is assumed for all ${\displaystyle x\in D_{1}}$ and some ${\displaystyle n\in \mathbb {N} }$

Induction step: ${\displaystyle n\to n+1}$. For ${\displaystyle x\in D_{1}}$ there is

{\displaystyle {\begin{aligned}(f_{1}\circ f_{2}\circ \ldots \circ f_{n}\circ f_{n+1})'(x)&=(\underbrace {(f_{1}\circ f_{2}\circ \ldots \circ f_{n})} _{=h}\circ f_{n+1})'(x)\\&={\underset {\text{rule}}{\overset {\text{chain}}{=}}}\underbrace {(f_{1}\circ f_{2}\circ \ldots \circ f_{n})'(\overbrace {f_{n+1}(x)} ^{\tilde {x}})} _{=h'({\tilde {x}})}\cdot f_{n+1}'(x)\\&={\underset {\text{assumption}}{\overset {\text{induction}}{=}}}f_{1}'(f_{2}(\ldots f_{n-1}(f_{n}(\overbrace {f_{n+1}(x)} ^{={\tilde {x}}}))\ldots ))\cdot f_{2}'(f_{3}(\ldots f_{n-1}(f_{n}(\overbrace {f_{n+1}(x)} ^{={\tilde {x}}}))\ldots ))\cdot \ldots \cdot f_{n}'(\overbrace {f_{n+1}(x)} ^{={\tilde {x}}})\cdot f_{n+1}'(x)\end{aligned}}}