Chapter 10: Calculus 3
Multivariable calculus generalizes the single-variable ideas of derivative and integral to functions of several variables. The gradient replaces the derivative, multiple integrals replace single integrals, and the classical theorems of Green, Stokes, and Gauss reveal that integration over a region and integration over its boundary are deeply related. For computing, the payoff is direct: the gradient is the engine of optimization (gradient descent), the Jacobian is the engine of backpropagation, and multiple integrals compute joint probabilities.
Concepts from other sections (24)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- Jacobian: the matrix of partial derivatives of a function . Read more: 10.2 Jacobians, the multivariable chain rule, and numeric JVP/VJP
- Backpropagation: reverse-mode automatic differentiation that computes all parameter gradients in one backward pass. Read more: Chapter 2: Deep Learning in AI Engineering
- Partial derivative: the ordinary derivative of along one coordinate with every other coordinate frozen. Read more: 10.1 Partial derivatives, gradients, and gradcheck
- Vector-Jacobian product (VJP): , one step of reverse-mode differentiation. Read more: 10.3 Calculus 3 problem set: vectors, gradients, the chain rule, Hessians, multiple integrals, Lagrange
- Reverse mode: automatic differentiation that records the computation and walks it backward once from the output, pushing adjoints into inputs. Read more: 14.2 Scalar reverse mode: the Value graph
- Chain rule: . Read more: 10.2 Jacobians, the multivariable chain rule, and numeric JVP/VJP
- Directional derivative: , the rate of change of along a unit vector . Read more: 10.3 Calculus 3 problem set: vectors, gradients, the chain rule, Hessians, multiple integrals, Lagrange
- Hessian: the symmetric matrix of second partial derivatives, whose eigenvalues classify a critical point. Read more: 10.3 Calculus 3 problem set: vectors, gradients, the chain rule, Hessians, multiple integrals, Lagrange
- Lagrange multiplier: the scalar in at a constrained optimum. Read more: 10.3 Calculus 3 problem set: vectors, gradients, the chain rule, Hessians, multiple integrals, Lagrange
- Numerical gradient: an approximation of the gradient by one central difference per element, costing evaluations of . Read more: 10.1 Partial derivatives, gradients, and gradcheck
- JVP (Jacobian-vector product): , the rate of change of the output along ; what forward mode computes. Read more: 10.2 Jacobians, the multivariable chain rule, and numeric JVP/VJP
- VJP (vector-Jacobian product): , the gradient of ; what reverse mode computes. Read more: 10.2 Jacobians, the multivariable chain rule, and numeric JVP/VJP
- critical point: a point where , a candidate for an interior optimum. Read more: 7.5 Calculus 1 Problem Set
- Taylor series: the power series built from the derivatives of at ; truncating it gives the polynomials that libraries use to compute , , and . Read more: Chapter 8: Calculus 2
- Row-major layout: storage in which each row of a matrix is contiguous in memory. Read more: 9.1 Vectors, matrices, row-major layout, and matmul
- central difference: , a second-order approximation of . Read more: 7.1 Derivatives and Finite Differences
- Determinant: a single number for a square matrix: the factor by which scales signed volume. It is zero exactly when squashes space flat and so cannot be inverted, and . Read more: Chapter 9: Linear Algebra
- Arc length: the length of a curve, for , or for a parametric curve: the integral of speed. Read more: Chapter 8: Calculus 2
- Rate of change: how much the output changes per unit change in the input; for it is 4 per person. Read more: Chapter 2: Change and growth
- Polar coordinates: describing a point by its distance from the origin and angle , with and ; a polar curve sweeps area . Read more: Chapter 8: Calculus 2
- fundamental theorem of calculus: if , then . Read more: 7.4 Definite Integrals: Trapezoid and Simpson
- Unit circle: the circle of radius 1 about the origin; the point at angle is . Read more: 6.2 Trigonometry, rotations, complex numbers, and Euler’s formula
- Regularization: penalizing model complexity to trade bias for lower variance. Read more: Chapter 1: Statistical Learning in AI Engineering
- Expected value: the average outcome across many repetitions of a situation under the model. Read more: Chapter 4: Uncertainty and evidence
This chapter has two parts. Its two build sections turn partial derivatives and Jacobians into code that later chapters depend on: a gradient checker that referees every backward rule you will ever write, and numeric oracles for the Jacobian-vector and vector-Jacobian products that forward and reverse mode compute. Its problem set then works the hand computations behind the rest of the subject: vectors and geometry, gradients, the chain rule, directional derivatives, Hessians, multiple integrals, and Lagrange multipliers. The survey below the section list covers the wider territory of a Calculus 3 course, including vector-valued functions and vector calculus, with a worked example for each topic.
Learning objectives
- Compute partial derivatives, gradients, and directional derivatives, and explain why is the direction of steepest descent.
- Build and use a numerical gradient check with a mixed absolute and relative tolerance.
- Form Jacobians, apply the multivariable chain rule as a matrix product, and compute JVPs and VJPs without forming the matrix.
- Classify critical points with the Hessian, and solve constrained problems with Lagrange multipliers.
- Evaluate double and triple integrals with a change of variables, and state Green’s, Stokes’, and the Divergence theorems.
Before you begin
Section titled “Before you begin”You should be comfortable with one-variable derivatives and finite differences from Calculus 1, especially Derivatives and Finite Differences, whose central_diff the first section calls; with Taylor series from Calculus 2; and with matrices, row-major layout, and matrix products from Linear Algebra, especially Vectors, matrices, row-major layout, and matmul.
In this chapter
Section titled “In this chapter”- Partial derivatives, gradients, and gradcheck: builds the gradient of a scalar function of several arrays from one central difference per element, and a
gradcheckthat rejects real backward-pass bugs and points at the element furthest past its tolerance. - Jacobians, the multivariable chain rule, and numeric JVP/VJP: defines the Jacobian and the chain rule as a matrix product, and builds numeric oracles for and that the autodiff chapter checks against.
- Calculus 3 problem set: 58 problems with worked answers on vectors, gradients, the chain rule, directional derivatives, Hessians, multiple integrals, and Lagrange multipliers. It is the book’s treatment of the Hessian, multiple integrals, and Lagrange multipliers.
A survey of the subject
Section titled “A survey of the subject”The sections above focus on the parts of multivariable calculus that code depends on. The rest of this opening surveys the whole subject, following Calculus Volume 3 from OpenStax, so you can see where those parts sit. Each topic gives the key definitions and theorems, a worked example, and the textbook exercises to practice on.
Vectors in space
Section titled “Vectors in space”Textbook chapter 2, sections 2.1 to 2.5. The dot product is . It measures how much two vectors point in the same direction; zero means perpendicular. The cross product is
perpendicular to both and , with magnitude , the area of the parallelogram they span. So the cross product encodes both a direction (normal to the plane of and ) and a magnitude (area). The triple scalar product is the signed volume of the parallelepiped: determinants measure volume, and the triple product is exactly a determinant.
A line in space is , a point plus a direction. A plane is , or where is the normal vector.
For example, find the plane through , , and . Two vectors in the plane are and . The normal is
which simplifies to . The plane is , or .
Practice: OpenStax 2.3 exercises 123 to 135, 2.4 exercises 161 to 175, and 2.5 exercises 215 to 228; for a challenge, 2.5 exercises 237 to 242.
Vector-valued functions
Section titled “Vector-valued functions”Textbook chapter 3, sections 3.1 to 3.4. A vector-valued function describes a curve in space. Its derivative is the tangent vector, the arc length is , and the unit tangent is . Every smooth curve can be reparameterized by arc length so that everywhere: traveling at unit speed, the parameter directly measures distance along the curve.
Curvature measures how sharply a curve bends:
A straight line has ; a circle of radius has . For the helix : with , , and with . So : the helix has constant curvature .
Practice: OpenStax 3.2 exercises 60 to 72, 3.3 exercises 100 to 112, and 3.4 exercises 130 to 140; for a challenge, 3.4 exercises 145 to 150.
Partial derivatives
Section titled “Partial derivatives”Textbook chapter 4, sections 4.1 to 4.8. The partial derivative differentiates with respect to holding constant. The gradient points in the direction of steepest ascent, and the directional derivative is the rate of change in direction . The tangent plane at is . A critical point is where or is undefined, and the Hessian encodes second-order behavior.
Four results organize the topic. The multivariable chain rule: if with , , then ; each variable contributes its own rate of change, weighted by how the function responds to it. Clairaut’s theorem: if and are continuous, they are equal, so the order of mixed partials does not matter under mild smoothness. The second derivative test: at a critical point , let ; if and it is a local minimum, if and a local maximum, and if a saddle. is the determinant of the Hessian, and it checks whether the surface curves the same way in all directions. Lagrange multipliers: to optimize subject to , solve and . At a constrained extremum the gradient of must be parallel to the gradient of ; otherwise you could improve by moving along the constraint.
Two worked examples. First, minimize subject to . Lagrange gives , so and . The constraint gives , and the minimum is .
Second, classify the critical points of . Setting and , the first gives ; substituting, , so , giving and . At , , , , so with : a local minimum. At , : a saddle.
Practice: OpenStax 4.3 exercises 115 to 128, 4.5 exercises 200 to 215, 4.6 exercises 240 to 252, and 4.8 exercises 340 to 355; for a challenge, 4.8 exercises 360 to 368.
Multiple integrals
Section titled “Multiple integrals”Textbook chapter 5, sections 5.1 to 5.7. A double integral is computed as iterated integrals over and , and a triple integral likewise. Fubini’s theorem says that if is continuous on a rectangle , the double integral equals either iterated integral: you can slice horizontally or vertically and get the same answer.
Other coordinate systems simplify circular and spherical regions. Polar: , , . Cylindrical: with . Spherical: , , , . All are instances of the change of variables formula. For a transformation with Jacobian determinant , and
The Jacobian determinant measures how much the transformation stretches or compresses area, just as does in single-variable substitution.
For example, integrate over the disk . In polar coordinates,
Practice: OpenStax 5.1 exercises 1 to 14, 5.3 exercises 130 to 145, 5.5 exercises 240 to 255, and 5.7 exercises 340 to 352; for a challenge, 5.7 exercises 358 to 365.
Vector calculus
Section titled “Vector calculus”Textbook chapter 6, sections 6.1 to 6.8. A vector field is . The line integral of a scalar is , and the line integral of a vector field, the work done by along , is . A field is conservative if for some scalar potential . Curl, , measures local rotation; divergence, , measures local expansion. A surface integral is .
Four theorems relate integrals over a region to integrals over its boundary:
- Fundamental theorem for line integrals: if , then . For gradient fields, work depends only on the endpoints, not the path, just like the fundamental theorem of calculus.
- Green’s theorem: . The circulation around a closed curve equals the total curl inside.
- Stokes’ theorem: . It generalizes Green’s theorem to 3D: the circulation of around a closed curve equals the flux of the curl through any surface bounded by that curve.
- Divergence theorem: . The total outward flux through a closed surface equals the total divergence inside: what flows out must be produced within.
For example, use Green’s theorem to evaluate around the unit circle, counterclockwise. With and , , so the integral is . In polar coordinates this is , and since and each integrate to 0 over , the result is 0.
Practice: OpenStax 6.2 exercises 55 to 70, 6.3 exercises 115 to 130, 6.4 exercises 155 to 168, 6.7 exercises 285 to 298, and 6.8 exercises 325 to 338; for a challenge, 6.8 exercises 345 to 352.
Choosing a technique
Section titled “Choosing a technique”Most problems in the subject reduce to recognizing which tool applies. This table pairs each technique with when to reach for it:
| Technique | When to use | Key formula or idea |
|---|---|---|
| Gradient | find the direction of steepest ascent | |
| Lagrange multipliers | constrained optimization | |
| Second derivative test | classify critical points in 2D | check and |
| Polar, cylindrical, spherical coordinates | integrate over circular or spherical regions | include the Jacobian factor (, , ) |
| Green’s theorem | convert a line integral to a double integral (2D) | circulation = integral of curl over the region |
| Stokes’ theorem | convert a line integral to a surface integral (3D) | circulation = flux of curl |
| Divergence theorem | convert a surface integral to a volume integral | flux = integral of divergence |
| Change of variables | simplify the integration domain |
Key terms
Section titled “Key terms”- Dot product: ; it measures how much two vectors point the same way, and it is zero exactly when they are perpendicular.
- Cross product: for vectors in 3D, is perpendicular to both, with magnitude , the area of the parallelogram they span; it gives normals to planes.
- Vector-valued function: a function that traces a curve in space; its derivative is the tangent (velocity) vector, and is arc length.
- Tangent plane: the plane that best approximates the surface near a point, the two-variable analogue of the tangent line.
- Clairaut’s theorem: if the mixed partials and are continuous, they are equal, so the order of differentiation does not matter and the Hessian is symmetric.
- Second derivative test (two variables): at a critical point, , the determinant of the Hessian, gives a local minimum if and , a local maximum if and , and a saddle if .
- Fubini’s theorem: for continuous on a rectangle, the double integral equals either iterated integral, so you can integrate over first or first and get the same answer.
- Change of variables (multiple integrals): for a substitution , , where is the Jacobian determinant of ; it measures how stretches area, and it gives the in polar and the in spherical coordinates.
- Vector field: a function that assigns a vector to every point, such as a velocity or force field; the gradient of a scalar function is one.
- Line integral: an integral along a curve ; for a vector field, is the work done by along .
- Conservative vector field: a field that is the gradient of a scalar potential, ; its line integrals depend only on the endpoints, and its integral around any closed curve is zero.
- Fundamental theorem for line integrals: if , then for any path from to , the analogue of the fundamental theorem of calculus for gradient fields.
- Green’s theorem: ; the circulation around a closed plane curve equals the total curl inside the region it bounds.
- Stokes’ theorem: ; the circulation of around a closed curve equals the flux of its curl through any surface bounded by that curve, generalizing Green’s theorem to 3D.
- Divergence theorem: ; the outward flux through a closed surface equals the total divergence inside, so what flows out must be produced within.
Where this leads
Section titled “Where this leads”The gradient and directional derivative drive gradient descent in Optimization. The Jacobian is the chain rule for vector functions, which is backpropagation, and Matrix calculus and autodiff builds it three ways. Lagrange multipliers underlie constrained optimization such as SVMs and regularization, and the reading of softmax as a maximum-entropy distribution in Information theory. Multiple integrals compute joint probability distributions and expected values in Probability and statistics. The change of variables formula is the core of normalizing flows in generative models, and divergence and curl appear in physics simulation and fluid dynamics for games.
Further reading
Section titled “Further reading”- OpenStax, Calculus Volume 3 (CC BY-NC-SA 4.0), the textbook this chapter follows.
- Paul’s Online Math Notes, Calculus III, for additional worked examples and practice problems.