skip to content

How do Lagrange multipliers solve maximizing x*y subject to x + y = 10?

level: middleimportance: must knowfreq 60%

answer

  1. give the constraint a price
  2. one extra unknown per constraint
  3. set every partial to zero, lambda included
  4. the two gradients line up at the optimum
  5. here x = y = lambda

basics

~20 s

Form L = xy - lambda(x + y - 10) and set every partial derivative to zero. The solution is x = y = 5 with lambda = 5, so the largest achievable product is 25.

solid answer

~50 s

Instead of eliminating the constraint, you give it a price. Define the Lagrangian `L(x, y, lambda) = x*y - lambda*(x + y - 10)` and set all three partial derivatives to zero: `dL/dx = y - lambda = 0`, `dL/dy = x - lambda = 0`, and `dL/dlambda = -(x + y - 10) = 0`, which simply restores the constraint. The first two say `x = y = lambda`; combined with the third, `2*lambda = 10`, so `x = y = 5`, `lambda = 5`, and the maximum product is 25. The first two equations together say that at the optimum the objective's gradient is a scalar multiple of the constraint's gradient, with `lambda` as that scalar: no feasible direction is left that still improves the objective. Substitution works on this toy problem, but the multiplier form scales to many variables and several simultaneous constraints, where solving for one variable is not possible.

go deeper

for a junior

Be ready to write the Lagrangian for a single equality constraint and grind the small system by hand. Knowing that x = y = 5 maximizes the product under x + y = 10 is the expected takeaway.

for a middle

Explain why the stationarity equations say the objective gradient is a multiple of the constraint gradient, and why the derivative in lambda simply restores feasibility rather than adding new information.

for a senior

Show where substitution breaks down - several coupled constraints, or a constraint you cannot solve for any one variable - and why the multiplier form stays symmetric and solvable numerically.

for a principal

Own the framing: decide what belongs in the constraint set at all, and be able to explain the method to non-specialists in pricing terms rather than in partial derivatives.

## The problem A constrained optimization problem has two parts: an **objective** you want to push as high (or as low) as possible, and a **constraint** limiting which points you may consider. In `maximize x*y subject to x + y = 10`, the objective is `f(x, y) = x*y` and the constraint is the line `g(x, y) = x + y = 10`. Only points on that line are *feasible*; a huge product at a point off the line is worthless. The unconstrained instinct - set both partial derivatives of the objective to zero - fails immediately. `df/dx = y` and `df/dy = x`, so it would demand `x = y = 0`, which is not even on the line. The constraint has to enter the equations themselves, not act as a filter applied afterwards. ## The Lagrangian Lagrange's method introduces one extra unknown, the **multiplier** `lambda`, for each equality constraint, and folds objective and constraint into one function. Rewrite the constraint so one side is zero (`x + y - 10 = 0`) and attach it with weight `lambda`: `L(x, y, lambda) = x*y - lambda*(x + y - 10)` Now treat `L` as an ordinary unconstrained function of all three variables and set every partial derivative to zero: - `dL/dx = y - lambda = 0` - `dL/dy = x - lambda = 0` - `dL/dlambda = -(x + y - 10) = 0` The third equation is the constraint itself; that is precisely why `lambda` is made a variable rather than a fixed number. The first two give `x = lambda` and `y = lambda`. Substituting into the third, `2*lambda = 10`, so `lambda = 5`, `x = y = 5`, and the maximum product is `25`. ## What the stationarity equations mean Written together, the first two conditions are `df/dx = lambda * dg/dx` and `df/dy = lambda * dg/dy`: at the optimum the objective's gradient equals a scalar multiple of the constraint's gradient, and `lambda` is that scalar. The geometric content is that at any feasible point where the two gradients are *not* proportional, there is still a direction that stays on the constraint and increases the objective, so you cannot be at the best feasible point. The search stops only when the objective's push has been fully absorbed by the constraint. ## Confirming it is a maximum Stationarity is a first-order condition: it produces candidates, not verdicts. Here it can be settled directly. On the line, `y = 10 - x`, so the product is `x*(10 - x) = -x^2 + 10*x`, a downward-opening parabola peaking at `x = 5`. It has no minimum at all - push `x` up and `y` down and the product runs to minus infinity - so `(5, 5)` with value 25 is the maximum. In bigger problems you check a second-order condition restricted to directions that stay on the constraint surface, or you invoke concavity of the objective over a convex feasible set. ## Why bother, when substitution works? On two variables and one linear constraint, substitution is faster. It stops being an option when the constraint cannot be solved for any single variable in closed form, when there are several constraints that interact, or when the problem is symmetric and substitution destroys that symmetry (here the symmetric answer `x = y` falls out of the equations rather than being spotted). The multiplier form also keeps the problem in a shape a numerical solver can attack directly, and it produces `lambda` as a by-product, which carries real information about how binding the constraint is. ## Several constraints, and the sign convention With several equality constraints you add one multiplier each: `L = f - sum_j lambda_j * (g_j - c_j)`, and you set the partial derivative with respect to every variable and every multiplier to zero. For equality constraints the sign convention is cosmetic - writing `+ lambda` instead of `- lambda` only flips the sign of the recovered multiplier, and the same optimal point solves both. The convention starts to matter for inequality constraints, where multipliers are required to be nonnegative and the sign encodes which side the constraint pushes from. ## The fine print The method assumes the objective and constraint are differentiable near the candidate, and it needs a **constraint qualification**: roughly, the constraint gradients must not degenerate at the point (for a single constraint, `dg` must not vanish there). Without it, a genuine optimum can fail to satisfy the stationarity equations at all. And stationary points of `L` are candidates for maxima, minima or neither, so the second-order or convexity check is not optional bookkeeping.

  • Why does differentiating with respect to lambda just hand back the constraint?
    Because `lambda` multiplies the term `(x + y - 10)` and appears nowhere else. Differentiating in `lambda` leaves exactly `-(x + y - 10)`, and setting that to zero forces `x + y = 10`. That is the bookkeeping which guarantees the stationary point of the Lagrangian is a feasible point of the original problem; the multiplier is made a variable for exactly this reason.
  • How do you know (5, 5) is a maximum rather than a minimum?
    Substitute the constraint back in: on `x + y = 10`, the product is `x*(10 - x) = -x^2 + 10*x`, a downward parabola. It peaks at `x = 5` with value 25 and has no minimum, since the product falls without bound as `x` grows. Generally you need a second-order check along the constraint surface, or a convexity argument; stationarity alone never settles it.
  • How does the method change when there are three constraints instead of one?
    You add one multiplier per equality constraint: `L = f - lambda_1*(g_1 - c_1) - lambda_2*(g_2 - c_2) - lambda_3*(g_3 - c_3)`. Stationarity then says the objective gradient is a linear combination of the three constraint gradients, with the multipliers as coefficients. You still set every partial derivative, including each multiplier's, to zero, and solve the resulting system.

Rather than forbidding overspending, you charge a fee per unit spent and then tune the fee until the free-spending optimum happens to land exactly on budget. The fee is the multiplier.

saying these in an interview costs you the question

  • Sets only the objective's partials to zero and ignores the constraint
  • Forgets to differentiate with respect to the multiplier
  • Claims any stationary point of the Lagrangian is automatically a maximum
  • Substitutes the constraint away and then also adds a multiplier for it
  • Calls the multiplier a meaningless algebraic device with no interpretation

context