# What is the derivative of f(g(h(x)))?

It's ${f}^{p} r i m e \left(g \left(h \left(x\right)\right)\right) {g}^{p} r i m e \left(h \left(x\right)\right) {h}^{p} r i m e \left(x\right)$

Start by defining the function $a \left(x\right) = g \left(h \left(x\right)\right)$

The the chain rule gives us:

${\left(f \circ g \circ h\right)}^{p} r i m e \left(x\right) = {\left(f \circ \alpha\right)}^{p} r i m e \left(x\right) = {f}^{p} r i m e \left(\alpha \left(x\right)\right) {\alpha}^{p} r i m e \left(x\right)$

Applying the definition of $\alpha \left(x\right)$ to the equation above gives us:

${f}^{p} r i m e \left(\alpha \left(x\right)\right) {\alpha}^{p} r i m e \left(x\right) = {f}^{p} r i m e \left(g \left(h \left(x\right)\right)\right) {\left(g \circ h\right)}^{p} r i m e \left(x\right)$

Using the chain rule again:

${f}^{p} r i m e \left(g \left(h \left(x\right)\right)\right) {\left(g \circ h\right)}^{p} r i m e \left(x\right) = {f}^{p} r i m e \left(g \left(h \left(x\right)\right)\right) {g}^{p} r i m e \left(h \left(x\right)\right) {h}^{p} r i m e \left(x\right)$

Therefore:

${\left(f \circ g \circ h\right)}^{p} r i m e \left(x\right) = {f}^{p} r i m e \left(g \left(h \left(x\right)\right)\right) {g}^{p} r i m e \left(h \left(x\right)\right) {h}^{p} r i m e \left(x\right)$

The same derivation using the Leibniz notation and the definitions $y = h \left(x\right)$, $w = g \left(y\right)$:

$\frac{d}{\mathrm{dx}} \left[f \left(w\right)\right] = \frac{\mathrm{df}}{\mathrm{dw}} \frac{\mathrm{dw}}{\mathrm{dx}} = \frac{\mathrm{df}}{\mathrm{dw}} \frac{\mathrm{dw}}{\mathrm{dy}} \frac{\mathrm{dy}}{\mathrm{dx}} = \frac{\mathrm{df}}{\mathrm{dw}} \left(w\right) \frac{\mathrm{dw}}{\mathrm{dy}} \left(y\right) \frac{\mathrm{dy}}{\mathrm{dx}} \left(x\right) = \frac{\mathrm{df}}{\mathrm{dw}} \left(g \left(y\right)\right) \frac{\mathrm{dw}}{\mathrm{dy}} \left(h \left(x\right)\right) \frac{\mathrm{dy}}{\mathrm{dx}} \left(x\right) = \frac{\mathrm{df}}{\mathrm{dw}} \left(g \left(h \left(x\right)\right)\right) \frac{\mathrm{dw}}{\mathrm{dy}} \left(h \left(x\right)\right) \frac{\mathrm{dy}}{\mathrm{dx}} \left(x\right) = {f}^{p} r i m e \left(g \left(h \left(x\right)\right)\right) {g}^{p} r i m e \left(h \left(x\right)\right) {h}^{p} r i m e \left(x\right)$