Maximization With Constraint: The Art of Doing Your Best With Limits
Imagine you are a student with ₹100 to spend on lunch. You love pizza (₹20 a slice) and you love juice (₹10 a glass). You want the most satisfying meal — the maximum "happiness" — but you cannot spend more than ₹100. That is a constrained maximization problem.
Without the ₹100 limit, you would eat infinite pizza and drink infinite juice. But reality imposes a boundary. The question becomes: given your limited budget, which combination of pizza and juice gives you the greatest possible satisfaction?
This is the core of every constrained maximization problem: you have something you want to maximize (happiness, profit, area, speed) and a restriction that limits your choices (money, materials, time, a physical law). The trick is to find the best possible outcome within that restriction, not the best possible outcome in an imaginary world with no limits.
The Precise Statement
A constrained maximization problem has three parts:
-
The Objective Function — the thing you want to maximize. Call it f(x,y). In our example, f is your "satisfaction" from x slices of pizza and y glasses of juice.
-
The Constraint — the rule that limits your choices. Usually written as g(x,y)=c (or ≤c). Here: 20x+10y=100 (you must spend exactly ₹100).
-
The Decision Variables — the things you control. Here: x (pizza slices) and y (glasses of juice).
The problem is:
Maximize f(x,y)subject to g(x,y)=c
You are searching over all pairs (x,y) that satisfy the constraint, and picking the one that makes f largest.
The constraint reduces the set of possible choices. Without it, you would just find where f is biggest everywhere. With it, you must stay on the curve (or inside the region) defined by g(x,y)=c.
The Key Insight: Tangency
Here is the conceptual leap. Imagine you draw a map of your satisfaction — contour lines where f is constant (like elevation lines on a hiking map). Each contour is a curve: "all combinations of pizza and juice that give 10 units of happiness," then 11, then 12, and so on.
Now draw the budget line: 20x+10y=100, a straight line.
You want the highest possible contour that still touches the budget line. That happens where the budget line is tangent to a contour — just barely kissing it. If the budget line cuts through a contour, you can slide along it to a higher contour. The optimum is the point where you cannot improve without leaving the budget.
Tangency means the slope of the contour (the marginal rate of substitution in economics) equals the slope of the budget line (the price ratio). In general, it means the gradient of f is parallel to the gradient of g: ∇f=λ∇g, where λ is the Lagrange multiplier.
The Method: Lagrange Multipliers
The tangency condition leads to a systematic method. To maximize f(x,y) subject to g(x,y)=c:
- Form the Lagrangian:
L(x,y,λ)=f(x,y)−λ(g(x,y)−c)
- Set all partial derivatives to zero:
∂x∂L=0,∂y∂L=0,∂λ∂L=0
- Solve the system. The third equation just gives back g(x,y)=c. The first two enforce ∇f=λ∇g.
The Lagrange multiplier λ has a real meaning: it tells you how much the maximum value of f would increase if you relaxed the constraint by one unit. In the pizza-juice problem, λ is the "marginal happiness per rupee" at the optimum.
A Concrete Example
Maximize f(x,y)=xy (area of a rectangle) subject to x+y=10 (fixed perimeter).
Intuition: Among all rectangles with perimeter 20 (so x+y=10), which has the largest area? You might guess a square.
Lagrangian:
L=xy−λ(x+y−10)
Derivatives:
∂x∂L=y−λ=0⇒y=λ
∂y∂L=x−λ=0⇒x=λ
∂λ∂L=−(x+y−10)=0⇒x+y=10
From x=λ and y=λ, we get x=y. Then x+y=10 gives 2x=10, so x=5, y=5. The maximum area is 5×5=25.
A common mistake is to forget that the constraint must be satisfied exactly at the optimum. The Lagrangian method builds it in automatically, but when solving manually, always check that your candidate point lies on g(x,y)=c.
Why This Matters
Every optimization in the real world is constrained. A company maximizes profit subject to production capacity. A rocket trajectory minimizes fuel subject to reaching orbit. A student maximizes grades subject to study time. The concept of constrained maximization — and the tangency condition — is the single most powerful idea in optimization. It teaches you that the best choice is not the one that is best in isolation, but the one that is best relative to your limits.