The Lagrange Method Explained- Step-by-Step Problem Solving
What the Lagrange Method Actually Is
The Lagrange method is a strategy for finding local maxima and minima of functions when you have constraints. That's it. No magic, no mystery—just math.
You encounter this when you need to optimize something but can't just set derivatives to zero. Something's holding you back. A budget limit. A fixed amount of material. A requirement that must be satisfied. That's your constraint, and the Lagrange multiplier is how you handle it.
When to Use Lagrange Multipliers
You'll need this method when:
- You have an objective function you want to optimize
- You have one or more equality constraints
- Regular differentiation won't work because the optimum lies on a boundary
If you're maximizing profit but can't exceed a production capacity, or minimizing cost while hitting a performance target—Lagrange multipliers are your tool.
The Core Concept
Here's the blunt truth: at an optimum point on a constraint boundary, the gradient of your objective function is parallel to the gradient of your constraint.
Why? Because if they weren't parallel, you could move along the constraint to improve your objective. The constraint boundary acts like a wall. When you're at the best possible point on that wall, the direction of steepest ascent of your objective function points directly along the wall—not into it or away from it.
The Lagrange multiplier λ (lambda) represents the rate at which your optimal value would change if you relaxed the constraint by one unit. That's useful information on its own.
Step-by-Step: Setting Up the Lagrange Function
Given an objective function f(x, y) and a constraint g(x, y) = c:
Step 1: Build the Lagrangian
Create a new function:
L(x, y, λ) = f(x, y) − λ(g(x, y) − c)
The λ term connects your objective to your constraint. Some textbooks use a plus sign; it's just a convention. The math works either way.
Step 2: Take Partial Derivatives
Set up a system of equations by taking partial derivatives with respect to each variable:
- ∂L/∂x = 0
- ∂L/∂y = 0
- ∂L/∂λ = 0
The third equation simply recovers your constraint: g(x, y) = c.
Step 3: Solve the System
You now have three equations with three unknowns. Solve for x, y, and λ. Expect multiple solutions. Each candidate point must be checked against the constraint and evaluated in the original objective function.
Step 4: Evaluate and Classify
Plug your candidate points into f(x, y). Compare values. If you need a maximum, pick the highest. Minimum? Pick the lowest. Sometimes you'll need the second derivative test or additional reasoning to classify a point.
A Worked Example
Problem: Maximize f(x, y) = xy subject to x² + y² = 8.
Step 1: The constraint is x² + y² = 8, so g(x, y) = x² + y² and c = 8.
The Lagrangian: L = xy − λ(x² + y² − 8)
Step 2: Partial derivatives:
- ∂L/∂x = y − 2λx = 0
- ∂L/∂y = x − 2λy = 0
- ∂L/∂λ = −(x² + y² − 8) = 0 → x² + y² = 8
Step 3: From the first equation: y = 2λx
From the second: x = 2λy
Substituting: x = 2λ(2λx) = 4λ²x
If x ≠ 0, then 4λ² = 1, so λ = ±1/2
Case 1: λ = 1/2 → y = x. Combined with x² + y² = 8 gives 2x² = 8, so x = ±2, y = ±2 (same sign).
Points: (2, 2) and (−2, −2)
Case 2: λ = −1/2 → y = −x. Combined with x² + y² = 8 gives 2x² = 8, so x = ±2, y = ∓2 (opposite signs).
Points: (2, −2) and (−2, 2)
Step 4: Evaluate f(x, y) = xy at each point:
- f(2, 2) = 4
- f(−2, −2) = 4
- f(2, −2) = −4
- f(−2, 2) = −4
Maximum value is 4 at (2, 2) and (−2, −2). Minimum is −4 at the other two points.
Common Mistakes That Waste Time
- Forgetting the constraint equation when solving. The λ equation is not optional—it's how you enforce the constraint.
- Assuming all solutions are valid. Some algebraic manipulations (like dividing by a variable) can lose solutions. Always check.
- Not checking boundary points when working with inequalities. Lagrange multipliers solve equality constraints. For inequalities, you need KKT conditions or separate boundary analysis.
- Getting λ confused. The multiplier itself is often meaningless unless you're doing sensitivity analysis. Don't read too much into its value.
Lagrange Method vs. Other Approaches
Here's how this stacks up against alternatives:
| Method | Best For | Drawbacks |
|---|---|---|
| Lagrange Multipliers | Equality constraints, smooth functions | System of equations can be messy |
| Substitution | Simple constraints, low dimensions | Gets ugly fast with multiple constraints |
| Parametrization | Curves with easy parametrization | Not always possible; adds complexity |
| KKT Conditions | Inequality constraints | More variables, more cases to check |
| Numerical Methods | Complex, real-world problems | Approximate, requires computation |
Multiple Constraints? Here's How That Works
When you have two constraints like g₁(x, y, z) = 0 and g₂(x, y, z) = 0, you add a multiplier for each:
L = f − λ₁g₁ − λ₂g₂
Now you have five unknowns and five equations. The geometry extends naturally: you're finding where the objective function's gradient lies in the plane spanned by the constraint gradients.
Three or more constraints follow the same pattern. The algebra gets heavier, but the logic doesn't change.
Getting Started: Your Quick Reference
- Identify f—your objective function
- Identify g—your constraint written as g = 0 or g = constant
- Write L = f − λg
- Take ∂L/∂x, ∂L/∂y, ∂L/∂λ (add variables as needed)
- Solve the system
- Evaluate candidates in the original f
- Pick the max or min
Practice with simple functions first. A circle constraint with a linear or quadratic objective. Once that's automatic, move to harder problems.
When This Gets Complicated
The method assumes your functions are differentiable and that the constraint qualification holds—basically, that the constraint surface isn't doing something weird at your candidate point (like having a cusp).
If your constraint surface has a corner or edge exactly where you're trying to optimize, Lagrange multipliers might miss it. Check your constraint's behavior. If it looks pathological, handle that point separately.
For non-smooth optimization or integer constraints, this method doesn't apply. You'll need linear programming, dynamic programming, or other specialized techniques.