Critical Points and Extrema

When optimizing a machine learning model, our goal is often to find the parameter values that minimize a loss function. These optimal points are typically found at the "bottom" of valleys or the "top" of hills on the loss surface. In calculus, these turning points are known as extrema, and the specific locations where they might occur are called critical points. Understanding how to identify and classify critical points is fundamental to solving optimization problems, from simple curve fitting to complex neural network training.

Defining Critical Points

A critical point of a function f(x)f(x) is any point cc in the domain of ff where the first derivative f′(c)f'(c) is either zero or undefined. These points are significant because they are the only candidates for local maxima or local minima. Intuitively, if a function is smoothly changing direction from increasing to decreasing (or vice-versa), its tangent line must be horizontal, meaning its derivative is zero. If the function has a sharp corner or a discontinuity, the derivative might not exist at that point, also indicating a potential turning point.

📐 Critical Point Conditions

For a function f(x)f(x), a point cc is a critical point if:

  1. f′(c)=0f'(c) = 0 (the tangent line is horizontal)
  2. f′(c)f'(c) is undefined (e.g., a sharp corner, cusp, or vertical tangent)

Finding Critical Points: Derivative Equals Zero

The most common way to find critical points is to compute the first derivative of the function and set it equal to zero. Solving the resulting equation for xx will yield the xx-coordinates of these critical points. This approach works well for polynomial functions and other differentiable functions where the derivative is always defined. These points correspond to where the function's slope momentarily flattens out.

pythonIdentifying Critical Points by Setting Derivative to Zero

Finding Critical Points: Derivative Undefined

Some functions have critical points where their derivative does not exist. This often occurs at sharp corners (like in the absolute value function), cusps, or points where the tangent line is vertical. These are points where the function's smoothness breaks down, but they still represent potential locations for local extrema. When analyzing a function, always consider its domain and points where its derivative might become undefined, such as denominators becoming zero or arguments of square roots becoming negative.

pythonIdentifying Critical Points Where Derivative is Undefined
Check Your Understanding
Which of the following is NOT necessarily true for a function at a critical point?

Classifying Extrema: The First Derivative Test

Once critical points are identified, the First Derivative Test helps classify them as local maxima, local minima, or neither. This test involves examining the sign of the first derivative on either side of a critical point. If the derivative changes from positive to negative, it indicates a local maximum. A change from negative to positive signifies a local minimum. If the derivative's sign does not change, the critical point is typically a saddle point (or an inflection point in 1D), where the function flattens but continues in the same direction.

Applying the First Derivative Test
1
Find Critical Points
Calculate f′(x)f'(x) and find all values cc where f′(c)=0f'(c) = 0 or f′(c)f'(c) is undefined.
2
Create Intervals
Use the critical points to divide the number line into test intervals.
3
Test Each Interval
Choose a test value xtx_t within each interval and evaluate f′(xt)f'(x_t). Note the sign of the derivative.
4
Classify Critical Points
Based on the sign changes: - If f′(x)f'(x) changes from positive to negative at cc, f(c)f(c) is a local maximum. - If f′(x)f'(x) changes from negative to positive at cc, f(c)f(c) is a local minimum. - If f′(x)f'(x) does not change sign at cc, f(c)f(c) is neither a local maximum nor minimum (often a saddle point).
pythonClassifying Extrema using the First Derivative Test
Function, Derivative, and Critical Points
This chart displays the function f(x)=x3−6x2+9x+10f(x) = x^3 - 6x^2 + 9x + 10 and its first derivative f′(x)=3x2−12x+9f'(x) = 3x^2 - 12x + 9. Notice how the critical points of f(x)f(x) (where f′(x)=0f'(x)=0) correspond to local extrema of f(x)f(x). The sign of f′(x)f'(x) indicates whether f(x)f(x) is increasing or decreasing.
Loading chart...
Key Insight: The function f(x)f(x) reaches a local maximum or minimum precisely where its derivative f′(x)f'(x) crosses the x-axis (i.e., where f′(x)=0f'(x)=0). The sign of f′(x)f'(x) indicates the direction of f(x)f(x).

The Second Derivative Test

An alternative method for classifying critical points is the Second Derivative Test. This test uses the concavity of the function at a critical point to determine if it's a local maximum or minimum. If f′′(c)>0f''(c) > 0, the function is concave up, indicating a local minimum. If f′′(c)<0f''(c) < 0, the function is concave down, indicating a local maximum. However, if f′′(c)=0f''(c) = 0, the test is inconclusive, and you must revert to the First Derivative Test.

📐 Second Derivative Test Conditions

Given a critical point cc where f′(c)=0f'(c) = 0:

  1. If f′′(c)>0f''(c) > 0, then f(c)f(c) is a local minimum.
  2. If f′′(c)<0f''(c) < 0, then f(c)f(c) is a local maximum.
  3. If f′′(c)=0f''(c) = 0, the test is inconclusive.

pythonClassifying Extrema using the Second Derivative Test
Check Your Understanding
If f′(c)=0f'(c)=0 and f′′(c)=0f''(c)=0, what can be concluded about the critical point cc?

Absolute Extrema on a Closed Interval

For a continuous function on a closed interval [a,b][a, b], the Extreme Value Theorem guarantees that both an absolute maximum and an absolute minimum exist. These absolute extrema must occur either at a critical point within the interval or at one of the endpoints aa or bb. To find them, you evaluate the function at all critical points in the interval and at the endpoints, then compare these values to find the largest and smallest.

pythonFinding Absolute Extrema on a Closed Interval

Critical Points in Machine Learning Optimization

In machine learning, we often train models by minimizing a loss function L(θ)L(\theta), where θ\theta represents the model's parameters. The goal is to find the θ\theta values that yield the smallest possible loss. This is an optimization problem, and the techniques for finding critical points are directly applicable. We seek parameters where the gradient of the loss function, ∇L(θ)\nabla L(\theta), is zero. These critical points can be local minima (our desired outcome), local maxima, or saddle points. Gradient descent algorithms iteratively move towards these critical points, ideally converging to a local minimum.

Optimization Flow to Critical Points
Loading diagram...
This diagram illustrates how optimization algorithms like gradient descent iteratively approach critical points by following the negative gradient of the loss function. The goal is to converge to a local minimum.
Try It Yourself
Consider the function f(x)=x4−4x3+4x2+5f(x) = x^4 - 4x^3 + 4x^2 + 5. Modify the code to find its critical points and classify them using the Second Derivative Test. What happens if f′′(c)=0f''(c)=0?
python
Key Takeaways
  • Critical points are locations where a function's first derivative is zero or undefined, making them candidates for local extrema.

  • To find critical points, calculate the first derivative f′(x)f'(x) and solve for xx where f′(x)=0f'(x)=0 or f′(x)f'(x) is undefined.

  • The First Derivative Test classifies critical points by observing the sign change of f′(x)f'(x) around the point: positive to negative for a local maximum, negative to positive for a local minimum, and no change for a saddle point.

  • The Second Derivative Test offers an alternative classification: f′′(c)>0f''(c) > 0 indicates a local minimum, f′′(c)<0f''(c) < 0 indicates a local maximum. If f′′(c)=0f''(c) = 0, the test is inconclusive.

  • For a continuous function on a closed interval, absolute extrema occur at either critical points within the interval or at the interval's endpoints.

  • In machine learning, critical points of loss functions correspond to potential optimal parameter settings, with local minima being the desired outcome for model training.

← All lessons in Calculus: Derivatives

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