Partial Differentiation

☰ Contents

Profit depends on price and on how many are sold, so it is a function of two variables. Partial differentiation is calculus for functions like these. Every rule of ordinary differentiation still applies. What changes is the geometry: the graph is a surface, and a surface has a different slope in each direction.

What is a function of two variables?

A function of two variables takes a pair of numbers (x, y) and gives back one number, written f(x, y). For x² + y², the input (3, 4) gives 9 + 16 = 25. The input is a point in a plane, and the output is a height above it, so the graph is a surface, here a bowl with its lowest point at the origin. Ordinary calculus needs care here because a surface can slope differently in every direction. Level curves help: each is the slice at one fixed height, like a contour on a map, and this bowl at height 25 gives the circle of radius 5 through (3, 4). Some inputs must be left out, which changes the domain: √(x − y) needs x ≥ y. The point (−3, 4) sits at the same height, because squaring removes the sign. See Functions of two variables and Surfaces in three dimensions.

xy(1.5, 1)xzhold y constanthold y constanthold x constant

hold y constant — the slice is an ordinary curve, and the partial derivative is its gradient: 3

Find a point where the x-slope is zero

xyz
The output is a height above each point, so the graph is a surface, not a curve. Full lesson: Functions of Two Variables
z = x² + y² is lowest at the origin and rises in every direction: a bowl. Full lesson: Surfaces in Three Dimensions

Cut the bowl z = x² + y² at height 4 and the slice is the circle x² + y² = 4, which has radius 2. See Level curves.

481216
That is a contour map. Each step is 4 units, so closely spaced rings mean steep ground. Full lesson: Level Curves

Do limits still work with two variables?

Yes, but in two variables a limit must give the same value along every path into the point, not just from two sides. Take f = 2xy / (x² + y²) near the origin. Along the x-axis, f is 0. Along the line y = x, f is 2x² / 2x², which is 1. Two paths give two values, so the limit does not exist. The value depends on the direction of approach: along y = mx it is 2m / (1 + m²) at every distance. Agreement along two paths proves nothing, so showing a limit exists takes a different step, usually a bound. For x²y / (x² + y²), the size is at most |y|, which goes to 0, so that limit is 0. The line y = 2x makes the first function 4/5 throughout, with 2 × 2 = 4 on top and 1 + 4 = 5 underneath.

xyr1−1f = 0.64f along the rayθ = 20°

along the ray at 20°, f = sin 2θ = 0.64 at every distance from the origin: the value depends on the direction of approach, not on the distance

Turn the ray onto y = −x and read the value

xy
On a plane there are infinitely many ways to approach a point, along any path you like. Full lesson: Limits of Functions of Two Variables

See Limits of functions of two variables.

Continuity means the same as it did for one variable: the limit at a point exists and equals the value of the function there. See Continuity in two variables.

a tear in the sheetthe surface cannot be walked across that pointdiscontinuous there
Picture a sheet with a rip or a step in it. Those are the points that fail. Full lesson: Continuity in Two Variables

What is a partial derivative?

A partial derivative is the rate of change of f in one direction, with the other variable held constant. To find ∂f/∂x, treat y as a constant and differentiate in x as usual; ∂f/∂y is the reverse. For x²y + 5y², ∂f/∂x = 2xy, since y is a constant factor and 5y² is a constant, and ∂f/∂y = x² + 10y. At (1, 2) the x-slope is 2 × 1 × 2 = 4 and the y-slope is 1 + 10 × 2 = 21. Holding y fixed slices the surface parallel to the x-axis, and the slice is an ordinary curve whose gradient is ∂f/∂x. The curly ∂ replaces d to show that other variables are being held still, and a term with no x differentiates to 0 in x. The heights at (1, 2) and (2, 2) are 22 and 28, so that chord has gradient 28 − 22 = 6, above 4 because the slice curves upward. See The partial derivative.

12345510152025xyh = 1.5(3.5, 12.25)(2, 4)

the chord’s gradient exceeds f ′(2) by exactly h

Drag the upper point along the curve

y held constant
Fix y and walk only in the x direction. That slice is an ordinary curve again. Full lesson: The Partial Derivative

No new rules are needed. See Computing partial derivatives.

x2ywaits
2xypower rule on x, with y held constant
Differentiate with respect to x: y is held constant and stays as a factor. Full lesson: Computing Partial Derivatives

Let f = x²y + y³. Then ∂f/∂x = 2xy, because y is a constant factor and y³ is a constant. And ∂f/∂y = x² + 3y², because x² is a constant factor and y³ differentiates to 3y².

a term with no xto that derivative it is a constant
vanishes under
A term that does not contain the variable you differentiate with respect to is a constant, so it vanishes. Full lesson: Computing Partial Derivatives

Now you

one variable varies, the other is held constant

f = x² + 6y. What is ∂f/∂x?

one variable varies, the other is held constant

f = 3x²y. What is ∂f/∂y?

What about second derivatives?

Differentiating a partial derivative again gives a second partial derivative, and there are four: twice in x, twice in y, and the two mixed ones, x then y and y then x. Take f = x³y², whose first derivatives are 3x²y² in x and 2x³y in y. Differentiating again gives ∂²f/∂x² = 6xy² and ∂²f/∂y² = 2x³, and both mixed derivatives are 6x²y. At (1, 2) those are 6 × 1 × 4 = 24, then 2, then 12 for each mixed one. The mixed pair agree by the mixed derivative theorem: when both are continuous, the order does not matter, so only three need working out. Together the three measure how the surface bends, and the test for a stationary point uses all of them. In the other order, 2x³y differentiated in x is 6x²y, and 6 × 1 × 2 = 12 again. See Higher partial derivatives.

2xwaitsy
then once in y — a different variable is held constant each time
Differentiate once in each and you measure how the slope in x changes as you move in y. Full lesson: Higher Partial Derivatives

Take f = x²y³. Then ∂f/∂x = 2xy³, and differentiating that in y gives 6xy². Also ∂f/∂y = 3x²y², and differentiating that in x gives 6xy². See The mixed derivative theorem.

x first
then
y first — the same result
then
Try it: 2xy³ differentiated in y, and 3x²y² differentiated in x, both give 6xy². Full lesson: The Mixed Derivative Theorem

Now you

differentiate in y, then in x

f = x³y³. What is ∂²f/∂x∂y?

f

f = x²y³. Is ∂²f/∂x∂y equal to ∂²f/∂y∂x?

How does the chain rule work here?

When x and y both depend on t, z = f(x, y) changes for two reasons at once, and dz/dt adds one term per variable: the partial derivative of z with respect to it, times its rate of change. For z = xy with x = t² and y = 3t, ∂z/∂x = y and ∂z/∂y = x, while the rates are 2t and 3, so dz/dt = 2ty + 3x. At t = 1, where x = 1 and y = 3, that is 2 × 3 + 3 × 1 = 9. Over a short time each variable raises z by its own slope times its own step, and small rises add. If x and y each depend on s and t, then ∂z/∂s and ∂z/∂t each get one term through x and one through y. With one variable the formula is the ordinary chain rule. Substituting first agrees: z = 3t³ differentiates to 9t², and 9 × 1 = 9.

∇fvdz/dt = fx ẋ + fy ẏ = (3.3)(−1.1) + (0.8)(1.2) = −2.68t = 0.6

dz/dt = fx ẋ + fy ẏ = −3.73 + 1.05 = −2.68: the climb is the east slope times the east speed plus the north slope times the north speed

Park the walker where the path runs along a contour

dz/dt = (∂z/∂x)(dx/dt) + (∂z/∂y)(dy/dt).

via x
via y
Add one term per variable: the partial derivative of z, times how fast that variable changes. Full lesson: The Chain Rule for Partial Derivatives

Draw the dependence as a tree, multiply along each branch, then add the branches. See The chain rule for partial derivatives.

Now you

what does this come to?

Each term multiplies ∂z/∂x by

what does this come to?

dz/dt =

What is the gradient vector?

The gradient vector ∇f has the two partial derivatives as its components, ∇f = (∂f/∂x, ∂f/∂y); it points in the direction of steepest ascent, and its length is the slope that way. For x² + y², ∇f = (2x, 2y), so at (3, 4) it is (6, 8), pointing straight up the side of the bowl, with length 10, because 36 + 64 = 100. The slope along a unit vector u is ∇f · u, which is |∇f| cos θ for the angle θ between them. That is largest at θ = 0, so the gradient is the steepest way up, and it is 0 at a right angle, so the gradient crosses each level curve square on, here the circle of radius 5. A zero gradient means the surface is level, with no steepest direction. Along the unit vector (3/5, 4/5) the slope is 6 × 3/5 + 8 × 4/5 = 10, the full length. See The gradient vector.

∇fDu f = 0.12|∇f| = 2.6P = (1.2, 1), ∇f = (2.4, 1), φ = 87°

Du f = ∇f · u = |∇f| cos φ = 2.6 × 0.05 = 0.12: the slope in the direction u is the gradient's length scaled by the cosine of the angle between them

Turn u along the contour until Du f = 0

4812∇f
That gradient vector points in the steepest uphill direction from where you stand. Full lesson: The Gradient Vector

This slope in a chosen direction is the directional derivative. See Directional derivatives.

4812∇fu0
At right angles to the gradient the slope is zero — that is why contours are level. Full lesson: Directional Derivatives

The flat plane that rests on a surface at a point is the tangent plane. The two partial derivatives give its tilt in the x and y directions, and that fixes it. See Tangent planes.

A surface is approximated near a point by a flat plane resting on it. Full lesson: Tangent Planes

Now you

4812∇fu∇f · u

∇f = (10, 5) and the unit step u = (0.6, 0.8). What is the slope along u?

4812∇fu∇f · u

∇f = (5, 20) and the unit step u = (0.8, 0.6). What is the slope along u?

How do you find maxima and minima on a surface?

At a maximum or minimum of a smooth surface, both partial derivatives are 0, so solve them together and then classify each point. For f = x² + 2y² − 4x + 4y, the partial derivatives 2x − 4 and 4y + 4 are both 0 only at (2, −1), where the height is 4 + 2 − 8 − 4 = −6. To classify, multiply the second derivatives in x and in y and subtract the square of the mixed one: 2 × 4 − 0 = 8, positive, and the x one is positive, so this is a minimum. A peak or a dip has a flat tangent plane, so both slopes vanish there. A negative result means a saddle: for x² − y² at the origin it is 2 × (−2) − 0 = −4, rising one way and falling the other. Completing the square confirms it: f is (x − 2)² + 2(y + 1)² − 6, never below −6.

xyρzθ = 20°

the slice at 20° is z = (cos 2θ) ρ² = 0.77 ρ²: a bowl while cos 2θ > 0, a dome while cos 2θ < 0, and the change of sign happens at 45°

Turn the cut until the slice is flat

Level means level in both directions at once, so both partial derivatives must be zero. Full lesson: Stationary Points of a Surface

Because a saddle is possible, the second-derivative test in two variables uses all three second partial derivatives. See Stationary points of a surface.

a saddleflat as well, and neither of the twoup one way, down the other
A saddle is level too, yet it rises one way and falls the other: neither a maximum nor a minimum. Full lesson: Stationary Points of a Surface
What the test showsWhat the point is
Curving up in every directionLocal minimum
Curving down in every directionLocal maximum
Up one way, down anotherSaddle point

Now you

xy

A surface is stationary where

xy

Rising in x and falling in y at a level point is a

What if the variables are constrained?

Under a constraint g(x, y) = 0, Lagrange multipliers find the largest or smallest value of f along that curve: set ∇f = λ∇g and solve the component equations together with the constraint. To maximize xy on the line x + y = 10, take g = x + y − 10. Then ∇f = (y, x) and ∇g = (1, 1), so y = λ and x = λ, which forces x = y = 5 and a maximum of 5 × 5 = 25. If ∇f crossed the curve at an angle, a step along the curve would still raise f, so at the best point the gradients are parallel. The multiplier means something too: λ = 5 is the rate at which the maximum grows as the 10 is raised. With two constraints each gets its own multiplier. Other points on the line give less, since 4 × 6 = 24 and 3 × 7 = 21.

∇f∇gx + 2y = 1two crossings

x + 2y = 1 cuts the ellipse twice: walk along the ellipse between the crossings and x + 2y rises above 1, so neither crossing is the maximum

Slide the line up until it only just touches the ellipse

g = k
Find the smallest value of f, but only along a fixed path — a constraint. Full lesson: Lagrange Multipliers

Solve the component equations for x and y in terms of λ first, then substitute into the constraint. See Lagrange multipliers.

g = k∇f∇g
So at the best point the two gradients must be parallel, differing only by a multiplier λ. Full lesson: Lagrange Multipliers

How do you integrate over a surface?

Integrating over a region of the plane means integrating twice, once in each variable, and gives the volume under the surface. Hold y constant and integrate in x to get the area of a cross-section, then integrate those areas in y. For xy over the rectangle with x from 0 to 2 and y from 0 to 3, the inner integral is x²y/2, which is 2y between the limits, and the outer integral of 2y is y², which comes to 9. The volume is built from thin slices, each a cross-sectional area times a small thickness, just as an area is built from strips. A region that is not a rectangle changes the limits: over the triangle under y = x, the inner integral in y runs from 0 up to x. This rectangle's integral also splits into a product, because xy is x times y, and 2 × 9/2 = 9.

one slice
Under a curve the slices made an area. Under a surface the slices make a volume. Full lesson: The Volume Under a Surface

In symbols, A(y) = ∫ f(x, y) dx and V = ∫ A(y) dy. See The volume under a surface.

stack the slice areas along y
an integral of integrals
Stack the slice areas along y: V = ∫ A(y) dy — an integral of integrals, two ∫ signs. Full lesson: The Volume Under a Surface

The mistakes worth naming

The single-variable rules that carry over are in the rules of differentiation, the optimization ideas are in applications of differentiation, and the vector language is in vectors. Related guides: Applications of Integration and Polar Curves.

Your turn

Three to try — tap what you get.

∂/∂x of x²y

∂/∂y of x²y

Taking ∂f/∂x, you treat y as

Questions and answers

What is a partial derivative?
It is the rate of change of a function of several variables with respect to one of them, holding the others fixed. On a surface it is the slope you would measure walking due east, or due north, but not diagonally. The curly symbol is used instead of the ordinary d precisely to signal that other variables exist and are being deliberately held still.
How do you compute a partial derivative?
Differentiate with respect to your chosen variable and treat every other variable as a constant. If the function is x squared y plus y cubed, then differentiating with respect to x gives 2xy, because y is just a number for the purpose of that calculation, and the y cubed term disappears entirely. No new rules are needed — only the discipline of holding the rest still.
What does the gradient vector tell you?
It points in the direction of steepest ascent, and its length is how steep that ascent is. Its components are the partial derivatives, so it packages both slopes into a single object. It is also always perpendicular to the level curve through that point, which is why water runs downhill at right angles to the contour lines on a map.
Why are mixed partial derivatives equal?
For any function whose second derivatives are continuous, differentiating with respect to x then y gives the same result as y then x. The order does not matter. This is the mixed derivative theorem, and it is a genuine theorem rather than an obvious fact — it can fail for artificially constructed functions, but never for the ones that arise in practice.
What is a saddle point?
It is a point where both partial derivatives are zero but the surface is neither a peak nor a pit — it rises in one direction and falls in another, like a mountain pass or a horse's saddle. Saddle points have no equivalent in single-variable calculus, which is why a stationary point on a surface needs a second-derivative test to classify rather than simply being a maximum or minimum.
What is a Lagrange multiplier?
It is the method for optimizing a function when the variables must satisfy a constraint. At the best point on the constraint, the gradient of the function is parallel to the gradient of the constraint, so you set one equal to a multiple of the other and solve alongside the constraint. The multiplier itself has a meaning: it measures how much the optimum would improve if the constraint were relaxed slightly.
Mr. Chalk