Marginal

Multivariable Calculus

Calculus in many dimensions, as used in machine learning and physics: gradients and directional derivatives, Jacobians and the chain rule, second-order Taylor expansions, big-O notation, multiple integrals and change of variables, the Gaussian integral, geometry of high dimensions, the implicit function theorem, Laplace's method, Stirling's formula, divergence and line integrals.

33 lessons in 4 units

Start your free trial14 days free. No card needed.
What you'll learn

33 lessons, one small step at a time

Each lesson states its goal, then works up to it in short steps with practice after each. A placement test at the start skips what you already know.

Differentiation

11 lessons
  1. The gradient vectorCompute partial derivatives and gradients of polynomial and other functions.
  2. Directional derivativesCompute directional derivatives with the gradient, and identify the directions in which a function rises, falls or stays level.
  3. Steepest ascentFind the steepest rate of increase and the direction of steepest descent, and take a gradient-descent step.
  4. Jacobian matricesBuild the Jacobian of a map with several outputs by stacking gradients, and find its shape.
  5. Linear approximationUse the Jacobian to approximate the change in a map's outputs, and write the tangent plane of a function of two variables.
  6. Jacobian determinantsCompute a Jacobian determinant, use it to scale small areas, and find where a map has a local inverse.
  7. Chain rule along pathsCompute the rate of change of a function along a path by adding up the chain-rule terms, and find the slope of a level curve.
  8. The multivariable chain ruleApply the chain rule to a one-parameter model, backpropagate through a two-layer model, and multiply Jacobians for compositions.
  9. Classifying critical pointsFind critical points, classify them with the Hessian in two variables, and classify them with Hessian eigenvalues in any dimension.
  10. Second-order Taylor expansionApproximate a function of several variables to first and to second order with its gradient and Hessian.
  11. Newton's methodTake Newton steps in one variable and in many, and compare Newton's speed and cost with gradient descent.

Integration

9 lessons
  1. Double integralsCompute double integrals over rectangles one variable at a time, switch the order of integration, and compute joint probabilities.
  2. Non-rectangular regionsIntegrate over triangles, and compute probabilities of events such as Y < aX as areas.
  3. Areas under linear mapsCompute how a linear map scales areas with its determinant, and change variables in an integral with it.
  4. Polar coordinatesDescribe points and regions in polar coordinates, and integrate with the area element r dr dθ.
  5. Densities under transformationsFind the density of a scaled variable and of a linear map of a random vector, and transform a normal vector to polar coordinates.
  6. The Gaussian integralEvaluate the Gaussian integral with polar coordinates, rescale it, and derive the constant of the normal density.
  7. Multivariate Gaussian integralsCompute the Gaussian integral of e−xᵀAx/2 for diagonal and for general positive definite A, and the normal constant in several dimensions.
  8. Volume of a d-ballCompute the volume of the unit ball in d dimensions by recursion and with the gamma function, and how volume scales with the radius.
  9. Geometry of high dimensionsCompute the share of a ball's volume near its surface and a ball's share of a cube, and explain why random directions are nearly orthogonal and lengths concentrate.

Asymptotics & Approximation

7 lessons
  1. Scaling of running timesCompute how polynomial, exponential and n log n running times scale with the size of the input.
  2. Big-O & little-o notationCompare functions with big-O and little-o as n grows and as h shrinks, and prove a big-O bound from the definition.
  3. The implicit function theoremFind the slope of an implicitly defined curve, and compute comparative statics with the implicit function theorem.
  4. Laplace's methodMeasure how e−nf concentrates around the minimum of f, and approximate its integral with Laplace's method.
  5. Laplace in many dimensionsApply Laplace's method in d dimensions, and derive the BIC penalty of about ½ ln n per parameter.
  6. Stirling's formulaApproximate log factorials and factorials with Stirling's formula.
  7. Counting with entropyApproximate binomial and multinomial counts with entropy, and explain why balanced arrangements dominate.

Vector Fields

6 lessons
  1. DivergenceCompute the divergence of linear and nonlinear vector fields, and interpret its sign.
  2. Flows & area changeTell from the divergence whether a flow expands or contracts areas, and compute how fast.
  3. Line integralsCompute the work of constant forces and line integrals along parametrized paths, and explain how direction and speed affect them.
  4. Conservative fieldsTest whether a field is conservative with the curl, and find its potential.
  5. Green's theoremCompute the circulation around a loop as the total curl inside with Green's theorem, compute areas from boundaries, and explain what the theorem implies.
  6. Potentials & workCompute the work of a conservative force from its potential, and apply energy conservation.
Sample lesson

The gradient vector

Goal: Compute partial derivatives and gradients of polynomial and other functions.

Profit depends on price and advertising; a neural network's loss depends on millions of weights. To know how such a function changes, we need its rate of change in every input at once. The gradient collects these rates into a single vector: the central object of multivariable calculus and of optimization.

We will compute partial derivatives and finish with gradients of other functions.

Step 1: Partial derivatives

A partial derivative is an ordinary derivative in one variable, taken with the other variables held fixed. The gradient stacks them into a vector:

∇f = (∂f/∂x₁, …, ∂f/∂xₙ)

For f = x² + 3xy, treat y as a constant to get ∂f/∂x = 2x + 3y, and treat x as a constant to get ∂f/∂y = 3x. So ∇f = (2x + 3y, 3x), which is (8, 3) at the point (1, 2). The gradient is itself a function: it takes a different value at each point.

Step 2: Gradients of other functions

Every rule of single-variable calculus applies to each variable in turn, with the other variables treated as constants. A constant factor stays: ∂(x²y)/∂x = 2xy, since y just multiplies x². A term without x vanishes: ∂(x + y³)/∂x = 1. For f = 2x³ + xy², the power rule gives ∂f/∂x = 6x² + y², and in y, where 2x³ is constant and x multiplies y², ∂f/∂y = 2xy. At (1, 3): ∂f/∂x = 6 + 9 = 15 and ∂f/∂y = 6.

In the app, each step ends with practice questions, new ones every time, and the lesson comes back later in spaced reviews.

Start Multivariable Calculus

Lessons that need something you haven't learned yet bring it in first, from any course.

Start your free trial14 days free. No card needed.