Mathwords logoMathwords

Lagrange Multiplier — Definition, Formula & Examples

A Lagrange multiplier is a scalar variable introduced to find the maximum or minimum of a function subject to a constraint. It converts a constrained optimization problem into a system of equations you can solve using partial derivatives.

Given a function f(x1,,xn)f(x_1, \dots, x_n) to optimize subject to a constraint g(x1,,xn)=0g(x_1, \dots, x_n) = 0, the method of Lagrange multipliers states that at any local extremum where g0\nabla g \neq \mathbf{0}, there exists a scalar λ\lambda such that f=λg\nabla f = \lambda \, \nabla g. The value λ\lambda is called the Lagrange multiplier.

Key Formula

f=λgsubject tog(x1,,xn)=0\nabla f = \lambda \, \nabla g \quad \text{subject to} \quad g(x_1, \dots, x_n) = 0
Where:
  • ff = The objective function to be maximized or minimized
  • gg = The constraint function, set equal to zero
  • λ\lambda = The Lagrange multiplier (unknown scalar)
  • \nabla = The gradient operator (vector of all partial derivatives)

How It Works

To use Lagrange multipliers, set up the equation f=λg\nabla f = \lambda \, \nabla g alongside the constraint g=0g = 0. This produces n+1n + 1 equations in n+1n + 1 unknowns (the original variables plus λ\lambda). Solve the system simultaneously to find the candidate points. Evaluate ff at each candidate to determine which gives the maximum or minimum. The multiplier λ\lambda itself has a useful interpretation: it approximates how much the optimal value of ff changes per unit change in the constraint.

Worked Example

Problem: Find the maximum value of f(x,y)=xyf(x, y) = xy subject to the constraint x2+y2=8x^2 + y^2 = 8.
Set up the gradient equation: Write the constraint as g(x,y)=x2+y28=0g(x, y) = x^2 + y^2 - 8 = 0. Then f=λg\nabla f = \lambda \, \nabla g gives two component equations.
y=λ(2x),x=λ(2y)y = \lambda(2x), \quad x = \lambda(2y)
Solve for λ: From the first equation, λ=y2x\lambda = \frac{y}{2x}. From the second, λ=x2y\lambda = \frac{x}{2y}. Setting them equal:
y2x=x2y    y2=x2    y=±x\frac{y}{2x} = \frac{x}{2y} \implies y^2 = x^2 \implies y = \pm x
Apply the constraint: Substitute y=xy = x into x2+y2=8x^2 + y^2 = 8 to get 2x2=82x^2 = 8, so x=±2x = \pm 2. The candidate points are (2,2)(2, 2), (2,2)(-2, -2), (2,2)(2, -2), and (2,2)(-2, 2).
f(2,2)=4,f(2,2)=4,f(2,2)=4,f(2,2)=4f(2, 2) = 4, \quad f(-2, -2) = 4, \quad f(2, -2) = -4, \quad f(-2, 2) = -4
Answer: The maximum value of ff is 44, occurring at (2,2)(2, 2) and (2,2)(-2, -2).

Why It Matters

Lagrange multipliers appear throughout economics (utility maximization under a budget constraint), physics (energy minimization), and machine learning (support vector machines). Mastering this technique is essential for any course in multivariable calculus or mathematical optimization.

Common Mistakes

Mistake: Forgetting to rewrite the constraint in the form g=0g = 0 before computing g\nabla g.
Correction: Always rearrange the constraint so one side equals zero — for example, rewrite x2+y2=8x^2 + y^2 = 8 as g(x,y)=x2+y28=0g(x, y) = x^2 + y^2 - 8 = 0 — before taking partial derivatives of gg.