2.2 The chain rule
Single variable
You should know the very important chain rule for functions of a single variable: if f and g are differentiable functions of a single variable and the function F is defined by F(x) = f(g(x)) for all x, thenF'(x) = f'(g(x))g'(x).
This rule may be used to find the derivative of any “function of a function”, as the following examples illustrate.
 Example
 What is the derivative of the function F defined by F(x) = e^{x1/2}? If we define the functions f and g by f(z) = e^{z} and g(x) = x^{1/2}, then we have F(x) = f(g(x)) for all x. Thus using the chain rule, we have F'(x) = f'(g(x))g'(x) = e^{g(x)}(1/2)x^{−1/2} = (1/2)e^{x1/2}x^{−1/2}.
 Example
 What is the derivative of the function F defined by F(x) = log x^{2}? If we define the functions f and g by f(z) = log z and g(x) = x^{2}, then we have F(x) = f(g(x)), so that by the chain rule we have F'(x) = f'(g(x))g'(x) = (1/x^{2})2x = 2/x.
More importantly for economic theory, the chain rule allows us to find the derivatives of expressions involving arbitrary functions of functions. Most situations in economics involve more than one variable, so we need to extend the rule to many variables.
Two variables
First consider the case of two variables. Suppose that g and h are differentiable functions of a single variable, f is a differentiable function of two variables, and the function F of a single variable is defined byF'(x)  =  f'_{1}(g(x), h(x))g'(x) + f'_{2}(g(x), h(x))h'(x), 
An extension
We can extend this rule. If f, g, and h are differentiable functions of two variables and the function F of two variables is defined byF(x, y)  =  f(g(x, y), h(x, y)) for all x and y 
F'_{x}(x, y)  =  f'_{1}(g(x, y), h(x, y))g'_{x}(x, y) + f'_{2}(g(x, y), h(x, y))h'_{x}(x, y), 
More generally, we have the following result.
 Proposition (Chain rule)

If g^{j} is a differentiable function of m variables for j = 1, ..., n, f is a differentiable function of n variables, and the function F of m variables is defined by
F(x_{1}, ..., x_{m}) = f(g^{1}(x_{1}, ..., x_{m}), ..., g^{n}(x_{1}, ..., x_{m})) for all (x_{1}, ..., x_{m}) F'_{k}(x_{1}, ..., x_{m}) = ∑n
i=1f'_{i}(g^{1}(x_{1}, ..., x_{m}), ..., g^{n}(x_{1}, ..., x_{m}))gi
k'(x_{1}, ..., x_{m}),
k' is the partial derivative of g^{i} with respect to its kth argument.
 Source
 For a proof, see Rudin (1976), Theorem 9.15 (p. 214).
 Example

Consider a profitmaximizing firm that produces a single output with a single input. Denote its (differentiable) production function by f, the price of the input by w, and the price of the output by p. Suppose that its profitmaximizing input when the prices are w and p is z(w, p). Then its maximized
profit is
π(w, p) = pf(z(w, p)) − wz(w, p).How does this profit change if p increases?
Using the chain rule we have
π'_{p}(w, p) = f(z(w, p)) + pf'(z(w, p))z'_{p}(w, p) − wz'_{p}(w, p) π'_{p}(w, p) = f(z(w, p)) + z'_{p}(w, p)[pf'(z(w, p)) − w]. π'_{p}(w, p) = f(z(w, p)).In words, the rate of increase in the firm's maximized profit as the price of output increases is exactly equal to its optimal output.
 Example

A consumer trades in an economy in which there are n goods. She is endowed with the vector e of the goods, and faces the price vector p. Her demand for any good i depends on p and the value of her endowment given p, namely p·e (the inner product of p and e, which we may alternatively write as ∑n
j=1p_{j}e_{j}). Suppose we specify her demand for good i by the function f of n + 1 variables with values of the form f(p, p·e). What is the rate of change of her demand for good i with respect to p_{i}?The function f has n + 1 arguments—the n elements p_{1}, ..., p_{n} of the vector p and the number p·e. The derivative of p_{j} with respect to p_{i} is 0 for j ≠ i and 1 for j = i, and the derivative of p·e with respect to p_{i} is e_{i}. Thus by the chain rule, the rate of change of the consumer's demand with respect to p_{i} is
f'_{i}(p, p·e) + f'_{n+1}(p, p·e)e_{i}.
Leibniz's formula
We sometimes need to differentiate a definite integral with respect to a parameter that appears in the integrand and in the limits of the integral. Suppose that f is a differentiable function of two variables, a and b are differentiable functions of a single variable, and the function F is defined bya(t)f(t, x) dx for all t.
What is F'(t)? By the logic of the chain rule, it is the sum of three components:
 the partial derivative of the integral with respect to its top limit, times b'(t)
 the partial derivative of the integral with respect to its bottom limit, times a'(t)
 the partial derivative of the integral with respect to t, holding the limits fixed.
a(t)f'_{t}(t, x) dx,
 Proposition (Leibniz's formula)

Let f be a function of two variables, with values f(t, x). Assume that f is continuous, has a partial derivative with respect to t for all (t, x), and this partial derivative is
continuous. Let a and b be differentiable functions of a single variable, and define the function F of one variable by
F(t) = ∫b(t)Then F is differentiable and
a(t)f(t, x) dx for all t.F'(t) = f(t, b(t))b'(t) − f(t, a(t))a'(t) + ∫b(t)
a(t)f'_{1}(t, x) dx.
 Proof

Define the function G of three variables by
G(u, v, t) = ∫vBy 8.11.2 (p. 177) of Dieudonné (1969), G has a partial derivative with respect to t and that derivative is continuous in t and equal to
uf(t, x) dx for all u, v, and t.∫vThis derivative is also continuous in u and v.
uf'_{1}(t, x) dx.Now, by the fundamental theorem of calculus, G has a partial derivative with respect to u and that derivative is equal to −f(t, u), and also G has a partial derivative with respect to v and that derivative is equal to f(t, v). Given that f is continuous, both of these partial derivatives are continuous, so by a previous result G is differentiable. Thus the chain rule implies the expression for F'(t) in the result. If the derivatives a' and b' are continuous, then F' is continuous, given the continuity of f and f'_{1}.
 the part due to the change in b(t), namely f(t, b(t))b'(t)
 the part due to the change in a(t), namely −f(t, a(t))a'(t) (if a(t) increases then the integral decreases)
 the part due to the change in the values of f(t, x), namely ∫b(t)
a(t)f'_{t}(t, x) dx.
 Example

The profit of a firm is π(x) at each time x from 0 to T. At time t the discounted value of future profit is
V(t) = ∫Twhere r is the discount rate. Find V'(t).
tπ(x)e^{−r(x−t)}dx,Use Leibniz's rule. Define a(t) = t, b(t) = T, and f(t, x) = π(x)e^{−r(x−t)}. Then a'(t) = 1, b'(t) = 0, and f'_{1}(t, x) = π(x)re^{−r(x−t)}. Thus
V'(t) = −π(t)e^{−r(t−t)} + ∫T
tπ(x)re^{−r(x−t)}dx= −π(t) + rV(t).