Inferensys

Glossary

Quadratic Programming (QP)

A mathematical optimization process for minimizing a quadratic objective function—such as portfolio variance—subject to linear equality and inequality constraints.
Finance analyst reviewing cash flow AI optimization on laptop, charts and projections visible, home office work session.
CONVEX OPTIMIZATION

What is Quadratic Programming (QP)?

Quadratic programming is a mathematical optimization technique for minimizing or maximizing a quadratic objective function subject to linear equality and inequality constraints, forming the computational backbone of modern portfolio theory.

Quadratic Programming (QP) is a class of convex optimization that solves problems where the objective function contains a quadratic term—typically x^T Q x—and all constraints are linear. In finance, QP directly implements Markowitz mean-variance optimization by minimizing portfolio variance (a quadratic risk function) while enforcing linear constraints like full investment or target return thresholds.

The core computational challenge lies in the Hessian matrix Q, which must be positive semi-definite to guarantee a unique global optimum. When the covariance matrix is ill-conditioned or singular, solvers employ Cholesky decomposition or interior-point methods to stabilize the solution, making QP essential for constructing the efficient frontier in institutional asset allocation.

MATHEMATICAL FOUNDATIONS

Key Properties of Quadratic Programming

Quadratic Programming (QP) is a class of convex optimization where a quadratic objective function is minimized subject to linear constraints. In portfolio theory, it forms the mathematical backbone for minimizing variance while satisfying allocation and exposure limits.

01

Convexity Guarantees Global Optimality

In portfolio optimization, the covariance matrix is positive semi-definite, making the QP problem convex. This property ensures that any local minimum is also the global minimum, eliminating the risk of settling on a suboptimal allocation. Convexity is critical for production systems because it guarantees deterministic, repeatable solutions regardless of the starting point of the solver.

Global
Optimality Guarantee
P.S.D.
Required Matrix Property
02

Linear Constraints Define the Feasible Set

Constraints in QP are strictly linear equalities and inequalities, forming a convex polytope of feasible solutions. Common portfolio constraints include:

  • Full investment: Sum of weights = 1
  • Long-only: All weights ≥ 0
  • Sector limits: Sum of weights in a sector ≤ 40%
  • Turnover: Sum of absolute weight changes ≤ 20% These linear boundaries ensure the feasible region remains convex and computationally tractable.
03

The Quadratic Objective Encodes Risk

The objective function takes the form minimize wᵀΣw − λμᵀw, where w is the weight vector, Σ is the covariance matrix, and μ is expected returns. The quadratic term wᵀΣw represents portfolio variance—the primary risk measure. The linear term −λμᵀw incorporates return maximization, with λ controlling the risk-aversion trade-off. This structure directly maps the Mean-Variance Optimization framework into a solvable mathematical program.

wᵀΣw
Portfolio Variance Term
04

Duality Provides Economic Interpretations

Every QP problem has a corresponding dual problem whose variables are Lagrange multipliers. In portfolio optimization, these dual variables represent shadow prices—the marginal cost of tightening a constraint. For example, the dual variable for the full-investment constraint equals the expected return of the minimum-variance portfolio. This duality allows portfolio managers to quantify the economic impact of each constraint on performance.

05

Numerical Stability Requires Careful Formulation

Real-world covariance matrices often exhibit high condition numbers due to correlated assets, making QP solvers numerically unstable. Best practices include:

  • Shrinkage estimators to regularize Σ
  • Factor model decomposition to reduce dimensionality
  • Quadratic normalization to scale variables Without these techniques, solvers may return infeasible or inaccurate weight vectors, especially in large universes with thousands of assets.
κ(Σ)
Condition Number Risk
06

Solvers Leverage Active-Set and Interior-Point Methods

Two algorithmic families dominate QP solving:

  • Active-set methods: Iteratively identify which constraints are binding, ideal for problems where the optimal solution activates few constraints
  • Interior-point methods: Traverse the interior of the feasible region, scaling efficiently to large-scale problems with thousands of variables Modern libraries like OSQP and CVXOPT implement these methods, often exploiting sparsity in the covariance matrix for speed.
QUADRATIC PROGRAMMING IN FINANCE

Frequently Asked Questions

Explore the core mechanics and applications of Quadratic Programming, the mathematical engine driving modern portfolio optimization and risk management.

Quadratic Programming (QP) is a mathematical optimization process that minimizes or maximizes a quadratic objective function subject to linear constraints. In portfolio optimization, the objective function typically represents portfolio variance (risk), expressed as x^T Q x, where Q is the covariance matrix of asset returns and x is the vector of portfolio weights. The algorithm iteratively adjusts the weights to find the minimum variance point while respecting constraints like full investment (sum(x) = 1) or no short-selling (x >= 0). Because the objective function is convex (when Q is positive semi-definite), any local minimum is guaranteed to be the global minimum, making QP a robust and reliable solver for the Markowitz Mean-Variance Optimization framework.

OPTIMIZATION METHOD COMPARISON

Quadratic Programming vs. Alternative Optimization Methods

A feature-based comparison of Quadratic Programming against other common portfolio optimization techniques.

FeatureQuadratic Programming (QP)Linear Programming (LP)Non-Linear Programming (NLP)

Objective Function Form

Quadratic (e.g., minimize variance)

Linear (e.g., maximize return)

Any smooth, non-linear function

Handles Covariance Risk

Global Optimality Guarantee

Yes, if convex

Yes

No, may find local optima

Computational Complexity

O(n^3) to O(n^4) for interior-point

O(n^3) for simplex in practice

Problem-dependent, often high

Typical Solver Time (500 assets)

< 0.1 sec

< 0.05 sec

1-10 sec

Constraint Linearity Requirement

Linear constraints only

Linear constraints only

Can handle non-linear constraints

Primary Use Case

Mean-Variance Optimization (MVO)

Cash management, basic allocation

Complex derivatives pricing

Sparse Matrix Support

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.