Foundations to Frontier
Tests
A. Mathematical Foundations › A3 Calculus and Analysis › Multivariable calculus

Multivariate Taylor Expansion (First and Second Order)

Near any point, a smooth function of many variables looks like a tilted plane (first order) or a curved bowl (second order). These models are what gradient descent, Newton's method, Gauss–Newton, trust regions and the extended Kalman filter actually optimize and propagate.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Flat boards and curved bowls

Stand anywhere on a rolling hill. Right around your feet, the ground looks almost like a tilted flat board. That’s a good-enough description for one small step. For a bigger step, a curved bowl or saddle shaped to match the hill fits much better. Farther away, both descriptions break down.

These simple shapes are Taylor models.

Where can you trust a Taylor model? (click to move the expansion point)
area where the tangent plane T₁ is within τ: 0.679 · where the quadratic model T₂ is within τ: 1.816
Blue = both models accurate; green = only the second-order model; grey (rare) = only the tangent plane. The T₂ region is larger because its error is O(‖h‖³) instead of O(‖h‖²). Trust-region optimizers keep each step inside such a region.
Why engineers care

A spacecraft’s navigation filter can’t track the exact, curved physics of every uncertainty. It replaces the physics with flat-board (first-order) approximations around its current best guess, and updates them every fraction of a second. Optimizers that plan robot motions do the same with curved-bowl (second-order) approximations.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Very close to where you stand, a smooth hill looks almost…
  2. 2. Which matches the hill over a bigger area?
  3. 3. Far from the point, both approximations get…

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

The first-order model (the tangent plane)

f(p+h)≈f(p)+∇f(p)⋅hf(\mathbf p + \mathbf h)\approx f(\mathbf p) + \nabla f(\mathbf p)\cdot\mathbf h

Example. For f=x2+y2f = x^2 + y^2 at (1,2)(1,2): f=5f = 5 and ∇f=(2,4)\nabla f = (2,4), so z≈5+2(x−1)+4(y−2)z\approx5 + 2(x-1) + 4(y-2). At (1.1,2.1)(1.1, 2.1) the plane gives 5.65.6, while the true value is 5.625.62. The error is ∥h∥2=0.02\lVert\mathbf h\rVert^2 = 0.02.

The second-order model

f(p+h)≈f(p)+∇f(p)⋅h+12h⊤H(p)hf(\mathbf p + \mathbf h)\approx f(\mathbf p) + \nabla f(\mathbf p)\cdot\mathbf h + \tfrac12\mathbf h^\top H(\mathbf p)\mathbf h

Example. excos⁡ye^x\cos y at the origin has ∇f=(1,0)\nabla f = (1,0) and H=(100−1)H = \begin{pmatrix}1&0\\0&-1\end{pmatrix}, so the model is 1+x+12(x2−y2)1 + x + \tfrac12(x^2 - y^2). At (0.1,0.2)(0.1, 0.2): 1.085, against the true 1.0831.

📝 Quick check (Level 1)
0/3 answered
  1. 1. The tangent plane of x² + y² at (1, 2), evaluated at (1.1, 2.1)?
  2. 2. The first-order model of e^(x+y) at 0, evaluated at (0.1, 0.1)?
  3. 3. The second-order model adds which term?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

How good are the models?

For smooth ff:

  • the first-order error is O(∥h∥2)O(\lVert\mathbf h\rVert^2), so halving h\mathbf h quarters it;
  • the second-order error is O(∥h∥3)O(\lVert\mathbf h\rVert^3), so halving h\mathbf h divides it by 8.

The demo shows the consequence. The region where the quadratic model is accurate is much larger.

Optimization = minimizing a Taylor model

Method Model it minimizes Step
gradient descent f+∇f⋅h+12η∥h∥2f + \nabla f\cdot\mathbf h + \frac1{2\eta}\lVert\mathbf h\rVert^2 −η∇f-\eta\nabla f
Newton f+∇f⋅h+12h⊤Hhf + \nabla f\cdot\mathbf h + \frac12\mathbf h^\top H\mathbf h −H−1∇f-H^{-1}\nabla f
Gauss–Newton (least squares 12∥r∥2\tfrac12\lVert\mathbf r\rVert^2) same, with H≈J⊤JH\approx J^\top J −(J⊤J)−1J⊤r-(J^\top J)^{-1}J^\top\mathbf r
Levenberg–Marquardt / trust region the model, but keep ∥h∥\lVert\mathbf h\rVert small −(H+λI)−1∇f-(H + \lambda I)^{-1}\nabla f

Newton’s method is exact in one step on a quadratic. On Rosenbrock’s banana, a damped Newton method needs about 20 iterations where steepest descent needs about 19,000 (Exercise 2).

🐍 Exercise 1: error orders of Taylor models
Build the first- and second-order models of eˣ cos y + xy² at a point, and measure the error ratios as h halves: about 4 and about 8.
📝 Quick check (Level 2)
0/3 answered
  1. 1. ½hᵀHh for H = diag(2, 4), h = (1, 1)?
  2. 2. Halving h divides the second-order error by about…
  3. 3. Gauss–Newton replaces the Hessian with…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Proof by reducing to one variable

Let g(t)=f(p+th)g(t) = f(\mathbf p + t\mathbf h). By the chain rule (A3.2-4), g′(0)=∇f⋅hg'(0) = \nabla f\cdot\mathbf h and g′′(t)=h⊤H(p+th)hg''(t) = \mathbf h^\top H(\mathbf p + t\mathbf h)\mathbf h. One-variable Taylor with the Lagrange remainder (A3.1-10) gives g(1)=g(0)+g′(0)+12g′′(θ)g(1) = g(0) + g'(0) + \tfrac12g''(\theta). So

f(p+h)=f(p)+∇f(p)⋅h+12h⊤H(p+θh)h,θ∈(0,1)f(\mathbf p + \mathbf h) = f(\mathbf p) + \nabla f(\mathbf p)\cdot\mathbf h + \tfrac12\mathbf h^\top H(\mathbf p + \theta\mathbf h)\mathbf h, \quad \theta\in(0,1)

If HH is Lipschitz near p\mathbf p, replacing H(p+θh)H(\mathbf p + \theta\mathbf h) with H(p)H(\mathbf p) costs O(∥h∥3)O(\lVert\mathbf h\rVert^3). ∎

Consequences

  • The descent lemma in nn dimensions. If ∥H∥2≤L\lVert H\rVert_2\le L everywhere, then f(y)≤f(x)+∇f⋅(y−x)+L2∥y−x∥2f(\mathbf y)\le f(\mathbf x) + \nabla f\cdot(\mathbf y - \mathbf x) + \frac L2\lVert\mathbf y - \mathbf x\rVert^2 (A3.1-4). This is the basis of every η=1/L\eta = 1/L convergence proof.
  • Quadratics are their own Taylor model, so Newton solves them exactly in one step.
  • Second-order optimality (A3.2-6) is read off the quadratic term at a critical point.
Exercise 3.1: Write the second-order Taylor model of cos x cos y at the origin

∇f=(0,0)\nabla f = (0,0) and H=−IH = -I, so the model is 1−12(x2+y2)1 - \tfrac12(x^2 + y^2), a dome. At (0.1,0.1)(0.1, 0.1) it gives 0.99, against the true 0.99003.

📝 Quick check (Level 3)
0/3 answered
  1. 1. g(t) = f(p + th): g″(0) = ?
  2. 2. The quadratic model is exact for polynomials of degree at most…
  3. 3. hᵀHh for H = [[1, 2], [2, 3]] and h = (1, 1)?

Level 4: Expert

★★★★★ Expert⏱ 45 minResearchers: original papers and open problems.

Newton vs gradient descent on a banana

🐍 Exercise 2 (research): steepest descent vs damped Newton on Rosenbrock
From (−1.2, 1), minimize the Rosenbrock function with steepest descent and with damped Newton (minimize the quadratic model, then backtrack). Count the iterations to ‖∇f‖ < 10⁻⁸.

Taylor models in robotics and ML

  • Extended Kalman filter. Uncertainty is propagated through dynamics and sensor models with first-order Taylor: Σ′=JΣJ⊤\Sigma' = J\Sigma J^\top. It is accurate for small noise and biased for large noise. For example, range–bearing sensors produce banana-shaped clouds (Practice Code 4; Thrun, Burgard and Fox, 2005). The unscented transform matches more moments.
  • Gauss–Newton and Levenberg–Marquardt (Levenberg, 1944; Marquardt, 1963) are the solvers behind camera calibration, bundle adjustment (Triggs et al., 2000) and factor-graph SLAM (g2o, GTSAM, Ceres).
  • Trust-region policy optimization. TRPO limits each policy update using a second-order Taylor expansion of the KL divergence, whose Hessian is the Fisher matrix, solved with CG (A2.4-7; Schulman et al., 2015).
  • Influence functions and model analysis. A second-order expansion of the training loss predicts how removing a training point changes the model (Koh and Liang, 2017).

References

  1. K. Levenberg (1944). “A method for the solution of certain non-linear problems in least squares.” Quarterly of Applied Mathematics, 2.
  2. D. Marquardt (1963). “An algorithm for least-squares estimation of nonlinear parameters.” SIAM Journal on Applied Mathematics, 11(2).
  3. H. Rosenbrock (1960). “An automatic method for finding the greatest or least value of a function.” The Computer Journal, 3(3).
  4. B. Triggs, P. McLauchlan, R. Hartley, A. Fitzgibbon (2000). “Bundle adjustment — a modern synthesis.” Vision Algorithms: Theory and Practice, Springer.
  5. S. Thrun, W. Burgard, D. Fox (2005). Probabilistic Robotics. MIT Press. Chapter 3.
  6. J. Nocedal, S. Wright (2006). Numerical Optimization, 2nd ed. Springer. Chapters 2–4, 10.
  7. J. Schulman, S. Levine, P. Moritz, M. Jordan, P. Abbeel (2015). “Trust region policy optimization.” ICML.
  8. P. W. Koh, P. Liang (2017). “Understanding black-box predictions via influence functions.” ICML.