Convexity
A function is convex if the chord between any two points on its graph lies above it; then every local minimum is global.
Needs a step first: 19
Convex functions are bowl-shaped in every direction: . For a twice-differentiable function this means the Hessian has no negative eigenvalues everywhere. The payoff is that there are no false valleys, so gradient descent cannot get stuck and the minimum is often provably found. Linear and logistic regression have convex losses; deep networks do not, which is why their training is less predictable and depends on initialisation and tricks.
Where it shows up: Convexity is why linear and logistic regression train reliably, and its absence explains much of the craft of training deep networks.
How to hold it: In your head
See a convex function as a bowl in every direction, so there are no false valleys and every local minimum is the global one.
What knowing it looks like
- Test a function of two variables for convexity from the eigenvalues of its Hessian.
- Use the chord definition to show that a sum of convex functions is convex.
- Say which of the losses on this map are convex and why it matters for training.
Test yourself
Which of these is convex on all of : or ? Justify with the Hessians' eigenvalues.
Show the worked answer
Needs a step first: 19
Learn it with an AI
Copy this prompt into any AI assistant. It will take you through step by step at your level and finish with the test above.
Be my maths tutor. I'm learning "Convexity" (Undergraduate II tier): A function is convex if the chord between any two points on its graph lies above it; then every local minimum is global. I already know: Optimisation in Many Variables, Eigenvalues and Eigenvectors. Teach it Socratically: first ask what I already know; then explain the core idea with one concrete example and why it's true; then give me three problems, one at a time, easy to hard. Wait for my answer, check every step, and point out mistakes without giving the answer away. Finish by testing me with this: Which of these is convex on all of $\mathbb R^2$: $f(x, y) = x^2 + xy + y^2$ or $g(x, y) = x^2 + 3xy + y^2$? Justify with the Hessians' eigenvalues. Use LaTeX for formulas. When you say where it's used later (machine learning, quantum mechanics), be specific.
Needs first
- Optimisation in Many VariablesFinding the highest and lowest points of a function of several variables: where the gradient is zero, sorted by the Hessian.Undergraduate I · Optimisation & Information
- Eigenvalues and EigenvectorsThe directions a matrix only stretches and never turns, and the factor by which it stretches each one.Undergraduate I · Linear Algebra
Leads to
This is the end of a path.
Recommended
- Mathematics for Machine LearningDeisenroth, Faisal and Ong (Cambridge University Press) · BookA free book that gathers exactly the linear algebra, vector calculus, probability and optimisation machine learning uses, then applies them to regression, PCA and classification.
- Convex OptimizationStephen Boyd and Lieven Vandenberghe · BookThe standard text on convex sets, duality and Lagrange multipliers, free as a PDF from Stanford along with lecture slides and exercises.
- Information Theory, Inference, and Learning AlgorithmsDavid MacKay · BookMacKay's book connecting entropy, coding, Bayesian inference and neural networks, free to read online and still the one recommended for information theory with intuition.