Quadratic programming (QP) is the process of solving a special type of mathematical optimization problem—specifically, a (linearly constrained) quadratic optimization problem, that is, the problem of optimizing (minimizing or maximizing) a quadratic function of several variables subject to linear constraints on these variables. Quadratic programming is a particular type of nonlinear programming.
Contents
Problem formulation
The quadratic programming problem with n variables and m constraints can be formulated as follows.^{[1]} Given:
 a realvalued, ndimensional vector c,
 an n × ndimensional real symmetric matrix Q,
 an m × ndimensional real matrix A, and
 an mdimensional real vector b,
the objective of quadratic programming is to find an ndimensional vector x, that will
where x^{T} denotes the vector transpose of . The notation Ax ≤ b means that every entry of the vector Ax is less than or equal to the corresponding entry of the vector b.
A related programming problem, quadratically constrained quadratic programming, can be posed by adding quadratic constraints on the variables.
Solution methods
For general problems a variety of methods are commonly used, including

 interior point,
 active set,^{[2]}
 augmented Lagrangian,^{[3]}
 conjugate gradient,
 gradient projection,
 extensions of the simplex algorithm.^{[2]}
In the case in which Q is positive definite, the problem is a special case of the more general field of convex optimization.
Equality constraints
Quadratic programming is particularly simple when Q is positive definite and there are only equality constraints; specifically, the solution process is linear. By using Lagrange multipliers and seeking the extremum of the Lagrangian, it may be readily shown that the solution to the equality constrained problem
is given by the linear system
where is a set of Lagrange multipliers which come out of the solution alongside .
The easiest means of approaching this system is direct solution (for example, LU factorization), which for small problems is very practical. For large problems, the system poses some unusual difficulties, most notably that the problem is never positive definite (even if is), making it potentially very difficult to find a good numeric approach, and there are many approaches to choose from dependent on the problem.^{[4]}
If the constraints don't couple the variables too tightly, a relatively simple attack is to change the variables so that constraints are unconditionally satisfied. For example, suppose (generalizing to nonzero is straightforward). Looking at the constraint equations:
introduce a new variable defined by
where has dimension of minus the number of constraints. Then
and if is chosen so that the constraint equation will be always satisfied. Finding such entails finding the null space of , which is more or less simple depending on the structure of . Substituting into the quadratic form gives an unconstrained minimization problem:
the solution of which is given by:
Under certain conditions on , the reduced matrix will be positive definite. It is possible to write a variation on the conjugate gradient method which avoids the explicit calculation of .^{[5]}
Lagrangian duality
The Lagrangian dual of a QP is also a QP. To see that let us focus on the case where and Q is positive definite. We write the Lagrangian function as
Defining the (Lagrangian) dual function , defined as , we find an infimum of , using and positivedefiniteness of Q:
Hence the dual function is
and so the Lagrangian dual of the QP is
Besides the Lagrangian duality theory, there are other duality pairings (e.g. Wolfe, etc.).
Complexity
For positive definite Q, the ellipsoid method solves the problem in polynomial time.^{[6]} If, on the other hand, Q is indefinite, then the problem is NPhard.^{[7]} In fact, even if Q has only one negative eigenvalue, the problem is NPhard.^{[8]}
Solvers and scripting (programming) languages
Name  Brief info 

AIMMS  A software system for modeling and solving optimization and schedulingtype problems 
ALGLIB  Dual licensed (GPL/proprietary) numerical library (C++, .NET). 
AMPL  A popular modeling language for largescale mathematical optimization. 
APMonitor  Modeling and optimization suite for LP, QP, NLP, MILP, MINLP, and DAE systems in MATLAB and Python. 
CGAL  An open source computational geometry package which includes a quadratic programming solver. 
CPLEX  Popular solver with an API (C, C++, Java, .Net, Python, Matlab and R). Free for academics. 
CVXOPT  Pythonbased opensource solver for convex optimization problems (including quadratic programming) 
Excel Solver Function  A nonlinear solver adjusted to spreadsheets in which function evaluations are based on the recalculating cells. Basic version available as a standard addon for Excel. 
GAMS  A highlevel modeling system for mathematical optimization 
Gurobi  Solver with parallel algorithms for largescale linear programs, quadratic programs and mixedinteger programs. Free for academic use. 
IMSL  A set of mathematical and statistical functions that programmers can embed into their software applications. 
IPOPT  Ipopt (Interior Point OPTimizer) is a software package for largescale nonlinear optimization 
Artelys Knitro  An Integrated Package for Nonlinear Optimization 
Maple  Generalpurpose programming language for mathematics. Solving a quadratic problem in Maple is accomplished via its QPSolve command. 
MATLAB  A generalpurpose and matrixoriented programminglanguage for numerical computing. Quadratic programming in MATLAB requires the Optimization Toolbox in addition to the base MATLAB product 
Mathematica  A generalpurpose programminglanguage for mathematics, including symbolic and numerical capabilities. 
MOSEK  A solver for large scale optimization with API for several languages (C++, Java, .Net, Matlab and Python) 
NAG Numerical Library  A collection of mathematical and statistical routines developed by the Numerical Algorithms Group for multiple programming languages (C, C++, Fortran, Visual Basic, Java and C#) and packages (MATLAB, Excel, R, LabVIEW). The Optimization chapter of the NAG Library includes routines for quadratic programming problems with both sparse and nonsparse linear constraint matrices, together with routines for the optimization of linear, nonlinear, sums of squares of linear or nonlinear functions with nonlinear, bounded or no constraints. The NAG Library has routines for both local and global optimization, and for continuous or integer problems. 
GNU Octave  A free (its licence is GPLv3) generalpurpose and matrixoriented programminglanguage for numerical computing, similar to MATLAB. Quadratic programming in GNU Octave is available via its qp command 
OSQP  An opensource generalpurpose QP solver based on ADMM. 
R (Fortran)  GPL licensed universal crossplatform statistical computation framework, see its quadprog page. Ported to javascript under MIT License. Ported to C# under LGPL. 
SAS/OR  A suite of solvers for Linear, Integer, Nonlinear, DerivativeFree, Network, Combinatorial and Constraint Optimization; the Algebraic modeling language OPTMODEL; and a variety of vertical solutions aimed at specific problems/markets, all of which are fully integrated with the SAS System. 
TK Solver  Mathematical modeling and problem solving software system based on a declarative, rulebased language, commercialized by Universal Technical Systems, Inc.. 
TOMLAB  Supports global optimization, integer programming, all types of least squares, linear, quadratic and unconstrained programming for MATLAB. TOMLAB supports solvers like Gurobi, CPLEX, SNOPT and KNITRO. 
XPRESS  Solver for largescale linear programs, quadratic programs, general nonlinear and mixedinteger programs. Has API for several programming languages, also has a modelling language Mosel and works with AMPL, GAMS. Free for academic use. 
See also
References
Notes
 ^ Nocedal, Jorge; Wright, Stephen J. (2006). Numerical Optimization (2nd ed.). Berlin, New York: SpringerVerlag. p. 449. ISBN 9780387303031..
 ^ ^{a} ^{b} Murty, Katta G. (1988). Linear complementarity, linear and nonlinear programming. Sigma Series in Applied Mathematics. 3. Berlin: Heldermann Verlag. pp. xlviii+629 pp. ISBN 3885384035. MR 0949214. Archived from the original on 20100401.
 ^ Delbos, F.; Gilbert, J.Ch. (2005). "Global linear convergence of an augmented Lagrangian algorithm for solving convex quadratic optimization problems" (PDF). Journal of Convex Analysis. 12: 45–69.
 ^ Google search.
 ^ Gould, Nicholas I. M.; Hribar, Mary E.; Nocedal, Jorge (April 2001). "On the Solution of Equality Constrained Quadratic Programming Problems Arising in Optimization". 23 (4). SIAM Journal of Scientific Computing: 1376–1395. CiteSeerX 10.1.1.129.7555 .
 ^ Kozlov, M. K.; S. P. Tarasov; Leonid G. Khachiyan (1979). "[Polynomial solvability of convex quadratic programming]". Doklady Akademii Nauk SSSR. 248: 1049–1051. Translated in: Soviet Mathematics  Doklady. 20: 1108–1111. Missing or empty
title=
(help)  ^ Sahni, S. (1974). "Computationally related problems" (PDF). SIAM Journal on Computing. 3: 262–279. doi:10.1137/0203021.
 ^ Pardalos, Panos M.; Vavasis, Stephen A. (1991). "Quadratic programming with one negative eigenvalue is NPhard". Journal of Global Optimization. 1 (1): 15–22. doi:10.1007/bf00120662.
Bibliography
 Cottle, Richard W.; Pang, JongShi; Stone, Richard E. (1992). The linear complementarity problem. Computer Science and Scientific Computing. Boston, MA: Academic Press, Inc. pp. xxiv+762 pp. ISBN 0121923509. MR 1150683.
 Garey, Michael R.; Johnson, David S. (1979). Computers and Intractability: A Guide to the Theory of NPCompleteness. W.H. Freeman. ISBN 0716710455. A6: MP2, pg.245.
 Gould, Nicholas I. M.; Toint, Philippe L. (2000). "A Quadratic Programming Bibliography" (PDF). RAL Numerical Analysis Group Internal Report 20001.
External links
 A page about QP
 NEOS Optimization Guide: Quadratic Programming
 Solve an example Quadratic Programming (QP) problem