Local and Global Extrema

When optimizing a function, the goal is often to find its absolute best or worst value. However, a function's landscape can be complex, featuring many 'hills' and 'valleys'. Understanding the difference between local extrema (the highest or lowest points in a specific region) and global extrema (the absolute highest or lowest points across the entire domain) is fundamental to successful optimization. This distinction guides how algorithms search and what they ultimately find.

Local Minima and Maxima

A local minimum is a point where the function's value is smaller than or equal to the values at all nearby points. Think of it as the bottom of a small dip or valley. Conversely, a local maximum is a point where the function's value is greater than or equal to the values at all nearby points, like the peak of a small hill. These points are significant because they represent optimal solutions within a restricted neighborhood, even if better solutions exist elsewhere.

💡 Neighborhood Matters

The definition of 'nearby points' is crucial for local extrema. A point x0x_0 is a local minimum if there exists some open interval around x0x_0 such that f(x0)≤f(x)f(x_0) \leq f(x) for all xx in that interval. The size of this interval can be arbitrarily small.

Global Minima and Maxima

A global minimum is the point where the function's value is the absolute smallest across its entire domain. Similarly, a global maximum is the point where the function's value is the absolute largest across its entire domain. Unlike local extrema, global extrema are unique in their value, though multiple points might achieve that same value. Finding these global points is often the ultimate objective in many optimization problems, such as minimizing a loss function in machine learning.

✨ Existence of Global Extrema

For a continuous function on a closed and bounded interval (or compact set in higher dimensions), the Extreme Value Theorem guarantees the existence of both a global maximum and a global minimum. For functions on open or unbounded domains, global extrema may not exist.

Check Your Understanding
Can a function have multiple global minima with different function values?

Critical Points: Where Gradients Vanish

A critical point of a function is any point where its gradient is either zero or undefined. For differentiable functions, this means the tangent line (in 1D) or tangent plane (in higher dimensions) is flat. Local minima, local maxima, and saddle points are all types of critical points. Identifying these points is the first step in finding extrema, as they are the only candidates where an extremum can occur within the interior of a function's domain.

pythonFinding Critical Points for a 1D Function
📐 Gradient at Critical Points

For a function f(x)f(\mathbf{x}), a point x0\mathbf{x}_0 is a critical point if the gradient vector at that point is the zero vector:

∇f(x0)=0\nabla f(\mathbf{x}_0) = \mathbf{0}

Saddle Points: Neither Min nor Max

A saddle point is a critical point that is neither a local maximum nor a local minimum. Imagine a saddle on a horse: it's a minimum along one direction (front-to-back) but a maximum along another (side-to-side). For optimization algorithms, saddle points are problematic because the gradient is zero, making it seem like an extremum has been found, but the function can still decrease or increase by moving in different directions. This can trap algorithms, preventing them from reaching true minima.

pythonIdentifying a Saddle Point for a 2D Function
📐 Second Derivative Test (2D)

For a critical point (x0,y0)(x_0, y_0) where ∇f(x0,y0)=0\nabla f(x_0, y_0) = \mathbf{0}, let D=det⁡(H(x0,y0))D = \det(H(x_0, y_0)) and fxx=∂2f∂x2(x0,y0)f_{xx} = \frac{\partial^2 f}{\partial x^2}(x_0, y_0).

  • If D>0D > 0 and fxx>0f_{xx} > 0, then (x0,y0)(x_0, y_0) is a local minimum.
  • If D>0D > 0 and fxx<0f_{xx} < 0, then (x0,y0)(x_0, y_0) is a local maximum.
  • If D<0D < 0, then (x0,y0)(x_0, y_0) is a saddle point.
  • If D=0D = 0, the test is inconclusive.

Check Your Understanding
Why are saddle points particularly challenging for gradient descent algorithms?

The Optimization Challenge

Optimization algorithms, such as gradient descent, primarily rely on the gradient to navigate the function landscape. They naturally gravitate towards points where the gradient is zero. While this is effective for finding local minima, it means these algorithms can easily get trapped in a local minimum or a saddle point, failing to reach the desired global minimum. Strategies like using different starting points, adding momentum, or employing more advanced optimization techniques are necessary to increase the chances of finding the global optimum.

Local and Global Extrema of f(x)=x4−4x2+x+5f(x) = x^4 - 4x^2 + x + 5
This chart displays the function f(x)=x4−4x2+x+5f(x) = x^4 - 4x^2 + x + 5 over the interval [−2.5,2.5][-2.5, 2.5]. It highlights the various local minima and maxima, as well as the global minimum and maximum within this specific range. Notice how the global maximum occurs at an endpoint, while the global minimum is also a local minimum.
Loading chart...
Key Insight: A function can have multiple local extrema, but only one global minimum and one global maximum (in terms of value) within a given domain. Global extrema can occur at local extrema or at the domain boundaries.
Try It Yourself
Modify the 1D critical point finder to analyze the function g(x)=x3−6x2+9x+1g(x) = x^3 - 6x^2 + 9x + 1. Find its critical points and their corresponding function values. What do you observe about the number of critical points compared to the previous example?
python
Key Takeaways
  • Local extrema are the highest or lowest points within a specific neighborhood of a function, not necessarily across the entire domain.

  • Global extrema represent the absolute highest or lowest values a function attains over its entire domain, and their values are unique.

  • Critical points are locations where the function's gradient is zero or undefined; all local and global extrema (within the domain interior) are critical points.

  • Saddle points are critical points that are neither local minima nor local maxima, posing a challenge for optimization algorithms that can get stuck there.

  • The Hessian matrix and its determinant can classify critical points in higher dimensions, distinguishing between minima, maxima, and saddle points.

  • Optimization algorithms like gradient descent aim for global extrema but can converge to local minima or saddle points due to their reliance on local gradient information.

  • To find global extrema, consider multiple starting points, advanced optimization techniques, and evaluate function behavior at domain boundaries.

← All lessons in Calculus: Gradients & Optimization

Ready to keep this from fading?

Bitelrn turns lessons like this into a full course — quizzes, a knowledge map, and spaced review.

Get started free