Recommended resources
The freely available resources this lesson will direct you to.
Hello! Let's continue our exploration of multivariate calculus for machine learning.
Introduction
In our last lesson, we defined the Hessian matrix as the multivariable generalization of the second derivative for a scalar-valued function. We saw that it is formally the Jacobian of the gradient and that it geometrically describes the local curvature of a function's surface.
Today, we will put the gradient and the Hessian to work together. This lesson's goal is to construct the second-order Taylor approximation of a multivariable function. Just as a single-variable function can be locally approximated by a parabola, a multivariable function can be locally approximated by a quadratic surface (a "paraboloid"). This approximation is one of the most important tools in continuous optimization, forming the basis for powerful algorithms and the analysis of a model's loss landscape.
From Single to Multivariable Taylor Approximations
Recall the second-order Taylor approximation for a single-variable function around a point :
This formula approximates near using a simple quadratic polynomial whose value, first derivative, and second derivative all match those of at point .
Our goal is to find the equivalent formula for a multivariable function around a point . The structure is analogous, but we replace the scalar derivatives with their multivariable counterparts:
- The first derivative becomes the gradient .
- The second derivative becomes the Hessian matrix .
The resulting approximation involves a constant term, a linear term based on the gradient, and a quadratic term based on the Hessian.
Building the Approximation: Intuition and Formulation
Let's begin by developing a visual and conceptual understanding of how these pieces fit together.
M4ML - Multivariate Calculus - 4.8 Multivariate Taylor
This video from Imperial College London provides an excellent visual demonstration of how a function's Taylor approximation is built up layer by layer, from a constant value (0th order), to a tilted plane (1st order), to a quadratic surface (2nd order).
Please watch from 01:29 to 06:25. As you watch, focus on two key aspects: How the zeroth, first, and second-order approximations visually relate to the original function's surface. How the familiar concepts of gradient (as part of the Jacobian) and Hessian are assembled into a compact and elegant matrix expression for the approximation.
As the video demonstrates, the second-order Taylor approximation of around a point can be written very compactly using vector and matrix notation. If we define the displacement vector as , the approximation is:
This formula is fundamental. Let's break it down:
- : The zeroth-order term. This is simply the value of the function at the point of expansion. It provides the "height" of our approximating surface.
- : The first-order (linear) term. This is the dot product of the gradient at and the displacement vector . It defines a tangent plane (or hyperplane in higher dimensions) that matches the function's slope at .
- : The second-order (quadratic) term. This is a quadratic form involving the Hessian matrix. It adds the curvature to our approximation, bending the tangent plane into a paraboloid that matches the function's curvature at .

For a more formal statement of this approximation, let's turn to the MIT lecture notes we used previously.
Second Derivatives, Bilinear Maps, and Hessian Matrices
The video gave us the intuition and the final formula. Now, let's look at a formal definition from the MIT lecture notes.
Please read the paragraph on page 88 that starts with 'Instead of thinking of H...'. This section directly presents the second-order Taylor approximation using the compact vector/matrix notation that is standard in machine learning. The term o(∥δx∥²) denotes higher-order terms that become negligible as δx approaches zero.
Derivation of the Multivariable Taylor Expansion
Given your interest in the mathematical underpinnings, it's valuable to see where this formula comes from. A classic and elegant way to derive the multivariable Taylor expansion is to reduce the problem to the single-variable case, for which we already know the answer.
The core idea is to consider the function's behavior along a straight line. Let's define a path from our point to the point . We can parameterize this line segment using a scalar :
Now, we can create a new single-variable function . Notice that and .
We can now write the single-variable Taylor expansion for around :
Setting gives us an approximation for :
The final step is to calculate and using the multivariable chain rule, which will introduce the gradient and Hessian of .
The following video walks through this exact derivation.
Taylor Expansions for Functions of Several Variables
This video provides a formal proof for the multivariable Taylor expansion using the technique just described: reducing the problem to a single variable along a line and applying the chain rule.
Watch the section from 05:21 to 09:02. The presenter defines the function G(t), which is equivalent to our g(t), and then repeatedly applies the chain rule to find its first and second derivatives at t=0. This process beautifully reveals how the gradient and Hessian of the original function f emerge as the coefficients of the expansion.
Worked Example: Constructing the Approximation
Let's solidify this by constructing a second-order Taylor approximation for the function around the point .
Step 1: Evaluate the function at .
Step 2: Compute the gradient and evaluate it at .
The gradient is:
At :
Step 3: Compute the Hessian and evaluate it at .
The Hessian is the matrix of second partial derivatives:
At :
Step 4: Assemble the approximation.
The displacement vector is .
Plugging everything into the formula:
This quadratic function is the second-order Taylor approximation of near the origin.
Test your understanding!
In your past projects, you've likely encountered objective functions. Let's consider a simple one: . Construct the second-order Taylor approximation for this function around the point .
Show answer
1. Function value:
2. Gradient:
3. Hessian:
4. Assembly:
The displacement vector is .
The approximation is:
Expanding this gives the full quadratic polynomial, but this compact form is often more useful. The linear term is and the quadratic term is .
Conclusion
In this lesson, we successfully combined the gradient and the Hessian to build the second-order Taylor approximation, a local quadratic model of a multivariable function.
Key Takeaways:
- The second-order Taylor approximation provides a quadratic model of a function near a point .
- It is constructed using the function's value, gradient, and Hessian, all evaluated at .
- The standard formula in matrix notation is:
Preview of the Next Lesson:
The power of this approximation truly shines when we analyze a function's critical points—points where the gradient is zero. At a critical point, the linear term in the Taylor expansion vanishes. The local behavior of the function (whether it's a minimum, maximum, or saddle point) is therefore determined entirely by the quadratic term, which is governed by the Hessian. In our next lesson, we will use this insight to classify critical points using the properties of the Hessian matrix, a cornerstone of optimization theory in machine learning.