Zum Inhalt springen

Computing derivatives - special

Aus Wikibooks

Special cases of the chain rule

[Bearbeiten]

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↦xn etc. we refer to the following chapter Examples for derivatives (missing).

Case: f is linear

[Bearbeiten]

Let a,b∈ℝ and let g:ℝ→ℝ be differentiable. Then also h:ℝ→ℝ, h(x)=g(ax+b) is differentiable ad at x∈ℝ there is

h′(x)=ag′(ax+b)

Proof

f:ℝ→ℝ, f(x)=ax+b is differentiable with f′(x)=a for all x∈ℝ. The chain rule implies differentiablilty of h=g∘f:ℝ→ℝ , where

h′(x)=g′(f(x))⋅f′(x)=g′(ax+b)⋅a=ag′(ax+b)

Example

Let h:ℝ→ℝ, h(x)=(2x+1)2 with g(x)=x2. Then g′(x)=2x for all x∈ℝ so

h′(x)=2(2x+1)⋅2=4(2x+1)

Case: g is a power function

[Bearbeiten]

Let f:D→ℝ be differentiable. The also fn:D→ℝ is differentiable for all n∈ℕ, where at x∈D there is

(fn)′(x)=nfn−1(x)⋅f′(x)

Proof

g:ℝ→ℝ, g(x)=xn is differentiable with g′(x)=nxn−1 for all x∈ℝ. The chain rule implies differentiablility of fn:D→ℝ, where

(fn)′(x)=g′(f(x))⋅f′(x)=nfn−1(x)⋅f′(x)=nf(x)fn−1(x)

Example (Deriving a power function)

Let h:ℝ→ℝ, h(x)=sin2(x)=(sin⁡(x))2 with f(x)=sin⁡(x). Then f′(x)=cos⁡(x) and for allx∈ℝ we have

h′(x)=2sin⁡(x)2−1cos⁡(x)=2sin⁡(x)cos⁡(x)

Case: g is a root function

[Bearbeiten]

Let f:D→ℝ+ be differentiable. then f:D→ℝ+ with x↦f(x) is differentiable as well and for all x∈D there is

(f)′(x)=f′(x)2f(x)

Proof

g:ℝ+→ℝ, g(x)=x is differentiable with g′(x)=12x for all x∈ℝ+. The chain rule implies differentiability of f:D→ℝ+ where

(f)′(x)=(g∘f)′(x)=g′(f(x))⋅f′(x)=12f(x)⋅f′(x)=f′(x)2f(x)

Example (Deriving a root function)

Let h:ℝ→ℝ, h(x)=exp⁡(x) with f(x)=exp⁡(x). Then f′(x)=exp⁡(x) and for all x∈ℝ there is

h′(x)=exp⁡(x)2exp⁡(x)=exp⁡(x)2

Case: g=exp

[Bearbeiten]

Let f:D→ℝ be differentiable. Then exp⁡∘f:D→ℝ is differentiable as well and for all x∈D there is

(exp⁡∘f)′(x)=exp⁡(f(x))⋅f′(x)

Proof

Let g=exp⁡:ℝ→ℝ , which is differentiable with exp′⁡=exp. Since f:D→ℝ is differentiable by assumption, we also get differentiability of exp⁡∘f:D→ℝ. By the chain rule,

(exp⁡∘f)′(x)=(g∘f)′(x)=g′(f(x))⋅f′(x)=exp⁡(f(x))⋅f′(x)

Example (Deriving exponential functions)

1. Let h:ℝ→ℝ, h(x)=exp⁡(x2) with f(x)=x2. Then, f′(x)=2x for all x∈ℝ and we have

h′(x)=exp⁡(x2)⋅2x=2xexp⁡(x2)

2. Let h:ℝ→ℝ, h(x)=exp⁡(sin⁡(x)) with f(x)=sin⁡(x). Then, f′(x)=cos for all x∈ℝ and we have

h′(x)=exp⁡(sin⁡(x))⋅cos⁡(x)=cos⁡(x)exp⁡(sin⁡(x))

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

[Bearbeiten]

Consider the function

f1f2=exp⁡∘(f2⋅(ln⁡∘f1))

which is a special case of an exponential function. The inner function is f=f2⋅(ln⁡∘f1). We may again just use the chain rule.

Example (Deriving exponential functions 2)

1. Let h:(0,∞)→ℝ, h(x)=xa=exp⁡(aln⁡(x)) with f(x)=aln⁡(x). Then, f′(x)=a⋅1x=ax for all x∈(0,∞) and by the chain rule

h′(x)=exp⁡(aln⁡(x)))⋅ax=axa−1

2. Let h:(0,∞)→ℝ, h(x)=ax=exp⁡(xln⁡(a)) with f(x)=xln⁡(a). Then, f′(x)=ln⁡(a) for all x∈(0,∞) and by the chain rule

h′(x)=exp⁡(xln⁡(a))⋅ln⁡(a)=ln⁡(a)ax

3. Let h:(0,∞)→ℝ, h(x)=xx=exp⁡(xln⁡(x)) with f(x)=xln⁡(x). Then, f′(x)=1⋅ln⁡(x)+x⋅1x=ln⁡(x)+1 for all x∈(0,∞) and by the chain rule

h′(x)=exp⁡(xln⁡(x))⋅(ln⁡(x)+1)=xx(ln⁡(x)+1)

Case: g=ln

[Bearbeiten]

Let f:D→ℝ∖{0} be and by the chain rule. Then, ln⁡∘|f|:D→ℝ is and by the chain rule as well and for all x∈D there is

(ln⁡∘|f|)′(x)=f′(x)f(x) (logarithmic derivative)

Proof

Let g:ℝ∖{0}→ℝ, g(x)=ln⁡(|x|) , which is and by the chain rule with g′(x)=1x for all x∈ℝ∖{0}. Since f:D→ℝ∖{0} is and by the chain rule by assumption, the chain rule implies differentiability of ln⁡∘|f|:D→ℝ and

(ln⁡∘|f|)′(x)=g′(f(x))⋅f′(x)=1f(x)⋅f′(x)=f′(x)f(x)

Example (Logarithmic derivatives)

1. Let h:ℝ∖{π2+kπ∣k∈ℤ}→ℝ, h(x)=ln⁡(|cos⁡(x)|) with f(x)=cos⁡(x). Then, f′(x)=−sin⁡(x) for all x∈ℝ∖{π2+kπ∣k∈ℤ} and by the chain rule

h′(x)=−sin⁡(x)cos⁡(x)=−tan⁡(x)

2. Let h:(1,∞)→ℝ, h(x)=ln⁡(ln⁡(x)) with f(x)=ln⁡(x). Then, f′(x)=cos for all x∈(1,∞) and by the chain rule

h′(x)=1xln⁡(x)=1xln⁡(x)

Questions for understanding: Answer the questions:

  1. Why is the domain of h only (1,∞)?
  2. What of domain of h~:D→ℝ, h~(x)=ln⁡(ln⁡|x|)?

Solutions:

  1. There is x>1⟺ln⁡(x)>0⟺ln⁡(ln⁡(x)) is well-defined
  2. There is x>1∨x<−1⟺|x|>1⟺ln⁡(|x|)>0⟺ln⁡(ln⁡|x|) is well-defined. So D=(−∞,−1)∪(1,∞). For the derivative of h~ there is
h~′(x)=1ln⁡|x|⋅1x=1xln⁡|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=f1⋅f2⋅…fk)

Linear combinations of functions

[Bearbeiten]

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∈ℕ0, f0,…fn:D→ℝ be differentiable and a0,…,an∈ℝ. Then,

a0f0+a1f1+…+anfn=∑k=0nakfk:D→ℝ

is differentiable as well and for all x∈D there is

(∑k=0nakfk)′(x)=∑k=0nakfk′(x)

Proof (Differentiating linear combinations of functions)

We show the assertion by induction over n:

Induction base: n=0. For x∈D there is

(∑k=00akfk)′(x)=(a0f0)′(x)=factor-rulea0f0′(x)=∑k=00akfk′(x)

Induction assumption:

(∑k=0nakfk)′(x)=∑k=0nakfk′(x) shall hold for some n∈ℕ0

Induction step: n→n+1.

(∑k=0n+1akfk)′(x)=factorrule(∑k=0nakfk)′(x)+(an+1fn+1)′(x)==induction assumptionfactor rule∑k=0nakfk′(x)+an+1fn′+1(x)=∑k=0n+1akfk′(x)

Example (Differentiability of polynomial functions)

The power function fk:ℝ→ℝ, fk(x)=xk is differentiable for all k∈ℕ0 where

fk′(x)=kxk−1

The theorem from above applied to polynomial functions yields

p:ℝ→ℝ, k(x)=∑k=0nakxk

for n∈ℕ0 and a1,…,an∈ℝ differentiable with

p′(x)=∑k=0nakkxk−1=∑k=1nakkxk−1

Application: Deriving sum formulas

[Bearbeiten]

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∈ℝ∖{1} and n∈ℕ:

∑k=0nxk=1−xn+11−x

Both sides of the equation can be understood as differentiable functions ℝ∖{1} or f or g:

f:ℝ∖{0}→ℝ, f(x)=∑k=0nxkg:ℝ∖{0}→ℝ, g(x)=1−xn+11−x

Since f is a polynomial, we have for x∈ℝ∖{1}:

f′(x)=∑k=1nkxk−1

Furthermore, by the quotient rule

g′(x)=−(n+1)xn(1−x)−(1−xn+1)(−1)(1−x)2=−(n+1)xn+(n+1)xn+1+1−xn+1(1−x)2=1−(n+1)xn+nxn+1(1−x)2

Since now f≡g, we also have f′≡g′. So for x∈ℝ∖{1} there is:

∑k=1nkxk−1=1−(n+1)xn+nxn+1(1−x)2

Additional question: Which sum formulas do we get for x=2 and x=−1?

For n=2 we get

∑k=1nk2k−1=1−(n+1)2n+n2n+1(1−2)2=1−(n+1)2n+2n2n(−1)2=1+(n−1)2n

and for n=−1

∑k=1n(−1)k−1k=1−(n+1)(−1)n+n(−1)n+1(1+1)2=1−(n+1)(−1)n−n(−1)n4=14(1−(−1)n(2n+1))={−n2 for even nn+12 for odd n

Generalized product rule

[Bearbeiten]

The product rule (f1f2)′=f1′f2+f1f2′ 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

(f1f2f3)′=((f1f2)f3)′=productrule(f1f2)′f3+(f1f2)f3′=productrule(f1′f2+f1f2′)f3+(f1f2)f3′=f1′f2f3+f1f2′f3+f1f2f3′

For four functions we get analogously

(f1f2f3f4)′=((f1f2)(f3f4))′=productrule(f1f2)′(f3f4)+(f1f2)(f3f4)′=productrule(f1′f2+f1f2′)(f3f4)+(f1f2)(f3′f4+f3f4′)=f1′f2f3f4+f1f2′f3f4+f1f2f3′f4+f1f2f3f4′

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∈ℕ and let f1,f2,…,fn:D→ℝ be differentiable. The the product function f1f2⋅…⋅fn:D→ℝ is also differentiable with

(f1f2⋅…⋅fn)′=∑k=1n(f1⋅…⋅fk′⋅…⋅fn)

Exercise (Proof of the generalized product rule)

Prove the generalized product rule by induction over n.

Proof (Proof of the generalized product rule)

Induction base: n=1. Es gilt

f1′=∑k=11fk′

Induction assumption:

(f1f2⋅…⋅fn)′=∑k=1n(f1⋅…⋅fk′⋅…⋅fn) is assumed for some n∈ℕ0

Induction step: n→n+1.

(f1f2⋅…⋅fn⋅fn+1)′=((f1f2⋅…⋅fn)⋅fn+1)′==productrule(f1f2⋅…⋅fn)′⋅fn+1+(f1f2⋅…⋅fn)⋅fn′+1==inductionassumption(∑k=1n(f1⋅…⋅fk′⋅…⋅fn))⋅fn+1+(f1f2⋅…⋅fn)⋅fn′+1=∑k=1n(f1⋅…⋅fk′⋅…⋅fn⋅fn+1)+(f1f2⋅…⋅fn)⋅fn′+1=∑k=1n+1(f1⋅…⋅fk′⋅…⋅fn⋅fn+1)

Example (Generalized product rule)

The function

f:ℝ+→ℝ, f(x)=xexp⁡(x)ln⁡(x)

is differentiable, since f1(x)=x, f2(x)=exp⁡(x) and f3(x)=ln⁡(x) are differentiable for all x∈ℝ+ . In addition

f1′(x)=1, f2′(x)=exp⁡(x) and f3′(x)=1x

The generalized product rule yields for x∈ℝ+:

f′(x)=1⋅exp⁡(x)ln⁡(x)+xexp⁡(x)ln⁡(x)+xexp⁡(x)⋅1x=exp⁡(x)ln⁡(x)+xexp⁡(x)ln⁡(x)+exp⁡(x)=exp⁡(x)(ln⁡(x)+xln⁡(x)+1)

Exercise (Generalized product rule)

Determine the domain of definition and the derivative of

f:D→ℝ, f(x)=exp⁡(−x)sin⁡(x)cos⁡(x)tan⁡(x)

Solution (Generalized product rule)

Domain of definition: The functions x↦exp⁡(−x), sin and cos are defined on all of ℝ. by contrast, tan is only defined on ℝ∖{π2+kπ∣k∈ℤ}. Hence

D=ℝ∖{π2+kπ∣k∈ℤ}

Derivative: f is differentiable, as the functions f1:x↦exp⁡(−x), f2=sin, f3=cos and f4=tan are differentiable. In addition, for all x∈D there is:

f1′(x)=−exp⁡(−x), f2(x)=cos⁡(x), f3(x)=−sin⁡(x) and f4′(x)=1cos2(x)

The generalized product rule yields:

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)1cos2(x)=−exp⁡(−x)sin⁡(x)cos⁡(x)tan⁡(x)+exp⁡(x)cos2(x)tan⁡(x)−exp⁡(x)sin2(x)tan⁡(x)+exp⁡(x)sin⁡(x)cos⁡(x)=exp⁡(−x)(−sin⁡(x)cos⁡(x)tan⁡(x)+cos2(x)tan⁡(x)−sin2(x)tan⁡(x)+tan⁡(x))=exp⁡(−x)tan⁡(x)(−sin⁡(x)cos⁡(x)+cos2(x)−sin2(x)+1)

Hint

If additionally f1(x)⋅f2(x)⋅…⋅fn(x)≠0 for all x∈D, we can divide both sides by this product, and thus obtain the form

(f1f2⋅…⋅fn)′f1⋅f2⋅…⋅fn=∑k=1nf1⋅…⋅fk′⋅…⋅fnf1⋅f2⋅…⋅fn=∑k=1nfk′fk

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

[Bearbeiten]

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⁡∘|f|)′

We have already shown above that the chain rule yields:

L(f)=f′f

The following table lists some standard examples of logarithmic derivatives:

f L⁡(f) Domain of definition
c∈ℝ∖{0} 0c=0 ℝ
xn, n∈ℕ nxn−1xn=nx ℝ∖{0}
exp⁡(x) exp⁡(x)exp⁡(x)=1 ℝ
ln⁡(x) 1xln⁡(x)=1xln⁡(x) ℝ+∖{1}
sin⁡(x) cos⁡(x)sin⁡(x)=cot⁡(x) ℝ∖{kπ∣k∈ℤ}
cos⁡(x) −sin⁡(x)cos⁡(x)=−tan⁡(x) ℝ∖{π2+kπ∣k∈ℤ}
tan⁡(x) 1cos2(x)tan⁡(x)=1sin⁡(x)cos⁡(x) ℝ∖{kπ2∣k∈ℤ}

Exercise (Computing logarithmic derivatives)

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

  1. f(x)=x
  2. g(x)=cot⁡(x)=cos⁡(x)sin⁡(x)
  3. h(x)=xa=exp⁡(aln⁡(x)) with a∈ℝ

Solution (Computing logarithmic derivatives)

Part 1: There is f′(x)=12x for all x∈ℝ+. So

L(f)(x)=f′(x)f(x)=12xx=12x

Since f(x)=x≠0 for all x∈ℝ+, the domain of definition for our logarithmic derivative of f is equal to ℝ+.

Part 2: The quotient rule yields

g′(x)=−sin⁡(x)sin⁡(x)−cos⁡(x)cos⁡(x)sin2(x)=−sin2(x)+cos2(x)sin2(x)=−1sin2(x) for all x∈ℝ∖{kπ∣k∈ℤ}

So

L(g)(x)=g′(x)g(x)=−1sin2(x)cos⁡(x)sin⁡(x)=−1sin⁡(x)cos⁡(x)

Since g(x)=cos⁡(x)sin⁡(x)≠0⟺x≠π2+kπ (k∈ℤ) for all x∈ℝ∖{kπ∣k∈ℤ}, the domain of definition for our logarithmic derivative of g is equal to ℝ∖{kπ2∣k∈ℤ}.

Part 3: For x∈ℝ+ there is

L(h)(x)=[ln⁡(|h(x)|)]′=[ln⁡(exp⁡(aln⁡(x)))]′=(aln⁡(x))′=ax

Since h(x)=exp⁡(aln⁡(x))≠0 for all x∈ℝ+, the domain of definition for our logarithmic derivative of L(h) is equal to ℝ+.

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

  1. L(f⋅g)=L(f)+L(g)
  2. L(1f)=−L(f)
  3. L(fg)=L(f)−L(g)
  4. L(fn)=nL(f) for n∈ℕ
  5. L(f)=12L(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⋅g is also differentiable and free of zeros. Thus the following applies

L(fg)=(fg)′fg=productrulef′g+fg′fg=f′gfg+fg′fg=f′f+g′g=L(f)+L(g)

Rule 4: Since f is differentiable and zero-free, fn is also differentiable and zero-free for n∈ℕ. Further above we have already shown (fn)′=nfn−1f′ by the chain rule. So

L(fn)=(fn)′fn=nfn−1f′fn=nf′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 f are differentiable and zero-free, 1f is also differentiable and zero-free. By the chain rule, (1f)′=−1f2⋅f′=−f′f2. Thus, there is

L(1f)=(1f)′1f=−f′f21f=−f′ff2=−f′f=−L(f)

Rule 3: Since f and g are differentiable and zero-free, fg is also differentiable and zero-free. Using rules 1 and 2 we get

L(fg)=L(f⋅1g)=Rule 1L(f)+L(1g)=Rule 2L(f)−L(g)

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

Rule 5: Since f are differentiable and positive, f is also differentiable and positive. With the chain rule, (f)′=12f⋅f′=f′2f applies. Thus,

L(f)=(f)′f=f′2ff=f′2ff=f′2f=12L(f)

Hint

The summation rule can still be generalized to zero-free and differentiable f1,…,fn (n∈ℕ) as

L(f1⋅…⋅fn)=L(f1)+…+L(fn)⟺(f1⋅…⋅fn)′f1⋅…⋅fn=f1′f1+…+fn′fn

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)=xexcos⁡(x)

First we determine the domain of definition: there is f1(x)=x, f2(x)=ex and f3(x)=cos⁡(x). In order to be able to form the logarithmic derivative, f1,f2 and f3 must be zero-free. Because of f3 we will choose D=ℝ∖{π2+kπ∣k∈ℤ}.


Now take the logarithmic derivative of f: There is

L(f(x))⏟f′(x)f(x)=L(f1⋅f2⋅f3)=productruleL(f1(x))+L(f2(x))+L(f3(x))=f1′(x)f1(x)+f2′(x)f2(x)+f3′(x)f3(x)=1x+exex+−sin⁡(x)cos⁡(x)=1x+1−sin⁡(x)cos⁡(x)

Finally, we multiply the equation by f(x)=xexcos⁡(x) and obtain

f′(x)=1x⋅f(x)+1⋅f(x)−sin⁡(x)cos⁡(x)⋅f(x)=excos⁡(x)+xexcos⁡(x)−xexsin⁡(x)=ex(cos⁡(x)+xcos⁡(x)−xsin⁡(x))

Example (Logarithmic derivatives 2)

Next, we differentiate the following quotient function:

f~(x)=(x−1)2x2+1

Concerning the domain: The denominator is always different from zero. In order for f~ to be free of zeros, the numerator must be unequal to zero. Therefore:

(x−1)2≠0⟺x≠1

Hence, the domain of definition is D=ℝ∖{1}.

With f(x)=(x−1)2 and g(x)=x2+1 we have for the logarithmic derivative of f~:

L(f~(x))⏟f~′(x)f~(x)=L(f(x)g(x))=quotientruleL(f(x))−L(g(x))=f′(x)f(x)−g′(x)g(x)=2(x−1)(x−1)2−2xx2+1=2x−1−2xx2+1

Multiplication by f~(x)=(x−1)2x2+1 yields:

f~′(x)=2x−1⋅f~(x)−2xx2+1⋅f~(x)=2(x−1)x2+1−2x(x−1)2(x2+1)=2(x−1)(x2+1)−2x(x−1)2(x2+1)2=2(x−1)[(x2+1)−x(x−1)](x2+1)2=2(x−1)[x+1](x2+1)2=2(x2−1)(x2+1)2

Example (Logarithmic derivatives 3)

Finally, we differentiate with the logarithmic derivative

f̂(x)=x1x=exp⁡(1xln⁡(x))=exp⁡(ln⁡(x)x)

Concerning the domain: In order for f̂ to be defined, x>0 must hold. The function f̂ is zero-free on all of ℝ+. So D=ℝ+.

The logarithmic derivative of f̂ is

L(f̂(x))⏟=f̂′(x)f̂(x)=[ln⁡(f(x))]′=[ln⁡(exp⁡(ln⁡(x)x))]′=[ln⁡(x)x]′=1x⋅x−ln⁡(x)⋅1x2=1−ln⁡(x)x2

Multiplication by f̂(x)=x1x yields:

f̂′(x)=x1x(1−ln⁡(x)x2)=x1x−2(1−ln⁡(x))

Exercise (Logarithmic derivatives)

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

  1. f(x)=sin⁡(x)cos⁡(x)tan⁡(x)
  2. g(x)=x−1(x+1)2
  3. h(x)=xx

Generalized chain rule

[Bearbeiten]

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 f1 and f2 the chain rule reads

(f1∘f2)′(x)=(f1′(f2(x))⋅f2′(x)

If we have three functions f1, f2 and f3, then by applying the rule twice we obtain

(f1∘f2∘f3)′(x)=((f1∘f2)⏟=h∘f3)′(x)=(f1∘f2)′(f3(x))⏟=h′(f3(x))⋅f3′(x)=f1′(f2(f3(x)))⋅f2′(f3(x))⋅f3′(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 fi:Di→ℝ be differentiable for all i∈{1,…,n}, and fi+1(Di+1)⊆Di for all i∈{0,…,n−1}. Then f1∘f2∘…∘fn:D1→ℝ is also differentiable, and its derivative at x∈D1 is given by

(f1∘f2∘…∘fn)′(x)=f1′(f2(…fn−1(fn(x))…))⋅f2′(f3(…fn−1(fn(x))…))⋅…⋅fn′−1(fn(x))⋅fn′(x)

Proof (Generalized chain rule)

We prove the theorem by induction over n:

Induction base: n=1. There is

f1′=f1′

n=2. The chain rule yields

(f1∘f2)′(x)=f1′(f2(x))⋅f2′(x)

Induction assumption:

(f1∘f2∘…∘fn)′(x)=f1′(f2(…fn−1(fn(x))…))⋅f2′(f3(…fn−1(fn(x))…))⋅…⋅fn′−1(fn(x))⋅fn′(x) is assumed for all x∈D1 and some n∈ℕ

Induction step: n→n+1. For x∈D1 there is

(f1∘f2∘…∘fn∘fn+1)′(x)=((f1∘f2∘…∘fn)⏟=h∘fn+1)′(x)==chainrule(f1∘f2∘…∘fn)′(fn+1(x)⏞x~)⏟=h′(x~)⋅fn′+1(x)==inductionassumptionf1′(f2(…fn−1(fn(fn+1(x)⏞=x~))…))⋅f2′(f3(…fn−1(fn(fn+1(x)⏞=x~))…))⋅…⋅fn′(fn+1(x)⏞=x~)⋅fn′+1(x)