The slope of a slice
Lesson 4.1.1 cut the bowl into slices. Fix and the slice is , a function of alone, so it has a slope. That slope is a partial derivative: the rate at which changes as moves, with held fixed.
Take the point , where . Move by a gap and keep at 1. Then do the same in the other direction: keep at 1 and move .
| gap | |||
|---|---|---|---|
| chord slope, moving | 2.1, 1.9 | 2.01, 1.99 | 2.001, 1.999 |
| chord slope, moving | 4.2, 3.8 | 4.02, 3.98 | 4.002, 3.998 |
From both sides the first row settles on 2 and the second on 4. So at the surface rises twice as fast in the direction as in the direction.
The algebra agrees. With fixed, the chord slope is , which tends to 2. With fixed, it is , which tends to 4.
Rule: Partial derivatives
Lesson 2.2.2's derivative, taken along one input while the other stays fixed. is the slope of the slice at ; is the slope of the slice at .
The two slices of through , with their tangents at the point. The slope of each tangent is a partial derivative: 2 in the direction, 4 in the direction.
Try it on the explorer. The point starts at (2, 1) on the bowl , where the slice along has slope 4. Slide the point along the dashed line and watch the slope change; then slice along instead, and try the other functions.
Explore
Hold y fixed and f becomes a function of x alone: a slice through the surface, graphed below. Its slope at the point is the partial derivative ∂f/∂x. Move the point, or slice along y instead to read ∂f/∂y.
The slice y = 1: f(x, 1) against x, with its tangent at the point
- Point
- (2, 1), f = 6
- Partial derivatives
- ∂f/∂x = 4 (the slope of the slice along x), ∂f/∂y = 4 (along y)
Notation
The curly is read "partial", so is "partial f by partial x". It replaces the of to warn that has other inputs, held fixed. A shorter name is , with the input that moves written below.
Both name a new function of and . For the bowl, and at every point. At one point, write , giving both coordinates.
Try it
The cell repeats the table: chord slopes at from both sides. First moves with fixed at 1, then the other way round.
round(…, 6) hides rounding noise in the last digits.
The rules of Level 2 still work
To find , treat as a fixed number, such as 5, and differentiate in by the usual rules. To find , do the reverse. Nothing new is needed.
A polynomial. Take . In the is a constant factor, so its -derivative is (lesson 2.3.1). The term does not contain at all, so it is a constant and its -derivative is 0.
In , the is a constant factor of , which has slope 1. At the function is 7, with and .
The chain rule. For , the inside is . Its slope in is , so (lessons 2.3.3 and 2.3.4).
In the same way . At : and .
The quotient rule, or a power. For , the is a constant factor in , so . In , write : then . At : and .
Rule: Computing a partial derivative
Then use the rules of lessons 2.3.1 to 2.3.5. A term without the moving variable has derivative 0; a factor without it stays as a factor.
Try it
sp.diff(f, x) is the partial derivative in : SymPy holds every other symbol fixed. Each first line prints , , , and the exact values of and at the point.
SymPy keeps exact as exp(2). The second line gives , and at the point as decimals.
Signs, units and where it breaks
The sign of says what happens when grows and stays put. Positive means rises, negative means it falls, and zero means the slice is flat there. The other partial can tell a different story at the same point.
For the saddle of lesson 4.1.1, and . At , and : uphill along , downhill along . At both are 0, and for the plane they are and everywhere.
Units
A partial derivative is in output units per unit of the input that moves. A tin can of radius cm and height cm holds cm³. Then is in cm³ per cm of radius, and in cm³ per cm of height.
For and , cm³, and . Widening the can is far more effective than making it taller: per centimetre, more than six times as many cm³.
Each partial gives a tangent estimate in its own direction, as in lesson 2.2.1. With fixed at 10, widening by 0.1 adds about cm³; the true gain is 19.16. With fixed at 3, adding 0.1 to adds 2.83 cm³, exactly, because is a straight line in .
Where a partial derivative does not exist
A partial derivative is a one-variable derivative, so it fails where lesson 2.2.2's did. Take at .
With fixed, the slice has a corner at 0. Its chord slopes are 1 from the right and from the left, so does not exist there.
The other slice is smooth. With fixed, the slice is , so at . One partial can exist where the other does not.
Try it
The tin can's volume and its two partials. Then the tangent estimate for widening it by 0.1 cm, and the true gains from widening and from raising it by 0.1 cm.
The last loop takes chord slopes of at : in from both sides, and in .
Second partial derivatives
and are functions of and too, so each has two partial derivatives of its own. That gives four second partial derivatives:
is the second derivative of the slice in : it measures how that slice bends (lesson 2.4.2). For the bowl, and , so the slices in bend twice as sharply.
The mixed partials and are new. says how the slope in changes as moves.
A worked example
Take again, with . At that slope is . Read it off three slices:
| slice | |||
|---|---|---|---|
| as a function of | 0 | ||
| its slope at , | 0 | 4 | 8 |
Each step of 1 in adds 4 to the slope. So . Differentiating in gives the same: , which is 4 at .
The slope in at grows as grows: 0, 4 and 8 on the slices , 1 and 2. Its rate of growth, 4 per unit of , is the mixed partial derivative.
Now go the other way: , and its -derivative is . The two mixed partials agree. The rest: and , so at they are 2 and 6.
Rule: Mixed partials agree
The order of differentiation does not matter when the second partials are continuous, which holds for every function in this course. This lesson states it; the Proof Gym proves it.
So a function of two variables has only three different second partials: , and . Lesson 4.3.1 puts them in a symmetric matrix, the Hessian .
Two notations need care. is read left to right: first , then .
The same thing written with is , read right to left. Since the two agree, the order rarely changes an answer.
Try it
sp.diff(f, x, 2) is , and sp.diff(f, x, y) differentiates in , then in . Each line prints , , whether simplifies to 0, and .
The last line is the table's slope at , 1 and 2.
For the bowl the mixed partial is 0: its slope in , , does not depend on . For it is 1, since the slice has slope .
Estimating partials by central differences
When is a program rather than a formula, estimate each partial by lesson 2.8.1's central difference. Move one input up and down by , and keep the other exactly where it was.
Rule: Central differences in two variables
and are the same with moving. In the last line means , and so on. It is the central difference in of the central difference in , from four corner points.
For at the true values are and .
| step | 0.1 | 0.01 | 0.001 |
|---|---|---|---|
| estimate of | 14.87683 | 14.779097 | 14.778122 |
| its error | |||
| estimate of | 22.477557 | 22.170247 | 22.167199 |
| its error |
Both errors shrink like : ten times smaller , a hundred times smaller error. The first matches lesson 2.8.1's , with here.
Rounding sets a floor, as in lesson 2.8.1. For a first partial a step near times the scale of the input works well, and for second partials near . With the mixed estimate is ruined by rounding.
Try it
central_x and mixed are the first and last formulas of the rule. Each line of the loop prints the step, the two estimates and their errors.
The last line checks the step sizes: gets within , and misses by more than 0.001.
Three or more variables
Nothing changes with more inputs: to differentiate in one, hold all the others fixed. A box with sides , and cm has volume cm³, with
For a box of cm, and the partials are 12, 8 and 6 cm³ per cm. The shortest side gives the most: adding 0.1 cm to adds exactly cm³, since is a straight line in .
There are now nine second partials: three on the diagonal, such as , and three equal pairs, such as . For the box they are 4, 3 and 2 off the diagonal, and .
Try it
The three partials of at , then the table of all nine second partials. Row , column holds the derivative in the -th variable, then the -th. The table is symmetric.
The last line is the gain from adding 0.1 cm to .
Case study 4.1.4 treats an option's value as a function of the stock price, the volatility and time. Its sensitivities are partial derivatives. Lesson 4.2.1 puts the first partials together into one vector, the gradient.
Common mistakes
- The fixed variable is a number, not a variable. . Using the product rule as if moved gives an extra term that does not belong.
- A term without the moving variable vanishes; a factor stays. , but .
- A value needs both coordinates. For the bowl does not involve , but the point is still , where and .
- Units are per unit of the moving input. for the can is in cm³ per cm of radius.
- One partial can exist where another does not. For at , but does not exist.
- Mind the order in the notation. means first; means the same.
- In a central difference, move only one input, and keep the other exactly fixed. A mixed partial needs four corner points.
Partial derivatives
0 of 13 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Summary card
- , or , is the derivative in with held fixed: the slope of the slice . Likewise . Units: output per unit of the moving input.
- Compute it with the rules of Level 2, treating the other variable as a constant. Its sign says whether rises as that input grows.
- A partial derivative fails where a one-variable derivative does, such as at a corner; one partial can exist while another does not.
- Second partials: and measure the bend of slices; is how the -slope changes with . For the functions of this course, .
- Central differences estimate partials: move one input by , keep the others fixed. The mixed partial uses four corner points. Errors shrink like until rounding takes over.
- With three or more variables, hold all the others fixed.