In
calculus
Calculus is the mathematics, mathematical study of continuous change, in the same way that geometry is the study of shape, and algebra is the study of generalizations of arithmetic operations.
Originally called infinitesimal calculus or "the ...
, the chain rule is a
formula
In science, a formula is a concise way of expressing information symbolically, as in a mathematical formula or a ''chemical formula''. The informal use of the term ''formula'' in science refers to the general construct of a relationship betwe ...
that expresses the
derivative
In mathematics, the derivative is a fundamental tool that quantifies the sensitivity to change of a function's output with respect to its input. The derivative of a function of a single variable at a chosen input value, when it exists, is t ...
of the
composition of two
differentiable functions and in terms of the derivatives of and . More precisely, if
is the function such that
for every , then the chain rule is, in
Lagrange's notation,
or, equivalently,
The chain rule may also be expressed in
Leibniz's notation. If a variable depends on the variable , which itself depends on the variable (that is, and are
dependent variable
A variable is considered dependent if it depends on (or is hypothesized to depend on) an independent variable. Dependent variables are studied under the supposition or demand that they depend, by some law or rule (e.g., by a mathematical functio ...
s), then depends on as well, via the intermediate variable . In this case, the chain rule is expressed as
and
for indicating at which points the derivatives have to be evaluated.
In
integration, the counterpart to the chain rule is the
substitution rule.
Intuitive explanation
Intuitively, the chain rule states that knowing the instantaneous rate of change of relative to and that of relative to allows one to calculate the instantaneous rate of change of relative to as the product of the two rates of change.
As put by
George F. Simmons: "If a car travels twice as fast as a bicycle and the bicycle is four times as fast as a walking man, then the car travels 2 × 4 = 8 times as fast as the man."
The relationship between this example and the chain rule is as follows. Let , and be the (variable) positions of the car, the bicycle, and the walking man, respectively. The rate of change of relative positions of the car and the bicycle is
Similarly,
So, the rate of change of the relative positions of the car and the walking man is
The rate of change of positions is the ratio of the speeds, and the speed is the derivative of the position with respect to the time; that is,
or, equivalently,
which is also an application of the chain rule.
History
The chain rule seems to have first been used by
Gottfried Wilhelm Leibniz
Gottfried Wilhelm Leibniz (or Leibnitz; – 14 November 1716) was a German polymath active as a mathematician, philosopher, scientist and diplomat who is credited, alongside Sir Isaac Newton, with the creation of calculus in addition to ...
. He used it to calculate the derivative of
as the composite of the square root function and the function
. He first mentioned it in a 1676 memoir (with a sign error in the calculation). The common notation of the chain rule is due to Leibniz.
Guillaume de l'Hôpital used the chain rule implicitly in his ''
Analyse des infiniment petits''. The chain rule does not appear in any of
Leonhard Euler
Leonhard Euler ( ; ; ; 15 April 170718 September 1783) was a Swiss polymath who was active as a mathematician, physicist, astronomer, logician, geographer, and engineer. He founded the studies of graph theory and topology and made influential ...
's analysis books, even though they were written over a hundred years after Leibniz's discovery.. It is believed that the first "modern" version of the chain rule appears in Lagrange's 1797 ''Théorie des fonctions analytiques''; it also appears in Cauchy's 1823 ''Résumé des Leçons données a L’École Royale Polytechnique sur Le Calcul Infinitesimal''.
Statement
The simplest form of the chain rule is for real-valued functions of one
real variable. It states that if ' is a function that is differentiable at a point ' (i.e. the derivative exists) and ' is a function that is differentiable at , then the composite function
is differentiable at ', and the derivative is
The rule is sometimes abbreviated as
If and , then this abbreviated form is written in
Leibniz notation as:
The points where the derivatives are evaluated may also be stated explicitly:
Carrying the same reasoning further, given ' functions
with the composite function
, if each function
is differentiable at its immediate input, then the composite function is also differentiable by the repeated application of Chain Rule, where the derivative is (in Leibniz's notation):
Applications

Composites of more than two functions
The chain rule can be applied to composites of more than two functions. To take the derivative of a composite of more than two functions, notice that the composite of , , and ' (in that order) is the composite of with . The chain rule states that to compute the derivative of , it is sufficient to compute the derivative of ' and the derivative of . The derivative of can be calculated directly, and the derivative of can be calculated by applying the chain rule again.
For concreteness, consider the function
This can be decomposed as the composite of three functions:
So that
.
Their derivatives are:
The chain rule states that the derivative of their composite at the point is:
In
Leibniz's notation, this is:
or for short,
The derivative function is therefore:
Another way of computing this derivative is to view the composite function as the composite of and ''h''. Applying the chain rule in this manner would yield:
This is the same as what was computed above. This should be expected because .
Sometimes, it is necessary to differentiate an arbitrarily long composition of the form
. In this case, define
where
and
when
. Then the chain rule takes the form
or, in the Lagrange notation,
Quotient rule
The chain rule can be used to derive some well-known differentiation rules. For example, the quotient rule is a consequence of the chain rule and the
product rule. To see this, write the function as the product . First apply the product rule:
To compute the derivative of , notice that it is the composite of with the reciprocal function, that is, the function that sends to . The derivative of the reciprocal function is
. By applying the chain rule, the last expression becomes:
which is the usual formula for the quotient rule.
Derivatives of inverse functions
Suppose that has an
inverse function
In mathematics, the inverse function of a function (also called the inverse of ) is a function that undoes the operation of . The inverse of exists if and only if is bijective, and if it exists, is denoted by f^ .
For a function f\colon ...
. Call its inverse function so that we have . There is a formula for the derivative of in terms of the derivative of . To see this, note that and satisfy the formula
And because the functions
and are equal, their derivatives must be equal. The derivative of is the constant function with value 1, and the derivative of
is determined by the chain rule. Therefore, we have that:
To express as a function of an independent variable , we substitute
for wherever it appears. Then we can solve for .
For example, consider the function . It has an inverse . Because , the above formula says that
This formula is true whenever is differentiable and its inverse is also differentiable. This formula can fail when one of these conditions is not true. For example, consider . Its inverse is , which is not differentiable at zero. If we attempt to use the above formula to compute the derivative of at zero, then we must evaluate . Since and , we must evaluate 1/0, which is undefined. Therefore, the formula fails in this case. This is not surprising because is not differentiable at zero.
Back propagation
The chain rule forms the basis of the
back propagation algorithm, which is used in
gradient descent of
neural networks
A neural network is a group of interconnected units called neurons that send signals to one another. Neurons can be either Cell (biology), biological cells or signal pathways. While individual neurons are simple, many of them together in a netwo ...
in
deep learning (
artificial intelligence
Artificial intelligence (AI) is the capability of computer, computational systems to perform tasks typically associated with human intelligence, such as learning, reasoning, problem-solving, perception, and decision-making. It is a field of re ...
).
Higher derivatives
Faà di Bruno's formula generalizes the chain rule to higher derivatives. Assuming that and , then the first few derivatives are:
Proofs
First proof
One proof of the chain rule begins by defining the derivative of the composite function , where we take the
limit of the
difference quotient
In single-variable calculus, the difference quotient is usually the name for the expression
: \frac
which when taken to the Limit of a function, limit as ''h'' approaches 0 gives the derivative of the Function (mathematics), function ''f''. The ...
for as approaches :
Assume for the moment that
does not equal
for any
near
. Then the previous expression is equal to the product of two factors:
If
oscillates near , then it might happen that no matter how close one gets to , there is always an even closer such that . For example, this happens near for the
continuous function
In mathematics, a continuous function is a function such that a small variation of the argument induces a small variation of the value of the function. This implies there are no abrupt changes in value, known as '' discontinuities''. More preci ...
defined by for and otherwise. Whenever this happens, the above expression is undefined because it involves
division by zero
In mathematics, division by zero, division (mathematics), division where the divisor (denominator) is 0, zero, is a unique and problematic special case. Using fraction notation, the general example can be written as \tfrac a0, where a is the di ...
. To work around this, introduce a function
as follows:
We will show that the difference quotient for is always equal to:
Whenever is not equal to , this is clear because the factors of cancel. When equals , then the difference quotient for is zero because equals , and the above product is zero because it equals times zero. So the above product is always equal to the difference quotient, and to show that the derivative of at exists and to determine its value, we need only show that the limit as goes to of the above product exists and determine its value.
To do this, recall that the limit of a product exists if the limits of its factors exist. When this happens, the limit of the product of these two factors will equal the product of the limits of the factors. The two factors are and . The latter is the difference quotient for at , and because is differentiable at by assumption, its limit as tends to exists and equals .
As for , notice that is defined wherever ' is. Furthermore, ' is differentiable at by assumption, so is continuous at , by definition of the derivative. The function is continuous at because it is differentiable at , and therefore is continuous at . So its limit as ' goes to ' exists and equals , which is .
This shows that the limits of both factors exist and that they equal and , respectively. Therefore, the derivative of at ''a'' exists and equals .
Second proof
Another way of proving the chain rule is to measure the error in the linear approximation determined by the derivative. This proof has the advantage that it generalizes to several variables. It relies on the following equivalent definition of differentiability at a point: A function ''g'' is differentiable at ''a'' if there exists a real number ''g''′(''a'') and a function ''ε''(''h'') that tends to zero as ''h'' tends to zero, and furthermore
Here the left-hand side represents the true difference between the value of ''g'' at ''a'' and at , whereas the right-hand side represents the approximation determined by the derivative plus an error term.
In the situation of the chain rule, such a function ''ε'' exists because ''g'' is assumed to be differentiable at ''a''. Again by assumption, a similar function also exists for ''f'' at ''g''(''a''). Calling this function ''η'', we have
The above definition imposes no constraints on ''η''(0), even though it is assumed that ''η''(''k'') tends to zero as ''k'' tends to zero. If we set , then ''η'' is continuous at 0.
Proving the theorem requires studying the difference as ''h'' tends to zero. The first step is to substitute for using the definition of differentiability of ''g'' at ''a'':
The next step is to use the definition of differentiability of ''f'' at ''g''(''a''). This requires a term of the form for some ''k''. In the above equation, the correct ''k'' varies with ''h''. Set and the right hand side becomes . Applying the definition of the derivative gives:
To study the behavior of this expression as ''h'' tends to zero, expand ''k''
''h''. After regrouping the terms, the right-hand side becomes:
Because ''ε''(''h'') and ''η''(''k''
''h'') tend to zero as ''h'' tends to zero, the first two bracketed terms tend to zero as ''h'' tends to zero. Applying the same theorem on products of limits as in the first proof, the third bracketed term also tends zero. Because the above expression is equal to the difference , by the definition of the derivative is differentiable at ''a'' and its derivative is
The role of ''Q'' in the first proof is played by ''η'' in this proof. They are related by the equation:
The need to define ''Q'' at ''g''(''a'') is analogous to the need to define ''η'' at zero.
Third proof
Constantin Carathéodory
Constantin Carathéodory (; 13 September 1873 – 2 February 1950) was a Greeks, Greek mathematician who spent most of his professional career in Germany. He made significant contributions to real and complex analysis, the calculus of variations, ...
's alternative definition of the differentiability of a function can be used to give an elegant proof of the chain rule.
Under this definition, a function is differentiable at a point if and only if there is a function , continuous at and such that . There is at most one such function, and if is differentiable at then .
Given the assumptions of the chain rule and the fact that differentiable functions and compositions of continuous functions are continuous, we have that there exist functions , continuous at , and , continuous at , and such that,
and
Therefore,
but the function given by is continuous at , and we get, for this
A similar approach works for continuously differentiable (vector-)functions of many variables. This method of factoring also allows a unified approach to stronger forms of differentiability, when the derivative is required to be
Lipschitz continuous
In mathematical analysis, Lipschitz continuity, named after Germany, German mathematician Rudolf Lipschitz, is a strong form of uniform continuity for function (mathematics), functions. Intuitively, a Lipschitz continuous function is limited in h ...
,
Hölder continuous, etc. Differentiation itself can be viewed as the
polynomial remainder theorem (the little
Bézout theorem, or factor theorem), generalized to an appropriate class of functions.
Proof via infinitesimals
If
and
then choosing infinitesimal
we compute the corresponding
and then the corresponding
, so that
and applying the
standard part we obtain
which is the chain rule.
Multivariable case
The full generalization of the chain rule to
multi-variable functions (such as
) is rather technical. However, it is simpler to write in the case of functions of the form
where
, and
for each
As this case occurs often in the study of functions of a single variable, it is worth describing it separately.
Case of scalar-valued functions with multiple inputs
Let
, and
for each
To write the chain rule for the composition of functions
one needs the
partial derivative
In mathematics, a partial derivative of a function of several variables is its derivative with respect to one of those variables, with the others held constant (as opposed to the total derivative, in which all variables are allowed to vary). P ...
s of with respect to its arguments. The usual notations for partial derivatives involve names for the arguments of the function. As these arguments are not named in the above formula, it is simpler and clearer to use
''D''-Notation, and to denote by
the partial derivative of with respect to its th argument, and by
the value of this derivative at .
With this notation, the chain rule is
Example: arithmetic operations
If the function is addition, that is, if
then
and
. Thus, the chain rule gives
For multiplication
the partials are
and
. Thus,
The case of exponentiation
is slightly more complicated, as
and, as
It follows that
General rule: Vector-valued functions with multiple inputs
The simplest way for writing the chain rule in the general case is to use the
total derivative
In mathematics, the total derivative of a function at a point is the best linear approximation near this point of the function with respect to its arguments. Unlike partial derivatives, the total derivative approximates the function with res ...
, which is a linear transformation that captures all
directional derivative
In multivariable calculus, the directional derivative measures the rate at which a function changes in a particular direction at a given point.
The directional derivative of a multivariable differentiable (scalar) function along a given vect ...
s in a single formula. Consider differentiable functions and , and a point in . Let denote the total derivative of at and denote the total derivative of at . These two derivatives are linear transformations and , respectively, so they can be composed. The chain rule for total derivatives is that their composite is the total derivative of at :
or for short,
The higher-dimensional chain rule can be proved using a technique similar to the second proof given above.
Because the total derivative is a linear transformation, the functions appearing in the formula can be rewritten as matrices. The matrix corresponding to a total derivative is called a
Jacobian matrix, and the composite of two derivatives corresponds to the product of their Jacobian matrices. From this perspective the chain rule therefore says:
or for short,
That is, the Jacobian of a composite function is the product of the Jacobians of the composed functions (evaluated at the appropriate points).
The higher-dimensional chain rule is a generalization of the one-dimensional chain rule. If , , and are 1, so that and , then the Jacobian matrices of and are . Specifically, they are:
The Jacobian of is the product of these matrices, so it is , as expected from the one-dimensional chain rule. In the language of linear transformations, is the function which scales a vector by a factor of and is the function which scales a vector by a factor of . The chain rule says that the composite of these two linear transformations is the linear transformation , and therefore it is the function that scales a vector by .
Another way of writing the chain rule is used when ''f'' and ''g'' are expressed in terms of their components as and . In this case, the above rule for Jacobian matrices is usually written as:
The chain rule for total derivatives implies a chain rule for partial derivatives. Recall that when the total derivative exists, the partial derivative in the -th coordinate direction is found by multiplying the Jacobian matrix by the -th basis vector. By doing this to the formula above, we find:
Since the entries of the Jacobian matrix are partial derivatives, we may simplify the above formula to get:
More conceptually, this rule expresses the fact that a change in the direction may change all of through , and any of these changes may affect .
In the special case where , so that is a real-valued function, then this formula simplifies even further:
This can be rewritten as a
dot product
In mathematics, the dot product or scalar productThe term ''scalar product'' means literally "product with a Scalar (mathematics), scalar as a result". It is also used for other symmetric bilinear forms, for example in a pseudo-Euclidean space. N ...
. Recalling that , the partial derivative is also a vector, and the chain rule says that:
Example
Given where and , determine the value of and using the chain rule.
and
Higher derivatives of multivariable functions
Faà di Bruno's formula for higher-order derivatives of single-variable functions generalizes to the multivariable case. If is a function of as above, then the second derivative of is:
Further generalizations
All extensions of calculus have a chain rule. In most of these, the formula remains the same, though the meaning of that formula may be vastly different.
One generalization is to
manifold
In mathematics, a manifold is a topological space that locally resembles Euclidean space near each point. More precisely, an n-dimensional manifold, or ''n-manifold'' for short, is a topological space with the property that each point has a N ...
s. In this situation, the chain rule represents the fact that the derivative of is the composite of the derivative of and the derivative of . This theorem is an immediate consequence of the higher dimensional chain rule given above, and it has exactly the same formula.
The chain rule is also valid for
Fréchet derivatives in
Banach space
In mathematics, more specifically in functional analysis, a Banach space (, ) is a complete normed vector space. Thus, a Banach space is a vector space with a metric that allows the computation of vector length and distance between vectors and ...
s. The same formula holds as before.
This case and the previous one admit a simultaneous generalization to
Banach manifolds.
In
differential algebra, the derivative is interpreted as a morphism of modules of
Kähler differentials. A
ring homomorphism of
commutative ring
In mathematics, a commutative ring is a Ring (mathematics), ring in which the multiplication operation is commutative. The study of commutative rings is called commutative algebra. Complementarily, noncommutative algebra is the study of ring prope ...
s determines a morphism of Kähler differentials which sends an element to , the exterior differential of . The formula holds in this context as well.
The common feature of these examples is that they are expressions of the idea that the derivative is part of a
functor
In mathematics, specifically category theory, a functor is a Map (mathematics), mapping between Category (mathematics), categories. Functors were first considered in algebraic topology, where algebraic objects (such as the fundamental group) ar ...
. A functor is an operation on spaces and functions between them. It associates to each space a new space and to each function between two spaces a new function between the corresponding new spaces. In each of the above cases, the functor sends each space to its
tangent bundle
A tangent bundle is the collection of all of the tangent spaces for all points on a manifold, structured in a way that it forms a new manifold itself. Formally, in differential geometry, the tangent bundle of a differentiable manifold M is ...
and it sends each function to its derivative. For example, in the manifold case, the derivative sends a -manifold to a -manifold (its tangent bundle) and a -function to its total derivative. There is one requirement for this to be a functor, namely that the derivative of a composite must be the composite of the derivatives. This is exactly the formula .
There are also chain rules in
stochastic calculus
Stochastic calculus is a branch of mathematics that operates on stochastic processes. It allows a consistent theory of integration to be defined for integrals of stochastic processes with respect to stochastic processes. This field was created an ...
. One of these,
Itō's lemma, expresses the composite of an Itō process (or more generally a
semimartingale) ''dX''
''t'' with a twice-differentiable function ''f''. In Itō's lemma, the derivative of the composite function depends not only on ''dX''
''t'' and the derivative of ''f'' but also on the second derivative of ''f''. The dependence on the second derivative is a consequence of the non-zero
quadratic variation of the stochastic process, which broadly speaking means that the process can move up and down in a very rough way. This variant of the chain rule is not an example of a functor because the two functions being composed are of different types.
See also
* − a computational method that makes heavy use of the chain rule to compute exact numerical derivatives.
*
*
*
*
*
*
References
External links
*
*
{{Calculus topics
Articles containing proofs
Differentiation rules
Theorems in mathematical analysis
Theorems in calculus