MATH 250 · Mathematics for Economics II
Unconstrained Optimization With Several Variables
Find the best mix of two or more choices by setting every partial derivative to zero, then reading the shape of the hill.
Key takeaways
- At an interior maximum or minimum of a smooth function, every partial derivative equals zero. These are the first-order conditions.
- Solving them gives candidate points, called critical points, but a critical point may be a peak, a valley or a saddle.
- A saddle goes up in one direction and down in another, like a mountain pass.
- Economic problems often include a story that tells you which kind of point you want.
- The next lesson gives a test that sorts peaks from valleys without drawing anything.
Maya runs a smoothie cart and sells two drinks: a green one and a berry one. Each week she picks how many cups of each to make. Make too few and she leaves money on the table. Make too many and she floods the market, drops the price and wears out her blender. Somewhere between those extremes sits her best week.
With one product, you found that best point by setting the derivative to zero, in finding maximums and minimums. Now there are two choices, and they push on each other, since the same blender and the same customers serve both drinks. The idea stays the same. You just need a zero-slope condition for every direction at once.
The first-order conditions
Suppose Maya's weekly profit, in dollars, depends on x hundred green cups and y hundred berry cups:
π(x, y) = 40x + 50y − x² − y² − xy (The Greek letter π is a common symbol for profit here, not the number 3.14.) The positive terms are what the cups earn at the start. The squared terms say each extra drink earns a little less, as the price falls with volume. The −xy term says the two drinks compete for the same customers and blender.
Think about being at the top of a hill. If you were still climbing in some direction, you would not be at the top. So at the peak, the slope must be flat in every direction. For a smooth function, that means each partial derivative is zero:
π_x = 40 − 2x − y = 0
π_y = 50 − 2y − x = 0 These are the first-order conditions. They form two equations in two unknowns, so we solve them as a system, a skill from systems of equations. From the first, y = 40 − 2x. Substitute into the second:
50 − 2(40 − 2x) − x = 0
50 − 80 + 4x − x = 0
3x = 30
x = 10 Then y = 40 − 2 × 10 = 20. Check the second condition: 50 − 2 × 20 − 10 = 50 − 40 − 10 = 0. It works. So the candidate is 10 hundred green cups and 20 hundred berry cups, which is 1,000 and 2,000 cups.
Profit there:
Example with made-up numbers.
Is that really the top? Test neighbors: at (11, 20), profit = 440 + 1000 − 121 − 400 − 220 = 699. At (10, 21): 400 + 1050 − 100 − 441 − 210 = 699. Both are lower than 700. Good sign.
The map of the hill
Recall level curves from the first lesson. For a peak, the level curves of profit are closed loops around the peak, like the contour lines around a hilltop. Each ring is a set of weekly plans that earn the same profit. Rings that sit farther from the peak earn less.
For Maya, the rings are ovals, slightly tilted because of the xy term. The inner ring is the plans worth $675, since 700 − 25 = 675. The outer one is worth $600.
Profit falls the farther you stray from the peak in any direction.
Three kinds of flat spot
Setting partials to zero finds every flat spot. But flat spots come in three flavors.
All three have zero slope in every direction. Only the shape around them differs.
The saddle deserves a little attention, because it is a trap. Take f(x, y) = x² − y². Then f_x = 2x and f_y = −2y, and both are zero at (0, 0). But move along the x-axis and f = x², which rises. Move along the y-axis and f = −y², which falls. The point is flat but it is neither a top nor a bottom. It is the pass between two peaks, where a hiker crosses.
For this reason, the first-order conditions are necessary but not sufficient. They must hold at an interior peak or valley, but they do not guarantee one.
A second example: the cheapest recipe
Let's find a minimum. A bakery's weekly cost of making x batches of bread and y batches of rolls, in dollars, is
C(x, y) = x² + y² − 4x − 6y + 20 First-order conditions:
C_x = 2x − 4 = 0 so x = 2
C_y = 2y − 6 = 0 so y = 3 At (2, 3), cost is 4 + 9 − 8 − 18 + 20 = 7. Is that a minimum? Compare a neighbor, say (3, 3): 9 + 9 − 12 − 18 + 20 = 8. And (2, 4): 4 + 16 − 8 − 24 + 20 = 8. Both are higher than 7, which fits a valley. Here the answer is clear, because each squared term opens upward like a bowl, and the other terms only slide the bowl around. The cost can never fall below 7, since C = (x − 2)² + (y − 3)² + 7 once you complete the squares: (x−2)² = x² − 4x + 4 and (y−3)² = y² − 6y + 9, which add to x² + y² − 4x − 6y + 13, and 13 + 7 = 20. Good.
Reading the first-order conditions as a story
The equations are not just algebra. Each one has an economic meaning. In Maya's case, π_x = 40 − 2x − y = 0 says the extra profit from one more green cup, which is the starting gain of 40 minus the crowding costs, has fallen to zero. At that point, making another green cup earns nothing, and making one fewer would lose nothing either. The same holds for the berry line.
Now see the link between the choices. Rewrite the green condition as x = (40 − y) ÷ 2. If Maya makes more berry drinks, the best number of green drinks falls. Rewrite the berry condition as y = (50 − x) ÷ 2. The same logic runs the other way. Each product is a rival to the other. The solution, (10, 20), is the one spot where both statements are true at the same moment: at y = 20 the green rule gives x = (40 − 20) ÷ 2 = 10, and at x = 10 the berry rule gives y = (50 − 10) ÷ 2 = 20. Each choice is the best reply to the other, which is a first taste of an idea you will meet again in game theory.
An economic use: one seller, two markets
A concert venue sells tickets to two groups: students and adults. They pay different prices, and the venue can charge each group separately. Suppose the price students will pay for q₁ tickets is P₁ = 100 − 2q₁, and the price adults will pay for q₂ tickets is P₂ = 80 − q₂. Each ticket costs the venue $20 to serve. Profit is revenue minus cost in each market:
π = (100 − 2q₁ − 20) × q₁ + (80 − q₂ − 20) × q₂
π = 80q₁ − 2q₁² + 60q₂ − q₂² The first-order conditions:
π_1 = 80 − 4q₁ = 0 so q₁ = 20
π_2 = 60 − 2q₂ = 0 so q₂ = 30 Prices follow: P₁ = 100 − 40 = $60 and P₂ = 80 − 30 = $50. Profit from students is 20 × (60 − 20) = $800, from adults 30 × (50 − 20) = $900, and the total is $1,700. Check with the formula: 80 × 20 − 2 × 400 + 60 × 30 − 900 = 1,600 − 800 + 1,800 − 900 = 1,700.
Look at the first-order conditions again. Each one contains only its own variable. There is no cross term like −xy linking the markets, so the two problems separate, and each can be solved on its own. The condition 80 − 4q₁ = 0 is the old rule of one-variable economics, marginal revenue (100 − 4q₁) equals marginal cost (20). Multivariable optimization contains that rule and goes beyond it: when the products affect each other, the conditions become a system, as with Maya.
More than two choices
Nothing in the method stops at two variables. A firm choosing three inputs, x, y and z, faces three first-order conditions and three unknowns. Suppose profit is π = 10x + 12y + 14z − x² − y² − z². Setting each partial to zero:
10 − 2x = 0 so x = 5
12 − 2y = 0 so y = 6
14 − 2z = 0 so z = 7 Profit there is 50 + 72 + 98 − 25 − 36 − 49 = 110. The hill now lives in four dimensions (three choices plus the profit), which nobody can draw. Algebra carries on where the pictures stop. This is one reason economists prefer equations to graphs once a problem has more than two moving parts: the graph is a way to build intuition, and the algebra is what scales.
Why the saddle matters in real economics
You might think saddles are a curiosity. They are not. Many economic models have saddle-shaped solutions, and a solution that looks "flat" can mislead a planner. A firm that sets its partials to zero and reads the result as maximum profit, when the point is a saddle, would be at a point where one change of plan raises profit and another lowers it. Sorting peaks from saddles is the job of the next lesson, and it is essential before anyone bets money on the answer.
The recipe
Step 4 is covered in second-order conditions, concavity and convexity. For Maya, the test will confirm the peak. For now, a plain-English check often works: ask whether the story has a natural best answer. A profit function that falls off with volume, like Maya's, has a peak. A cost function with growing congestion has a valley.
A common mistake
The favorite mistake is solving only one of the first-order conditions. Students set π_x = 0, find x in terms of y, and stop. You need all of them, together, because the best amount of green cups depends on how many berry cups you also make. With the xy term, π_x = 40 − 2x − y = 0 says the best x shrinks as y grows. Decide both at once.
A second mistake is trusting a critical point without checking. A student who finds f_x = f_y = 0 at the origin of x² − y² and calls it "the maximum" has a saddle instead.
A third mistake is forgetting that the conditions apply to interior points. If Maya can make at most 5 hundred green cups, the best plan might sit on that limit with a nonzero slope. Problems with limits need other tools, which arrive in the lesson on Lagrange multipliers.
Words to know
Objective function the thing you want to make as large or as small as possible, such as profit or cost.
First-order conditions the equations setting every partial derivative of the objective to zero.
Critical point a point where all the partial derivatives are zero.
Maximum a point where the function is higher than at every nearby point.
Minimum a point where the function is lower than at every nearby point.
Saddle point a flat point that is a peak along one direction and a valley along another.
Interior solution a best point that lies strictly inside the allowed region, not on its edge.
Check yourself
- For π = 40x + 50y − x² − y² − xy, compute π_x and π_y at x = 8, y = 10. Are we at the top?
- Find the critical point of f(x, y) = 12x + 8y − x² − 2y².
- What is the value of f at that point?
- For C = x² + y² − 4x − 6y + 20, why can the cost never fall below 7?
- Show that the origin is a critical point of f = x² − y² but not a maximum or a minimum.
- Explain why solving only π_x = 0 is not enough to find the best plan.
Show the answers
- π_x = 40 − 16 − 10 = 14 and π_y = 50 − 20 − 8 = 22; both are nonzero, so not at the top; profit can still rise.
- f_x = 12 − 2x = 0 gives x = 6, and f_y = 8 − 4y = 0 gives y = 2.
- f(6, 2) = 72 + 16 − 36 − 8 = 44.
- Completing the squares gives C = (x − 2)² + (y − 3)² + 7, and squares are never negative, so C ≥ 7.
- f_x = 2x and f_y = −2y vanish at (0, 0), but f = x² > 0 along the x-axis and f = −y² < 0 along the y-axis, so it is a saddle.
- The best x depends on y (the cross term links them), so both first-order conditions must hold together as a system.