The theorem for the derivative of a composition of two given functions can be applied iteratively to obtain the derivative of a composition of multiple functions.
For example, for the composition of three f, g and h

x\stackrel{h}\longmapsto h(x)\stackrel{g}\longmapsto g(h(x)) \stackrel{f}\longmapsto f(g(h(x))),


denoted by f\circ g\circ h, the following formula holds true

[(f\circ g\circ h)]'(x)=f'(g(h(x)))\cdot g'(h(x))\cdot h'(x).


Let’s see an example of how this rule works.

Example

Let’s compute the derivative of this function

y=\ln(1+\cos(x^2)).


Let’s highlight the ingredients with the composition chain

x\stackrel{h}\longmapsto x^2\stackrel{g}\longmapsto 1+\cos(x^2) \stackrel{f}\longmapsto \ln(1+\cos(x^2))


We see that the innermost function, h, takes x to x^2, the second function g is 1+\cos(\cdot), and finally the outer function f computes the natural logarithm of its input. The derivative is then obtained by multiplying three derivatives in this way:


  • the derivative of h at x:

    h'(x)=2x,


  • the derivative of g at h(x)=x^2:

    g'(h(x))=-\sin(h(x))=-\sin(x^2),



  • and finally the derivative of f calculated at g(h(x))=1+\cos(x^2):

    f'(g(h(x)))=\frac{1}{g(h(x))}=\frac{1}{1+\cos(x^2)}.


The result is therefore this

y'=\frac{1}{1+\cos(x^2)}\cdot -\sin(x^2)\cdot 2x,


or

y'=-\frac{2x\sin(x^2)}{1+\cos(x^2)}.