Lagrange multiplier

Also known as: method of Lagrange multipliers

On this page 7

A Lagrange multiplier is a scalar variable attached to each constraint of a constrained optimization problem, used to convert it into the search for a stationary point of a single function, the Lagrangian. The approach, known as the method of Lagrange multipliers, states that at a constrained optimum the gradient of the objective function is a linear combination of the gradients of the active constraints, and the multipliers are the coefficients of that combination.

In artificial intelligence and machine learning, Lagrange multipliers appear wherever a model must optimize under rules: the dual form of support vector machines, maximum entropy models, fairness-constrained training, constrained reinforcement learning and resource-limited neural architecture search. Their values also carry meaning: each multiplier measures the sensitivity of the optimal objective to a small relaxation of its constraint, often called a shadow price.

How the Lagrangian turns constraints into conditions

The method replaces a constrained problem with a system of equations. For the problem of minimizing f(x) subject to equality constraints g_i(x) = 0, one forms the Lagrangian L(x, λ) = f(x) + Σ λ_i g_i(x) and sets its partial derivatives with respect to both x and every λ_i to zero. The derivatives with respect to λ simply reproduce the constraints, so every solution of the system is feasible by construction.

The geometric intuition is a tangency condition. Moving along the constraint surface cannot improve the objective at an optimum, which means the level set of f touches the constraint surface without crossing it. At that point the two gradients are parallel, and the multiplier is the scale factor between them. This condition holds only under a constraint qualification, most commonly linear independence of the active constraint gradients (LICQ).

The table below lists the components of the method and what each contributes to the solution.

ComponentMathematical formRole in the solution
Objective functionf(x)Quantity to minimize or maximize
Equality constraintg_i(x) = 0Restricts x to a surface
Multiplierλ_i, one per constraintWeights each constraint gradient
Lagrangianf(x) + Σ λ_i g_i(x)Single function whose stationary points are candidates
Stationarity∇f(x) + Σ λ_i ∇g_i(x) = 0Gradient balance at the optimum
Components of the method of Lagrange multipliers

Inequality constraints and the KKT conditions

Inequality constraints extend the method through the Karush-Kuhn-Tucker conditions. For constraints h_j(x) ≤ 0, each multiplier μ_j must be non-negative, and the product μ_j h_j(x) must equal zero, a rule called complementary slackness. A constraint that is not tight at the optimum receives a zero multiplier, because relaxing it slightly would change nothing.

This rule is what makes multipliers useful in practice: after solving, the nonzero multipliers identify the binding constraints. In a support vector machine, the training points with nonzero multipliers are exactly the support vectors, and all other points can be discarded without changing the decision boundary.

The following table compares how multipliers behave for the two constraint types.

PropertyEquality constraintInequality constraint
Sign of the multiplierAny real valueNon-negative for minimization
Complementary slacknessNot applicableProduct with constraint equals zero
Inactive constraintAlways activeMultiplier is zero
Governing theoryClassical Lagrange conditionsKarush-Kuhn-Tucker conditions
Multipliers for equality and inequality constraints

Lagrange multipliers as shadow prices and dual variables

A multiplier quantifies the marginal value of a constraint. If the constraint g(x) = c is changed to g(x) = c + ε, the optimal objective changes by approximately λ times ε, with the sign depending on the convention used. A large multiplier therefore signals that the constraint is expensive, while a multiplier near zero means it barely restricts the solution.

Treating the multipliers as variables in their own right leads to Lagrangian duality. The dual function is the minimum of the Lagrangian over x for fixed multipliers, and maximizing it gives a lower bound on the original minimum. For convex problems that satisfy Slater’s condition, the bound is exact, a property called strong duality, and solving the dual is often easier than solving the original problem.

Where Lagrange multipliers appear in machine learning

Many standard algorithms in artificial intelligence are derived with the method. The table summarizes typical uses and what the multipliers represent in each case.

ApplicationConstraint imposedMeaning of the multiplier
Support vector machinesMargin constraint per training pointWeight of each support vector
Maximum entropy modelsMatch observed feature expectationsFeature weight in the exponential model
Constrained reinforcement learningExpected cost below a budgetAdaptive penalty on safety cost
Fairness-constrained trainingBounded gap in group error ratesPrice of enforcing the fairness rule
Trust region updatesKL divergence below a thresholdStep size control in policy optimization
Hardware-aware model searchLatency or memory budgetTrade-off between accuracy and cost
Uses of Lagrange multipliers in AI and machine learning

In deep learning the multipliers are rarely solved analytically. Instead, primal-dual methods alternate a gradient descent step on the model parameters with a gradient ascent step on the multipliers. When a constraint is violated, its multiplier grows and the penalty strengthens; when it is satisfied with slack, the multiplier shrinks toward zero.

Limitations and common mistakes

The stationarity conditions are necessary but not sufficient. A stationary point of the Lagrangian may be a minimum, a maximum or a saddle point of the constrained problem, so second-order conditions on the bordered Hessian or convexity arguments are needed to confirm a minimum. The table lists frequent errors and how to avoid them.

MistakeConsequenceRemedy
Assuming every stationary point is optimalAccepting a maximum or saddle pointCheck second-order conditions or convexity
Ignoring constraint qualificationMissing the true optimumVerify LICQ or Slater’s condition
Wrong sign on inequality multipliersInfeasible or suboptimal solutionEnforce non-negativity explicitly
Fixed penalty instead of learned multiplierConstraint satisfied only by chanceUpdate multipliers with dual ascent
Large dual learning rateOscillating constraint violationUse smaller steps or augmented Lagrangian
Common mistakes with Lagrange multipliers

In non-convex optimization, such as training neural networks, strong duality generally fails, and primal-dual training may oscillate around the constraint boundary. The augmented Lagrangian method, which adds a quadratic penalty to the standard Lagrangian, and its distributed relative ADMM are common remedies that improve stability.

A non-technical view

Imagine you want the best result, but you must follow a rule. A Lagrange multiplier is a price tag on that rule. It tells you how much better the result would be if the rule were a little looser.

The method mixes the goal and the rules into one formula. You then look for the point where no small move helps anymore. If a rule costs nothing, its price is zero. If a rule hurts badly, its price is high. This makes it easy to see which rules really matter.

A concrete example

A lending team trains a credit scoring model and must keep the difference in false rejection rates between two applicant groups below 2 percentage points. Adding a fixed penalty term failed: small penalties ignored the rule, and large ones destroyed accuracy. The team instead attached a learned Lagrange multiplier to the fairness constraint and trained the model with alternating primal and dual updates.

During the first epochs the gap was about 6 points, so the multiplier rose steadily and pushed the model toward equal treatment. Once the gap dropped below 2 points, the multiplier settled at a stable value instead of growing further. The final model met the constraint with an accuracy loss of under one point, and the multiplier value gave the team a clear figure for the accuracy cost of the fairness requirement, which they reported to the risk committee.