Primer on Lagrangians

You typically have a function f(x)f(\mathbf{x}) to optimize (minimize or maximize), subject to constraints:

The Idea

Lagrange multipliers introduce additional variables (multipliers) to incorporate constraints into the objective function. This creates a single "augmented" function, the Lagrangian:

L(x,λ)=f(x)+i=1mλigi(x),\mathcal{L}(\mathbf{x}, \boldsymbol{\lambda}) = f(\mathbf{x}) + \sum_{i=1}^m \lambda_i g_i(\mathbf{x}),

where λi\lambda_i are the Lagrange multipliers for the equality constraints.

Procedure

  1. Construct the Lagrangian: Combine f(x)f(\mathbf{x}) and gi(x)g_i(\mathbf{x}) into L(x,λ)\mathcal{L}(\mathbf{x}, \boldsymbol{\lambda}).

  2. Stationary Points: Find critical points by solving:

    Lx=0andLλ=gi(x)=0.\frac{\partial \mathcal{L}}{\partial \mathbf{x}} = 0 \quad \text{and} \quad \frac{\partial \mathcal{L}}{\partial \boldsymbol{\lambda}} = g_i(\mathbf{x}) = 0.

    This ensures gradients of the objective and constraints are aligned.

  3. Solve: Solve the system of equations to find x\mathbf{x} and λ\boldsymbol{\lambda}.

Inequality Constraints (KKT Conditions)

For inequality constraints hj(x)0h_j(\mathbf{x}) \leq 0, introduce slackness conditions:

L(x,λ,μ)=f(x)+i=1mλigi(x)+j=1nμjhj(x),\mathcal{L}(\mathbf{x}, \boldsymbol{\lambda}, \boldsymbol{\mu}) = f(\mathbf{x}) + \sum_{i=1}^m \lambda_i g_i(\mathbf{x}) + \sum_{j=1}^n \mu_j h_j(\mathbf{x}),

where μj0\mu_j \geq 0. The KKT conditions are:

  1. xL=0\nabla_\mathbf{x} \mathcal{L} = 0,
  2. gi(x)=0g_i(\mathbf{x}) = 0,
  3. hj(x)0h_j(\mathbf{x}) \leq 0,
  4. μjhj(x)=0\mu_j h_j(\mathbf{x}) = 0 (complementary slackness).

Geometric Insight

The Lagrange multiplier λi\lambda_i measures the rate of change of the optimal f(x)f(\mathbf{x}) with respect to the constraint gi(x)g_i(\mathbf{x}). Think of it as a "shadow price" or sensitivity factor.