# Math for Non-Geeks/ Computing derivatives - special
## 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 $\exp$, $\ln$, $\sin$, $\cos$, $x\mapsto x^{n}$ etc. we refer to the following chapter Examples for derivatives (missing).

### Case: $f$ is linear

Let $a,b\in \mathbb {R}$ and let $g:\mathbb {R} \to \mathbb {R}$ be differentiable. Then also $h:\mathbb {R} \to \mathbb {R} ,\ h(x)=g(ax+b)$ is differentiable ad at $x\in \mathbb {R}$ there is
$h'(x)=ag'(ax+b)$
Proof
$f:\mathbb {R} \to \mathbb {R} ,\ f(x)=ax+b$ is differentiable with $f'(x)=a$ for all $x\in \mathbb {R}$. The chain rule implies differentiablilty of $h=g\circ f:\mathbb {R} \to \mathbb {R}$ , where $h'(x)=g'(f(x))\cdot f'(x)=g'(ax+b)\cdot a=ag'(ax+b)$
Example
Let $h:\mathbb {R} \to \mathbb {R} ,\ h(x)=(2x+1)^{2}$ with $g(x)=x^{2}$. Then $g'(x)=2x$ for all $x\in \mathbb {R}$ so
$h'(x)=2(2x+1)\cdot 2=4(2x+1)$

### Case: $g$ is a power function

Let $f:D\to \mathbb {R}$ be differentiable. The also $f^{n}:D\to \mathbb {R}$ is differentiable for all $n\in \mathbb {N}$, where at $x\in D$ there is
$(f^{n})'(x)=nf^{n-1}(x)\cdot f'(x)$
Proof
$g:\mathbb {R} \to \mathbb {R} ,\ g(x)=x^{n}$ is differentiable with $g'(x)=nx^{n-1}$ for all $x\in \mathbb {R}$. The chain rule implies differentiablility of $f^{n}:D\to \mathbb {R}$, where $(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 $h:\mathbb {R} \to \mathbb {R} ,\ h(x)=\sin ^{2}(x)=(\sin(x))^{2}$ with $f(x)=\sin(x)$. Then $f'(x)=\cos(x)$ and for all$x\in \mathbb {R}$ we have
$h'(x)=2\sin(x)^{2-1}\cos(x)=2\sin(x)\cos(x)$

### Case: $g$ is a root function

Let $f:D\to \mathbb {R} ^{+}$ be differentiable. then ${\sqrt {f}}:D\to \mathbb {R} ^{+}$ with $x\mapsto {\sqrt {f(x)}}$ is differentiable as well and for all $x\in D$ there is
$({\sqrt {f}})'(x)={\frac {f'(x)}{2{\sqrt {f(x)}}}}$
Proof
$g:\mathbb {R} ^{+}\to \mathbb {R} ,\ g(x)={\sqrt {x}}$ is differentiable with $g'(x)={\tfrac {1}{2{\sqrt {x}}}}$ for all $x\in \mathbb {R} ^{+}$. The chain rule implies differentiability of ${\sqrt {f}}:D\to \mathbb {R} ^{+}$ where $({\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 $h:\mathbb {R} \to \mathbb {R} ,\ h(x)={\sqrt {\exp(x)}}$ with $f(x)=\exp(x)$. Then $f'(x)=\exp(x)$ and for all $x\in \mathbb {R}$ there is
$h'(x)={\frac {\exp(x)}{2{\sqrt {\exp(x)}}}}={\frac {\sqrt {\exp(x)}}{2}}$

### Case: $g=\exp$

Let $f:D\to \mathbb {R}$ be differentiable. Then $\exp \circ f:D\to \mathbb {R}$ is differentiable as well and for all $x\in D$ there is
$(\exp \circ f)'(x)=\exp(f(x))\cdot f'(x)$
Proof
Let $g=\exp :\mathbb {R} \to \mathbb {R}$ , which is differentiable with $\exp '=\exp$. Since $f:D\to \mathbb {R}$ is differentiable by assumption, we also get differentiability of $\exp \circ f:D\to \mathbb {R}$. By the chain rule,
$(\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 $h:\mathbb {R} \to \mathbb {R} ,\ h(x)=\exp(x^{2})$ with $f(x)=x^{2}$. Then, $f'(x)=2x$ for all $x\in \mathbb {R}$ and we have
$h'(x)=\exp(x^{2})\cdot 2x=2x\exp(x^{2})$
2. Let $h:\mathbb {R} \to \mathbb {R} ,\ h(x)=\exp(\sin(x))$ with $f(x)=\sin(x)$. Then, $f'(x)=\cos$ for all $x\in \mathbb {R}$ and we have
$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
$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 $f=f_{2}\cdot (\ln \circ f_{1})$. We may again just use the chain rule.
Example (Deriving exponential functions 2)
1. Let $h:(0,\infty )\to \mathbb {R} ,\ h(x)=x^{a}=\exp(a\ln(x))$ with $f(x)=a\ln(x)$. Then, $f'(x)=a\cdot {\tfrac {1}{x}}={\tfrac {a}{x}}$ for all $x\in (0,\infty )$ and by the chain rule
$h'(x)=\exp(a\ln(x)))\cdot {\frac {a}{x}}=ax^{a-1}$
2. Let $h:(0,\infty )\to \mathbb {R} ,\ h(x)=a^{x}=\exp(x\ln(a))$ with $f(x)=x\ln(a)$. Then, $f'(x)=\ln(a)$ for all $x\in (0,\infty )$ and by the chain rule
$h'(x)=\exp(x\ln(a))\cdot \ln(a)=\ln(a)a^{x}$
3. Let $h:(0,\infty )\to \mathbb {R} ,\ h(x)=x^{x}=\exp(x\ln(x))$ with $f(x)=x\ln(x)$. Then, $f'(x)=1\cdot \ln(x)+x\cdot {\tfrac {1}{x}}=\ln(x)+1$ for all $x\in (0,\infty )$ and by the chain rule
$h'(x)=\exp(x\ln(x))\cdot (\ln(x)+1)=x^{x}(\ln(x)+1)$

### Case: $g=\ln$

Let $f:D\to \mathbb {R} \setminus \{0\}$ be and by the chain rule. Then, $\ln \circ |f|:D\to \mathbb {R}$ is and by the chain rule as well and for all $x\in D$ there is
$(\ln \circ |f|)'(x)={\frac {f'(x)}{f(x)}}$ (logarithmic derivative)
Proof
Let $g:\mathbb {R} \setminus \{0\}\to \mathbb {R} ,\ g(x)=\ln(|x|)$ , which is and by the chain rule with $g'(x)={\tfrac {1}{x}}$ for all $x\in \mathbb {R} \setminus \{0\}$. Since $f:D\to \mathbb {R} \setminus \{0\}$ is and by the chain rule by assumption, the chain rule implies differentiability of $\ln \circ |f|:D\to \mathbb {R}$ and $(\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 $h:\mathbb {R} \setminus \{{\tfrac {\pi }{2}}+k\pi \mid k\in \mathbb {Z} \}\to \mathbb {R} ,\ h(x)=\ln(|\cos(x)|)$ with $f(x)=\cos(x)$. Then, $f'(x)=-\sin(x)$ for all $x\in \mathbb {R} \setminus \{{\tfrac {\pi }{2}}+k\pi \mid k\in \mathbb {Z} \}$ and by the chain rule
$h'(x)={\frac {-\sin(x)}{\cos(x)}}=-\tan(x)$
2. Let $h:(1,\infty )\to \mathbb {R} ,\ h(x)=\ln(\ln(x))$ with $f(x)=\ln(x)$. Then, $f'(x)=\cos$ for all $x\in (1,\infty )$ and by the chain rule
$h'(x)={\frac {\frac {1}{x}}{\ln(x)}}={\frac {1}{x\ln(x)}}$
Questions for understanding: Answer the questions:
* Why is the domain of $h$ only $(1,\infty )$?
* What of domain of ${\tilde {h}}:D\to \mathbb {R} ,\ {\tilde {h}}(x)=\ln(\ln |x|)$?
Solutions:
* There is $x>1\iff \ln(x)>0\iff \ln(\ln(x))$ is well-defined
* There is $x>1\vee x<-1\iff |x|>1\iff \ln(|x|)>0\iff \ln(\ln |x|)$ is well-defined. So $D=(-\infty ,-1)\cup (1,\infty )$. For the derivative of ${\tilde {h}}$ there is
${\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. ($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 $n$ functions, we get:
Theorem (Differentiating linear combinations of functions)
Let $n\in \mathbb {N} _{0}$, $f_{0},\ldots f_{n}:D\to \mathbb {R}$ be differentiable and $a_{0},\ldots ,a_{n}\in \mathbb {R}$. Then,
$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 $x\in D$ there is
$\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 $n$:
Induction base: $n=0$. For $x\in D$ there is
$\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:
$\left(\sum _{k=0}^{n}a_{k}f_{k}\right)'(x)=\sum _{k=0}^{n}a_{k}f_{k}'(x)$ shall hold for some $n\in \mathbb {N} _{0}$
Induction step: $n\to n+1$.
$\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 $f_{k}:\mathbb {R} \to \mathbb {R} ,\ f_{k}(x)=x^{k}$ is differentiable for all $k\in \mathbb {N} _{0}$ where
$f_{k}'(x)=kx^{k-1}$
The theorem from above applied to polynomial functions yields
$p:\mathbb {R} \to \mathbb {R} ,\ k(x)=\sum _{k=0}^{n}a_{k}x^{k}$
for $n\in \mathbb {N} _{0}$ and $a_{1},\ldots ,a_{n}\in \mathbb {R}$ differentiable with
$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 $x\in \mathbb {R} \setminus \{1\}$ and $n\in \mathbb {N}$:
$\sum _{k=0}^{n}x^{k}={\frac {1-x^{n+1}}{1-x}}$
Both sides of the equation can be understood as differentiable functions $\mathbb {R} \setminus \{1\}$ or $f$ or $g$:
${\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 $f$ is a polynomial, we have for $x\in \mathbb {R} \setminus \{1\}$:
$f'(x)=\sum _{k=1}^{n}kx^{k-1}$
Furthermore, by the quotient rule
$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 $f\equiv g$, we also have $f'\equiv g'$. So for $x\in \mathbb {R} \setminus \{1\}$ there is:
$\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 $x=2$ and $x=-1$?
For $n=2$ we get
$\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 $n=-1$
$\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 $(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
${\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
${\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 $n$ functions is:
Theorem (Generalized product rule)
Let $n\in \mathbb {N}$ and let $f_{1},f_{2},\ldots ,f_{n}:D\to \mathbb {R}$ be differentiable. The the product function $f_{1}f_{2}\cdot \ldots \cdot f_{n}:D\to \mathbb {R}$ is also differentiable with
$(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})$
Math for Non-Geeks: Template:Aufgabe
Example (Generalized product rule)
The function
$f:\mathbb {R} ^{+}\to \mathbb {R} ,\ f(x)=x\exp(x)\ln(x)$
is differentiable, since $f_{1}(x)=x$, $f_{2}(x)=\exp(x)$ and $f_{3}(x)=\ln(x)$ are differentiable for all $x\in \mathbb {R} ^{+}$ . In addition
$f_{1}'(x)=1$, $f_{2}'(x)=\exp(x)$ and $f_{3}'(x)={\frac {1}{x}}$
The generalized product rule yields for $x\in \mathbb {R} ^{+}$:
${\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}}$
Math for Non-Geeks: Template:Aufgabe
Hint
If additionally $f_{1}(x)\cdot f_{2}(x)\cdot \ldots \cdot f_{n}(x)\neq 0$ for all $x\in D$, we can divide both sides by this product, and thus obtain the form
${\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 $f$ without zeros, the logarithmic derivative is defined by
$L(f)=(\ln \circ |f|)'$
We have already shown above that the chain rule yields:
$L(f)={\frac {f'}{f}}$
The following table lists some standard examples of logarithmic derivatives:
| $f$ | $\operatorname {L} (f)$ | Domain of definition |
| $c\in \mathbb {R} \setminus \{0\}$ | ${\tfrac {0}{c}}=0$ | $\mathbb {R}$ |
| $x^{n}$, $n\in \mathbb {N}$ | ${\tfrac {nx^{n-1}}{x^{n}}}={\tfrac {n}{x}}$ | $\mathbb {R} \setminus \{0\}$ |
| $\exp(x)$ | ${\tfrac {\exp(x)}{\exp(x)}}=1$ | $\mathbb {R}$ |
| $\ln(x)$ | ${\tfrac {\tfrac {1}{x}}{\ln(x)}}={\tfrac {1}{x\ln(x)}}$ | $\mathbb {R} ^{+}\setminus \{1\}$ |
| $\sin(x)$ | ${\tfrac {\cos(x)}{\sin(x)}}=\cot(x)$ | $\mathbb {R} \setminus \{k\pi \mid k\in \mathbb {Z} \}$ |
| $\cos(x)$ | ${\tfrac {-\sin(x)}{\cos(x)}}=-\tan(x)$ | $\mathbb {R} \setminus \{{\tfrac {\pi }{2}}+k\pi \mid k\in \mathbb {Z} \}$ |
| $\tan(x)$ | ${\tfrac {\tfrac {1}{\cos ^{2}(x)}}{\tan(x)}}={\tfrac {1}{\sin(x)\cos(x)}}$ | $\mathbb {R} \setminus \{k{\tfrac {\pi }{2}}\mid k\in \mathbb {Z} \}$ |
Math for Non-Geeks: Template:Aufgabe
By direct computation we obtain the following rules for the logarithmic derivative:
Theorem (Computation rules for logarithmic derivatives)
For two differentiable functions $f$ and $g$ without zeros, there is
* $L(f\cdot g)=L(f)+L(g)$
* $L({\tfrac {1}{f}})=-L(f)$
* $L({\tfrac {f}{g}})=L(f)-L(g)$
* $L(f^{n})=nL(f)$ for $n\in \mathbb {N}$
* $L({\sqrt {f}})={\tfrac {1}{2}}L(f)$ for $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 $f$ and $g$ are differentiable and free of zeros, $f\cdot g$ is also differentiable and free of zeros. Thus the following applies
$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 $f$ is differentiable and zero-free, $f^{n}$ is also differentiable and zero-free for $n\in \mathbb {N}$. Further above we have already shown $(f^{n})'=nf^{n-1}f'$ by the chain rule. So
$L(f^{n})={\frac {(f^{n})'}{f^{n}}}={\frac {nf^{n-1}f'}{f^{n}}}=n{\frac {f'}{f}}=nL(f)$
Math for Non-Geeks: Template:Aufgabe
Hint
The summation rule can still be generalized to zero-free and differentiable $f_{1},\ldots ,f_{n}$ ($n\in \mathbb {N} )$ as
$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
$f(x)=xe^{x}\cos(x)$
First we determine the domain of definition: there is $f_{1}(x)=x$, $f_{2}(x)=e^{x}$ and $f_{3}(x)=\cos(x)$. In order to be able to form the logarithmic derivative, $f_{1},f_{2}$ and $f_{3}$ must be zero-free. Because of $f_{3}$ we will choose $D=\mathbb {R} \setminus \{{\tfrac {\pi }{2}}+k\pi \mid k\in \mathbb {Z} \}$.
Now take the logarithmic derivative of $f$: There is
$\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 $f(x)=xe^{x}\cos(x)$ and obtain
$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:
${\tilde {f}}(x)={\frac {(x-1)^{2}}{x^{2}+1}}$
Concerning the domain: The denominator is always different from zero. In order for ${\tilde {f}}$ to be free of zeros, the numerator must be unequal to zero. Therefore:
$(x-1)^{2}\neq 0\iff x\neq 1$
Hence, the domain of definition is $D=\mathbb {R} \setminus \{1\}$.
With $f(x)=(x-1)^{2}$ and $g(x)=x^{2}+1$ we have for the logarithmic derivative of ${\tilde {f}}$:
$\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 ${\tilde {f}}(x)={\frac {(x-1)^{2}}{x^{2}+1}}$ yields:
${\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 ${\hat {f}}(x)=x^{\tfrac {1}{x}}=\exp({\tfrac {1}{x}}\ln(x))=\exp({\tfrac {\ln(x)}{x}})$
Concerning the domain: In order for ${\hat {f}}$ to be defined, $x>0$ must hold. The function ${\hat {f}}$ is zero-free on all of $\mathbb {R} ^{+}$. So $D=\mathbb {R} ^{+}$.
The logarithmic derivative of ${\hat {f}}$ is
$\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 ${\hat {f}}(x)=x^{\tfrac {1}{x}}$ yields:
${\hat {f}}'(x)=x^{\tfrac {1}{x}}({\tfrac {1-\ln(x)}{x^{2}}})=x^{{\tfrac {1}{x}}-2}(1-\ln(x))$
Math for Non-Geeks: Template:Aufgabe

## 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 $f_{1}$ and $f_{2}$ the chain rule reads
$(f_{1}\circ f_{2})'(x)=(f_{1}'(f_{2}(x))\cdot f_{2}'(x)$
If we have three functions $f_{1}$, $f_{2}$ and $f_{3}$, then by applying the rule twice we obtain
$(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 $n$ functions, we get:
Theorem (Generalized chain rule)
Let $f_{i}:D_{i}\to \mathbb {R}$ be differentiable for all $i\in \{1,\ldots ,n\}$, and $f_{i+1}(D_{i+1})\subseteq D_{i}$ for all $i\in \{0,\ldots ,n-1\}$. Then $f_{1}\circ f_{2}\circ \ldots \circ f_{n}:D_{1}\to \mathbb {R}$ is also differentiable, and its derivative at $x\in D_{1}$ is given by
$(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 $n$:
Induction base: $n=1$. There is
$f_{1}'=f_{1}'$
$n=2$. The chain rule yields
$(f_{1}\circ f_{2})'(x)=f_{1}'(f_{2}(x))\cdot f_{2}'(x)$
Induction assumption:
$(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 $x\in D_{1}$ and some $n\in \mathbb {N}$
Induction step: $n\to n+1$. For $x\in D_{1}$ there is
${\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}}$