Hello! Welcome to our lesson on convexity, a concept that bridges the gap between the local curvature we studied last time and the global structure of a function.
In our previous session, we learned how to use the Hessian matrix at a single critical point to classify it as a local minimum, maximum, or saddle point. This was a purely local analysis. Today, we'll zoom out and ask a more powerful question: What if a function's curvature is "upward" everywhere in its domain? This global property is called convexity, and it is one of the most important ideas in optimization.
Our goal is to understand how the Hessian's properties across the entire domain of a function determine its convexity. This connection is fundamental to why many optimization problems in machine learning are solvable, guaranteeing that when we find a minimum, we've found the minimum.
1. What is a Convex Function?
Let's start with the visual intuition. In one dimension, a convex function is one that is "bowl-shaped" or has positive curvature everywhere. A more formal geometric definition is:
A function is convex if the line segment connecting any two points on its graph lies on or above the graph itself.

Conversely, a function is concave if the line segment lies on or below the graph (like an upside-down bowl). A function that is not consistently one or the other is non-convex.
Why is this property so important for your goal of studying deep learning?
Because for a convex function, any local minimum is also a global minimum. This completely changes the game for optimization. If you are trying to find the minimum of a convex function, you can use an algorithm that just goes "downhill" (like gradient descent), and you are guaranteed not to get stuck in a "valley" that isn't the absolute lowest point.
2. The Second-Order Condition for Convexity
In the last lesson, a positive definite Hessian at a critical point signaled a local minimum. Now, we'll elevate that idea to a global statement about the function. The connection is remarkably direct.
For a twice-differentiable function , its convexity is determined by its Hessian matrix, , over its entire domain.
The following document from Stanford's CS229 course provides the formal definition connecting the Hessian to convexity. It's a cornerstone of optimization theory.
Please read section '3.2 Second Order Condition for Convexity'. This short section formally states the relationship. Pay attention to the distinction made between positive semi-definite and positive definite.
As you just read, the rule is as follows:
- A function is convex if and only if its Hessian is positive semi-definite for all in its domain. (Eigenvalues ).
- If the Hessian is positive definite for all , then is strictly convex. (Eigenvalues ).
A strictly convex function has a bowl shape that is always curving up, which guarantees a unique global minimum. A convex (but not strictly convex) function might have "flat" regions or troughs, allowing for multiple points to share the same minimum value.
3. The Archetype: Quadratic Functions
The most important and intuitive examples of convex functions are quadratic functions. Let's consider the general quadratic form:
where is a symmetric matrix. From our work on matrix calculus, we know the Hessian of this function is simply:
The Hessian is constant—it's the same matrix everywhere! This means the convexity of the entire quadratic function is determined solely by the properties of the matrix .
The following reading provides an excellent and intuitive explanation of this exact connection, which is at the heart of many optimization problems.
Understanding Positive Definite Matrices
This blog post, 'Understanding Positive Definite Matrices', does a fantastic job of building intuition. We'll focus on the section that directly connects these matrices to optimization and convexity.
Please read the section titled 'Quadratic programming'. It masterfully walks through the argument, starting from the 1D case (f(x) = (1/2)ax² - bx + c) and extending it to the multivariate quadratic form. Focus on understanding why the positive definiteness of A guarantees that the solution to Ax=b is the global minimum of the quadratic function.
The reading beautifully illustrates that if is positive definite, the quadratic function is a convex, bowl-shaped surface whose unique minimum occurs precisely at the point that solves the linear system .
To solidify this visual, the following short video clip shows how a positive definite matrix creates this characteristic "bowl" shape.
Symmetric Matrices and the Positive Definiteness
This video from DataMListic provides a great geometric visualization of the quadratic form for a positive definite matrix.
Watch from 02:40 to 03:58. The video visualizes the quadratic form xᵀAx as a 'bowl-shaped surface' that always slopes upward from the origin, which is the key geometric intuition behind positive definiteness and convexity.
The article you read also contains excellent visualizations (in its section "Visualizing definiteness", Figure 9) showing what the quadratic surface looks like for different types of matrices:
- Positive definite A: A convex bowl (a paraboloid).
- Negative definite A: A concave, upside-down bowl.
- Indefinite A: A Pringles-like saddle shape.
- Positive semi-definite A (but singular): A convex "trough" or "channel".
Test your understanding!
Consider the quadratic function . Is this function convex, concave, or neither? Does it have a unique global minimum?
Hint: Write this function in the form and analyze the matrix .
Show answer
First, let's find the Hessian matrix.
So, the Hessian is the constant matrix:
To check for convexity, we need to determine if is positive definite. We can use the test from the last lesson for 2D matrices:
- Determinant: . Since , the eigenvalues have the same sign.
- Top-left entry: The term is 4, which is positive.
Since and , the Hessian is positive definite everywhere.
Therefore, the function is strictly convex and has a unique global minimum.
Conclusion
In this lesson, we have solidified a crucial link between the algebraic properties of the Hessian matrix and the geometric shape of a function.
Key Takeaways:
- A convex function is "bowl-shaped," meaning any local minimum you find is guaranteed to be a global minimum.
- The second-order condition for convexity provides a definitive test: a function is convex if and only if its Hessian matrix is positive semi-definite everywhere in its domain.
- A function is strictly convex if its Hessian is positive definite everywhere, which guarantees a unique global minimum.
- Quadratic functions of the form are the quintessential example. Their convexity is determined entirely by the definiteness of the matrix .
Preview of the Next Lesson:
We now have a deep understanding of the "landscape" of a function—its direction of steepest ascent (the gradient) and its curvature (the Hessian and convexity). The next logical step is to develop an algorithm to navigate this landscape to find a minimum. In our next lesson, we will introduce the most fundamental optimization algorithm of all: gradient descent. We will see how it uses the gradient to take iterative steps "downhill," and how the concept of convexity assures us that this simple process can lead to a global optimum.