Recommended resources
The freely available resources this lesson will direct you to.
Hello! Welcome to your next lesson in the "Theory of Unconstrained Optimization" module.
Introduction
In our last session, we established a crucial theoretical guarantee: for any convex function, a local minimum is also a global minimum. This is a cornerstone of optimization because it assures us that if we find a valley, we've found the deepest valley.
Today, we address the natural follow-up question: how do we algorithmically find that minimum? We will answer this by deriving the update rule for gradient descent, arguably the most important and foundational iterative optimization algorithm in machine learning. This lesson is dedicated to rigorously deriving the famous update rule:
We will explore why moving in the direction of the negative gradient is the optimal local choice. This will connect the calculus you've been learning (gradients) with the practical goal of function minimization.
Part 1: The Principle of Steepest Descent
The core idea behind gradient descent is simple: to minimize a function, we should iteratively take small steps in the direction where the function's value decreases most rapidly. This is known as the direction of "steepest descent".
From your previous lessons on multivariate calculus, you'll recall that the gradient, , points in the direction of the steepest ascent of the function at point . It seems intuitive, then, that the direction of steepest descent would be its opposite, . Let's prove this formally.
Our goal is to find a direction vector (with unit norm, ) that minimizes the function's value when we take an infinitesimally small step in that direction. We can analyze this using a first-order Taylor expansion around our current point :
where is a very small step size.
To decrease the function value, we want to make the change, , as negative as possible. Since is a positive scalar, we need to minimize the dot product .
The following document provides a concise and formal derivation of the direction that achieves this.
The Steepest Descent Algorithm for Unconstrained ...
The note "The Steepest Descent Algorithm for Unconstrained ..." from MIT OpenCourseWare provides a direct and elegant proof. It uses the Cauchy-Schwarz inequality to show that the negative gradient is indeed the direction of steepest descent.
Please read the first section, "1 The Algorithm", up to the sentence "Note that d = −∇f(¯x) is a descent direction as long as ∇f(¯x) != 0." Focus on the argument that normalizes the direction vector d and then finds the d that minimizes the inner product with the gradient.
As the text shows, the inner product is minimized when is in the direction of . This confirms our intuition and formally establishes as the direction of steepest descent.

Part 2: Deriving the Update Rule
Now that we've established the direction, we can construct the full update rule. We start at a point and move to a new point by taking a step in the direction of the negative gradient.
This process is wonderfully explained in the following video, which uses a first-order Taylor series approximation to justify the update rule. The logic is very similar to what we just saw, but the step-by-step walkthrough is invaluable for cementing the concept.
Gradient Descent and Taylor Series
The video "Gradient Descent and Taylor Series" from IIT Madras provides a detailed, first-principles derivation of the gradient descent update rule. It carefully explains how the Taylor series approximation leads to the choice of the negative gradient direction.
Watch from 01:40 to 17:19. The video starts by asking 'What is so special about -f'(x)?' and then uses the Taylor expansion to answer it. Pay close attention to these key steps: Approximating f(x + ηd) with the first-order Taylor expansion. Setting the goal: We want f(x + ηd) - f(x) < 0. Showing that this goal requires the product of the direction and the derivative to be negative. Concluding that choosing the direction d = -f'(x) guarantees this condition.
The video, using single-variable notation for simplicity, shows that to guarantee a decrease in the function value (for a sufficiently small step), we must choose a direction such that . The choice makes this term , which is always negative unless the gradient is zero (meaning we are at a critical point).
Combining the direction with a step size parameter (also called the learning rate), we get the final update rule for gradient descent:
Part 3: An Alternative Derivation via Quadratic Approximation
There is another powerful way to derive this update rule, which is common in more advanced optimization literature. Instead of just finding the best direction, we build a simple local model of the function around our current point and then find the exact minimum of that model.
We can approximate for near using a quadratic model:
Here, the first two terms are the familiar linear Taylor approximation. The third term, , is a proximity term. It penalizes moving too far from our current point . The parameter controls how much we trust our linear approximation; a small keeps very close to .
To find the next iterate, we find the that minimizes this entire quadratic approximation. This is an unconstrained quadratic optimization problem, which we can solve by setting its gradient (with respect to ) to zero.
The following reading walks through this elegant derivation.
These scribe notes from a CMU Convex Optimization course, titled "Lecture 5: Gradient Descent", present a formal interpretation of the algorithm.
Please read the short section titled "Interpretation of Gradient Descent" (just below Figure 5.1). Focus on how the quadratic approximation g(y) is constructed and then minimized by setting its gradient to zero. This directly yields the update rule.
This second perspective is extremely valuable. It recasts gradient descent as a sequence of steps, where each step involves solving a very simple local approximation of the original, more complex problem.
Test your understanding!
In the second derivation, we approximated the function as . The true second-order Taylor expansion is , where is the Hessian matrix.
What matrix did we use to approximate the Hessian in our quadratic model? What does this imply about the algorithm's knowledge of the function's curvature?
Show answer
We approximated the Hessian matrix with , where is the identity matrix.
This implies that the basic gradient descent algorithm does not use any information about the function's true second-order structure or curvature (as captured by the Hessian). It implicitly assumes the curvature is uniform in all directions (isotropic). Algorithms that do use the Hessian, like Newton's method, can often converge much faster but at the cost of computing and inverting the Hessian at each step, which can be very expensive.
Part 4: The Critical Role of the Step Size
Both derivations implicitly assume a "small" step. The step size (or in the second derivation) is a hyperparameter that you must choose. Its value is critical for the algorithm's performance.
22. Gradient Descent: Downhill to a Minimum
To wrap up, let's hear Professor Gilbert Strang briefly discuss the practical importance of the step size (which he calls the learning rate).
Watch the section from 35:00 to 37:30. Professor Strang discusses what happens if the step size is too big (divergence) or too small (slow convergence) and introduces concepts like 'exact line search' and 'backtracking'.
As you heard, selecting a good step size is a non-trivial problem. We will revisit this when we analyze the convergence properties of gradient descent in a future lesson.
Conclusion
Today, we have rigorously derived the gradient descent update rule from first principles. This is the mechanism that powers the training of a vast number of machine learning models.
Key Takeaways:
- The direction of steepest descent of a function is the negative of its gradient, .
- We derived the gradient descent update rule, , by formalizing the idea of taking a small step in this direction.
- We explored two formal derivations: one based on minimizing the first-order Taylor approximation, and another based on minimizing a local quadratic model of the function.
- The step size (or learning rate) is a crucial hyperparameter that balances convergence speed with the risk of overshooting the minimum.
Preview of the Next Lesson:
With the theory now firmly in place, our next step is to bring it to life. In the next lesson, you will implement the gradient descent algorithm in Python to find the minimum of a simple convex function. This will connect the mathematical derivations from today's lesson directly to your practical programming experience.