Following Every Layer
A composite function can place one familiar function inside another. When several types of functions are nested, the derivative is built from several factors: one for each layer. The challenge is to identify those layers and keep their factors together.
For example, \(e^{\sin x}\) has a sine layer inside an exponential layer. The derivative of the outer exponential is not the whole answer: the derivative of the inner sine must also appear. Likewise, \(\sin(\ln x)\) has a logarithm inside a sine, so both derivative rules contribute.
The Derivative Rules Used Here
For a differentiable inner function \(u=u(x)\), the relevant chain-rule forms are:
Here \(u'\) means the derivative of the inner function with respect to \(x\). The exponential rule applies for every real-valued \(u\). The logarithm rule requires a positive argument at the point in question; a composition involving \(\ln u\) is defined only where \(u>0\).
These rules are useful to read as a sequence of layers. Differentiate the outer function while keeping its input in place, then multiply by the derivative of that input. If the input is itself a composition, repeat the process for its layers.
Why the Factors Multiply
Suppose an expression has three layers, \(y=f(g(h(x)))\), and each function is differentiable at the relevant input. A small change in \(x\) first changes \(h(x)\) at rate \(h'(x)\). That change affects \(g\) at rate \(g'(h(x))\), and the resulting change affects \(f\) at rate \(f'(g(h(x)))\). The chain rule expresses these successive local rates as a product:
Each factor records one layer's contribution. The order of the factors in a product can be rearranged, but their inputs cannot be changed: the derivative of \(g\) must be evaluated at \(h(x)\), and the derivative of \(f\) at \(g(h(x))\). The examples below make those inputs explicit.
Keep its input intact while differentiating that outer function.
Evaluate that derivative at the input it actually receives.
Repeat until every nested input has been differentiated down to \(x\).
In particular, every logarithm must have a positive argument.
Worked Examples
Worked Example: Exponential of a Sine
Differentiate \(y=e^{\sin x}\).
The outer function is the exponential, and its input is \(\sin x\). Differentiating the outer layer gives \(e^{\sin x}\). The inner sine has derivative \(\cos x\), so multiply by that factor:
Check: The exponential layer contributes \(e^{\sin x}\), and the sine layer contributes \(\cos x\); both required factors appear. At \(x=0\), the original inner value is \(\sin 0=0\), so the derivative formula gives \(e^0\cos 0=1\cdot1=1\). The expression is defined for every real \(x\).
Worked Example: Logarithm of One Plus an Exponential
Differentiate \(y=\ln(1+e^x)\).
The outer function is the natural logarithm, with inner argument \(1+e^x\). The derivative of \(\ln u\) is \(u'/u\), provided \(u>0\). Here \(1+e^x>0\) for every real \(x\), and the derivative of the argument is \(e^x\):
Check: The logarithm rule supplies the denominator \(1+e^x\), while differentiating its argument supplies the numerator \(e^x\). At \(x=0\), the derivative is \(e^0/(1+e^0)=1/2\). The argument \(1+e^x\) is positive, so the logarithm and derivative are defined for all real \(x\).
Worked Example: Sine of a Logarithm
Differentiate \(y=\sin(\ln x)\), and state where the function is defined.
The outer layer is sine, whose derivative contributes \(\cos(\ln x)\). Its input is \(\ln x\), whose derivative is \(1/x\). The logarithm requires \(x>0\):
Check: The sine layer contributes \(\cos(\ln x)\), and the logarithm layer contributes \(1/x\). At \(x=1\), the derivative is \(\cos(\ln 1)/1=\cos 0=1\). The restriction \(x>0\) is necessary because \(\ln x\) is defined only for positive \(x\).
Worked Example: An Exponential with a Doubled Trigonometric Input
Differentiate \(y=e^{\sin(2x)}\).
This expression has three layers: the outer exponential, then sine, then the inner expression \(2x\). Differentiating each layer in turn gives:
Check: The three factors correspond to the exponential layer, the sine layer, and the \(2x\) layer. At \(x=0\), the result is \(2e^0\cos 0=2\). Omitting the final factor \(2\) would fail to account for the derivative of the innermost expression.
Reading the Structure Before Calculating
Before differentiating a mixed composition, it can help to write its layers in words. For \(e^{\sin x}\), read “exponential of sine of \(x\).” For \(\sin(\ln x)\), read “sine of logarithm of \(x\).” The order of the words identifies which function is outermost. This prevents applying the right derivative rule to the wrong layer.
For a longer expression such as \(e^{\sin(2x)}\), a useful written structure is:
Taking the derivative follows the same structure from right to left: the derivative of the last function, evaluated at its input, times the derivative of the preceding layer, and so on. This is why the derivative contains \(e^{\sin(2x)}\), \(\cos(2x)\), and \(2\), rather than just one of those factors.
| Expression | Layer outside | Inner factor(s) |
|---|---|---|
| \(e^{\sin x}\) | Exponential | \(\cos x\) |
| \(\ln(1+e^x)\) | Natural logarithm | \(e^x\), divided by \(1+e^x\) |
| \(\sin(\ln x)\) | Sine | \(1/x\) |
| \(e^{\sin(2x)}\) | Exponential | \(\cos(2x)\) and \(2\) |
Common Mistake: Stopping at the Outer Derivative
A frequent error is to differentiate the outside function but forget that its input depends on \(x\). For instance, the incorrect calculation
accounts for differentiating the exponential layer, but not for differentiating \(\sin x\). The corrected calculation is
A related error with \(e^{\sin(2x)}\) is to include \(\cos(2x)\) but omit the factor \(2\). The innermost expression is \(2x\), and its derivative is \(2\), so the full derivative must include that factor too.
Domain and Meaning
Exponential expressions such as \(e^{\sin x}\) are defined for all real \(x\), because the exponential accepts every real input. A logarithmic composition has an additional condition: its argument must be positive. For \(\ln(1+e^x)\), positivity holds for every real \(x\), since \(e^x>0\) and therefore \(1+e^x>0\). For \(\sin(\ln x)\), the condition is \(x>0\), because the logarithm's argument is \(x\).
These domain checks are part of determining where a derivative formula applies, not an optional final detail. A formula involving \(1/x\) does not make sense at \(x=0\), and the original expression \(\sin(\ln x)\) is not defined there either.
Check Your Understanding
For each expression, identify its layers and differentiate. Include any necessary domain restriction.
- Differentiate \(e^{\cos x}\).
- Differentiate \(\ln(2+e^{3x})\).
- Differentiate \(\cos(\ln x)\), and state its domain.
- Differentiate \(e^{\sin(4x)}\).
- In the derivative of \(e^{\sin(2x)}\), what does each of the three factors represent?