{
  "id": "chain-rule",
  "title": "Chain Rule",
  "lang": "en",
  "source_lang": "en",
  "summary": "The chain rule expresses the derivative of a composite function in terms of the derivatives of its component functions.",
  "category": "mathematics",
  "subcategory": "analysis",
  "type": "concept",
  "aliases": [
    "Chain rule of differentiation",
    "Composite function differentiation rule"
  ],
  "generated_at": "2026-10-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/chain-rule/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/chain-rule/",
      "json": "https://aiwiki.page/zh/chain-rule.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The chain rule is a theorem of calculus that determines the derivative of a composition of functions. It describes how changes propagate through successive dependencies: an input changes an intermediate quantity, which changes the final output. For scalar functions, the relevant derivatives multiply; for functions of several variables, contributions from different dependencies must also be added. The rule connects elementary differentiation with multivariable analysis and computational methods for evaluating derivatives. (openstax.org)"
    },
    {
      "heading": "Single-variable formulation",
      "text": "Let \\(g\\) be differentiable at \\(a\\), and let \\(f\\) be differentiable at \\(g(a)\\), with the composition defined near \\(a\\). Then\n\n\\[(f\\circ g)'(a)=f'(g(a))\\,g'(a).\\]\n\nThe outer derivative must be evaluated at the output of the inner function, not at the original input. These differentiability assumptions are sufficient; continuity of the derivative functions is not required. (openstax.org)\n\nUsing the notation associated with Gottfried Wilhelm Leibniz, if \\(u=g(x)\\) and \\(y=f(u)\\), the same identity becomes\n\n\\[\\frac{dy}{dx}=\\frac{dy}{du}\\frac{du}{dx}.\\]\n\nAlthough this resembles cancellation of fractions, its justification is the differentiation theorem. (live.ocw.mit.edu)\n\nFor example, taking a polynomial as the inner function,\n\n\\[\\frac{d}{dx}(3x^2+1)^5 =5(3x^2+1)^4(6x).\\]\n\nFor three nested functions, repeated application gives\n\n\\[\\frac{d}{dx}f(g(h(x))) =f'(g(h(x)))\\,g'(h(x))\\,h'(x).\\]\n\nEvery layer contributes a derivative evaluated at its own input. Omitting an inner derivative is therefore an incomplete application of the rule. (openstax.org)"
    },
    {
      "heading": "Mathematical basis",
      "text": "The rule follows from differentiability understood as local linear approximation. Put \\(b=g(a)\\). For small \\(h\\),\n\n\\[g(a+h)=b+g'(a)h+o(h),\\]\n\nand, for small \\(k\\),\n\n\\[f(b+k)=f(b)+f'(b)k+o(k).\\]\n\nHere \\(o(h)\\) denotes an error whose ratio to \\(|h|\\) approaches zero in the relevant limit. Substituting the first increment into the second expansion produces\n\n\\[f(g(a+h)) =f(b)+f'(b)g'(a)h+o(h),\\]\n\nwhich establishes the derivative formula. This argument remains valid when \\(g'(a)=0\\), unlike a naive proof that divides by the change in \\(g\\), which may vanish. (openstax.org)\n\nThe assumptions are not necessary for every composite to be differentiable. For instance, \\(g(x)=|x|\\) is not differentiable at zero, but \\(f(u)=u^2\\) gives \\(f(g(x))=x^2\\). Thus, a differentiable composite does not imply differentiable component functions. This example illustrates the distinction between sufficient hypotheses and their converse. (openstax.org)"
    },
    {
      "heading": "Several variables",
      "text": "Suppose \\(z=f(x,y)\\), with \\(x=x(t)\\) and \\(y=y(t)\\), and assume the functions are differentiable. Then\n\n\\[\\frac{dz}{dt} =\\frac{\\partial f}{\\partial x}\\frac{dx}{dt} +\\frac{\\partial f}{\\partial y}\\frac{dy}{dt}.\\]\n\nEach partial derivative measures sensitivity to one intermediate variable, holding the other fixed. Both terms contribute because both intermediate variables can change with \\(t\\). The partial derivatives are evaluated at \\((x(t),y(t))\\). (openstax.org)\n\nFor example, if \\(f(x,y)=x^2+y^2\\), \\(x=\\cos t\\), and \\(y=\\sin t\\), then\n\n\\[\\frac{dz}{dt} =2\\cos t(-\\sin t)+2\\sin t\\cos t=0,\\]\n\nconsistent with \\(z=1\\). More generally, if \\(w=f(x_1,\\ldots,x_m)\\) and each \\(x_i\\) depends on \\(t_1,\\ldots,t_n\\),\n\n\\[\\frac{\\partial w}{\\partial t_j} =\\sum_{i=1}^{m} \\frac{\\partial f}{\\partial x_i} \\frac{\\partial x_i}{\\partial t_j}.\\]\n\nDependency diagrams organize this calculation by multiplying derivatives along each path and adding the resulting contributions. (openstax.org)"
    },
    {
      "heading": "Jacobian and gradient forms",
      "text": "For differentiable maps \\(g:\\mathbb{R}^n\\to\\mathbb{R}^m\\) and \\(f:\\mathbb{R}^m\\to\\mathbb{R}^p\\), the derivative is a linear map between vector spaces. The chain rule states\n\n\\[D(f\\circ g)(x)=Df(g(x))\\circ Dg(x).\\]\n\nIn coordinates, it becomes a product of Jacobian matrices:\n\n\\[J_{f\\circ g}(x)=J_f(g(x))J_g(x).\\]\n\nThe dimensions are respectively \\(p\\times n\\), \\(p\\times m\\), and \\(m\\times n\\). The order matters: matrix multiplication generally does not commute. This expresses the composition of local linear approximations in linear algebra. (live.ocw.mit.edu)\n\nWhen \\(f\\) is scalar-valued and gradients are column vectors,\n\n\\[\\nabla(f\\circ g)(x) =J_g(x)^{\\mathsf T}\\nabla f(g(x)).\\]\n\nThe transpose converts the outer gradient into sensitivity with respect to the original input coordinates. (live.ocw.mit.edu)"
    },
    {
      "heading": "Integration by substitution",
      "text": "The chain rule underlies integration by substitution. If \\(F'=f\\), then\n\n\\[\\frac{d}{dx}F(g(x))=f(g(x))g'(x),\\]\n\nso\n\n\\[\\int f(g(x))g'(x)\\,dx=F(g(x))+C.\\]\n\nThis is the differentiation identity used in reverse. Together with the fundamental theorem of calculus, it also gives the corresponding definite integral:\n\n\\[\\int_a^b f(g(x))g'(x)\\,dx =\\int_{g(a)}^{g(b)}f(u)\\,du,\\]\n\nprovided \\(g\\) is continuously differentiable on \\([a,b]\\) and \\(f\\) is continuous on its image. The integration bounds change with the substituted variable. (openstax.org)"
    },
    {
      "heading": "Computational applications",
      "text": "Automatic differentiation evaluates derivatives of computer programs by decomposing calculations into elementary operations and repeatedly applying the chain rule. A computational graph records dependencies. Forward mode propagates input sensitivities toward outputs; reverse mode propagates output sensitivities backward. Unlike finite-difference approximations, these methods differentiate the operations themselves, although numerical evaluation remains subject to rounding. (jmlr.org)\n\nIn machine learning, backpropagation applies reverse-mode differentiation to obtain derivatives of a loss function with respect to parameters of an artificial neural network. Those derivatives support optimization methods such as gradient descent. When an intermediate value influences the output through several branches, its derivative contributions must be accumulated, reflecting the sum in the multivariable chain rule rather than a single product along one path. (jmlr.org)"
    }
  ],
  "links": [
    "calculus",
    "derivative",
    "function-composition",
    "mathematical-function",
    "gottfried-wilhelm-leibniz",
    "polynomial",
    "limit",
    "partial-derivative",
    "linear-map",
    "vector-space",
    "jacobian-matrix",
    "matrix",
    "linear-algebra",
    "matrix-transpose",
    "gradient",
    "integration-by-substitution",
    "fundamental-theorem-of-calculus",
    "integral",
    "automatic-differentiation",
    "computational-graph",
    "machine-learning",
    "backpropagation",
    "loss-function",
    "artificial-neural-network",
    "mathematical-optimization",
    "gradient-descent"
  ],
  "sources": [
    {
      "title": "openstax.org/books/calculus-volume-1/pages/3-6-the-chain-rule",
      "url": "https://openstax.org/books/calculus-volume-1/pages/3-6-the-chain-rule"
    },
    {
      "title": "live.ocw.mit.edu/courses/18-s096-matrix-calculus-for-machine-learning-and-beyon…",
      "url": "https://live.ocw.mit.edu/courses/18-s096-matrix-calculus-for-machine-learning-and-beyond-january-iap-2023/mit18_s096iap23_lec_full.pdf"
    },
    {
      "title": "openstax.org/books/calculus-volume-3/pages/4-5-the-chain-rule",
      "url": "https://openstax.org/books/calculus-volume-3/pages/4-5-the-chain-rule"
    },
    {
      "title": "openstax.org/books/calculus-volume-1/pages/5-5-substitution",
      "url": "https://openstax.org/books/calculus-volume-1/pages/5-5-substitution"
    },
    {
      "title": "jmlr.org/papers/volume18/17-468/17-468.pdf",
      "url": "https://jmlr.org/papers/volume18/17-468/17-468.pdf"
    }
  ],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}