Differential Calculus and Optimization Basics › Convexity
Quantitative FinanceAll chapters Differential Calculus and Optimization Basics › ConvexityOne section · Sections in this chapter6 / 11 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Convexity is a key structural property in optimization. When a function is convex, any local minimum is automatically a global minimum, dramatically simplifying the search for optimal solutions.
Convexity provides essential guarantees in optimization. A non-convex objective can have many valleys, and gradient-based methods can stop in any of them with no guarantee of finding the deepest one. For a convex objective over a convex feasible set, any local minimum is globally optimal. Convexity does not guarantee that a minimum is attained. Under standard finite-dimensional representations and regularity assumptions, this structure often makes global optimization algorithmically tractable. Actual computational cost still depends on the problem representation, dimension, oracle access, conditioning, constraints, and requested accuracy.
Definition and Intuition
The formal definition of convexity captures a simple geometric idea. A function is convex if the line segment connecting any two points on its graph lies above the graph itself. Alternatively, if you interpolate between two input points and evaluate the function at the interpolated point, you get a value no larger than if you had interpolated between the function values at the original points.
A function is convex if for any two points and and any :
where:
- : any two points in the domain of
- : a convex combination weight (interpolation parameter)
- : a point on the line segment between and
- : the chord height at the interpolated input, between and
Geometrically, this means the line segment connecting any two points on the graph lies above the graph itself.
The definition compares the graph and chord at the same interpolated input: a convex graph never rises above its chords. It can have flat portions or corners; convexity does not require strictly positive smooth curvature everywhere.
Imagine a convex bowl-shaped graph and a string connecting two points on it. The string stays above or on the graph along the segment. A nonconvex graph can instead rise above a chord somewhere along a segment, violating the inequality.
The parameter can be thought of as a "mixing" proportion. When , we are entirely at point ; when , we are entirely at point ; and intermediate values of give us intermediate points along the segment. The convexity inequality states that the function value at any such intermediate point is at most the correspondingly weighted average of the function values at the endpoints.


Testing for Convexity
For twice-differentiable functions on an open convex domain, convexity can be checked using the Hessian matrix.
A function on such a domain is convex if and only if its Hessian is positive semidefinite at every point. Checking eigenvalues at only one point establishes local curvature there, not global convexity.
Strict convexity means the chord inequality is strict for distinct inputs and . A positive-definite Hessian everywhere on an open convex domain is sufficient, but not necessary: is strictly convex despite . Strict convexity gives at most one minimizer on a convex feasible set, if a minimum is attained; it does not guarantee existence.
The Hessian captures how the gradient changes as we move through the space. Positive semidefiniteness everywhere means the function curves upward or remains flat in every direction, ruling out suboptimal local minima. It is not by itself an algorithmic convergence guarantee: for a differentiable convex function with an -Lipschitz gradient and an attained minimum, fixed-step gradient descent also needs an appropriate step such as .
For a function with continuous second derivatives near , a small vector change gives . Here is evaluated at the base point, and the remainder becomes small relative to the squared displacement. The quadratic term describes second-order directional curvature. If the Hessian is positive semidefinite everywhere on the open convex domain, restriction to each line segment establishes global convexity. A zero Hessian at one point does not make the nearby function constant.
For our quadratic portfolio variance function:
where is the covariance matrix. The Hessian of this function is:
A valid covariance matrix is positive semidefinite because is a variance and cannot be negative. Portfolio variance is therefore convex. Over the stated affine budget and target-return constraints, every feasible local minimum is global. This theorem applies to a verified solution under those constraints, not automatically to any array returned by a solver.
For the verified 8% target portfolio, no feasible allocation under those same constraints has lower variance. The budget-only minimum is a different problem, as is a different asset universe. Numerical confidence still depends on status, feasibility, tolerances, and an optimality check; convexity does not verify an unchecked computation or establish the accuracy of estimated inputs.
import numpy as np
# Define covariance matrix (from earlier portfolio example)
sigma = np.array([0.20, 0.10]) # Standard deviations
rho = 0.3 # Correlation
cov_matrix = np.array(
[
[sigma[0] ** 2, rho * sigma[0] * sigma[1]],
[rho * sigma[0] * sigma[1], sigma[1] ** 2],
]
)
# Verify convexity of portfolio variance
# Hessian is 2 * covariance matrix
H_portfolio = 2 * cov_matrix
eigenvalues_portfolio = np.linalg.eigvals(H_portfolio)Covariance matrix: [[0.04 0.006] [0.006 0.01 ]] Hessian of variance function (2Σ): [[0.08 0.012] [0.012 0.02 ]] Eigenvalues of Hessian: [0.08231099 0.01768901] All eigenvalues ≥ 0: True Conclusion: Portfolio variance is convex
Why Convexity Matters in Finance
Convexity has significant practical implications in quantitative finance:
Portfolio optimization can be convex. With a positive-semidefinite covariance matrix and a convex feasible set such as linear equalities and inequalities, mean-variance minimization is a convex program. Every local minimum is then global, but a solver's returned point still requires success, feasibility, and numerical-tolerance checks.
Convexity removes suboptimal local-minimum traps from this formulation, but it does not guarantee that an arbitrary numerical run finds or accurately certifies a solution. Conditioning, tolerances, infeasibility, and implementation details still matter. Nonconvexity can introduce multiple basins and make global certification harder; its computational cost depends on the problem's structure rather than following a universal exponential search rule.
Convex risk measures reward mixing relative to an average benchmark. For a convex risk functional, the risk of a weighted combination cannot exceed the same weighted average of the component risks. Equality can occur, and the combination can still be riskier than one component; convexity does not promise a strict reduction in every comparison. Value-at-Risk is not convex in general.
If is a convex risk functional and we combine two portfolios and with weights and , then . The inequality supplies an upper bound relative to the weighted average. Whether the mixture is strictly safer than either component depends on the positions, dependence structure, weights, and risk functional.
Nonconvexity can make global certification harder. Multiple local minima may exist, and local gradient methods can stop in a nonglobal basin. Nontrivial integer choices, such as asset-selection decisions, can remove convexity guarantees and may require discrete or specialized methods. Difficulty depends on the structure and guarantee required; nonconvexity or integrality alone does not make every problem hard.
Examples of nonconvexity include a positive fixed fee charged for any nonzero trade but waived when there is no trade. An at-most-30-stock constraint is nonconvex when the asset universe permits feasible portfolios whose combined support exceeds 30; an already-small universe makes the restriction vacuous. Some loss distributions also make Value-at-Risk violate convexity. Depending on the structure and required guarantee, practitioners may use local methods, multi-start searches, relaxations, exact discrete algorithms, or global heuristics; heuristic methods do not by themselves certify a global optimum.

