Constrained Optimization with Calculus

Christopher Makler

Stanford University Department of Economics

Econ 50: Lecture 7

Choice space:
all possible options

Feasible set:
all options available to you

Optimal choice:
Your best choice(s) of the ones available to you

Constrained Optimization

Choice Space
(all colleges plus alternatives)

Feasible Set
(colleges you got into)

Your optimal choice!

Preferences

Preferences describe how the agent ranks all options in the choice space.

For example, we'll assume that you could rank all possible colleges
(and other options for what to do after high school) based upon your preferences.

Preference Ranking

Found a startup

Harvard

Stanford

Play Xbox in parents' basement

Cal

Choice space

Feasible set

Optimal
choice!

Found a startup

Stanford

Cal

Harvard

Play XBox in parents' basement

Optimal choice is the highest-ranking option in the feasible set.

Today's Agenda

Part 1: A Short Math Review

Part 2: Economic Intuition

Unconstrained optimization

Constrained optimization and Lagrange

Interpreting the Lagrange multiplier

Graphs: PPFs and indifference curves

Words: MRS vs MRT

Math: applying Lagrange

Unconstrained Optimization

Constrained Optimization

Canonical Constrained Optimization Problem

f(x_1,x_2)
\text{s.t. }
g(x_1,x_2) = k
k - g(x_1,x_2) = 0
\mathcal{L}(x_1,x_2,\lambda)=
\displaystyle{\max_{x_1,x_2}}
f(x_1,x_2)
k - g(x_1,x_2)
+ \lambda\ (
)

Suppose \(g(x_1,x_2)\) is monotonic (increasing in both \(x_1\) and \(x_2\)).

Then \(k - g(x_1,x_2)\) is negative if you're outside of the constraint,
positive if you're inside the constraint,
and zero if you're along the constraint.

OBJECTIVE

FUNCTION

CONSTRAINT

\mathcal{L}(x_1,x_2,\lambda)=
f(x_1,x_2)
k - g(x_1,x_2)
+ \lambda\ (
)
\displaystyle{\partial \mathcal{L} \over \partial x_1} =

FIRST ORDER CONDITIONS

\displaystyle{\partial \mathcal{L} \over \partial x_2} =
\displaystyle{\partial \mathcal{L} \over \partial \lambda} =
\displaystyle{\partial f \over \partial x_1}
\displaystyle{\partial f \over \partial x_2}
k - g(x_1,x_2)
=0
- \lambda\ \times
\displaystyle{\partial g \over \partial x_1}
\displaystyle{\partial g \over \partial x_2}
- \lambda\ \times
=0
=0

3 equations, 3 unknowns

 

Solve for \(x_1\), \(x_2\), and \(\lambda\)

How does the Lagrange method work?

It finds the point along the constraint where the
level set of the objective function passing through that point
is tangent to the constraint

\mathcal{L}(x_1,x_2,\lambda)=
f(x_1,x_2)
k - g(x_1,x_2)
+ \lambda\ (
)
\displaystyle{\partial \mathcal{L} \over \partial x_1} =

FIRST ORDER CONDITIONS

\displaystyle{\partial \mathcal{L} \over \partial x_2} =
\displaystyle{\partial \mathcal{L} \over \partial \lambda} =
\displaystyle{\partial f \over \partial x_1}
\displaystyle{\partial f \over \partial x_2}
k - g(x_1,x_2)
=0
- \lambda\ \times
\displaystyle{\partial g \over \partial x_1}
\displaystyle{\partial g \over \partial x_2}
- \lambda\ \times
=0
=0
\displaystyle{\Rightarrow \lambda\ = {{\partial f /\partial x_1} \over {\partial g/\partial x_1}}}
\displaystyle{\Rightarrow \lambda\ = {{\partial f /\partial x_2} \over {\partial g/\partial x_2}}}
\displaystyle{\Rightarrow {{\partial f /\partial x_1} \over {\partial f/\partial x_2}} = {{\partial g /\partial x_1} \over {\partial g/\partial x_2}}}

TANGENCY
CONDITION

CONSTRAINT

Example: Fence Problem

You have 40 feet of fence and want to enclose the maximum possible area.

Example: Fence Problem

You have 40 feet of fence and want to enclose the maximum possible area.

f(x_1,x_2)
\text{s.t. }
g(x_1,x_2) = k
k - g(x_1,x_2) = 0
\mathcal{L}(L,W,\lambda)=
\displaystyle{\max_{x_1,x_2}}
L \times W
40 - 2L - 2W
+ \lambda\ (
)

OBJECTIVE

FUNCTION

CONSTRAINT

L \times W
40 - 2L - 2W = 0
2L + 2W = 40
\mathcal{L}(L,W,\lambda)=
L \times W
40 - 2L - 2W
+ \lambda\ (
)
\displaystyle{\partial \mathcal{L} \over \partial L} =

FIRST ORDER CONDITIONS

\displaystyle{\partial \mathcal{L} \over \partial W} =
\displaystyle{\partial \mathcal{L} \over \partial \lambda} =
W
L
40 - 2L - 2W
=0
- \lambda\ \times
2
2
- \lambda\ \times
=0
=0
\displaystyle{\Rightarrow \lambda\ = {W \over 2}}
\displaystyle{\Rightarrow \lambda\ = {L \over 2}}
W = L

TANGENCY
CONDITION

CONSTRAINT

2L + 2W = 40
W = L

TANGENCY
CONDITION

CONSTRAINT

2L + 2W = 40

Meaning of the Lagrange multiplier

Suppose you have \(F\) feet of fence instead of 40.

\displaystyle{\partial \mathcal{L} \over \partial L} =
\displaystyle{\partial \mathcal{L} \over \partial W} =
\displaystyle{\partial \mathcal{L} \over \partial \lambda} =
W
L
F - 2L - 2W
=0
- \lambda\ \times
2
2
- \lambda\ \times
=0
=0
\displaystyle{\Rightarrow \lambda\ = {W \over 2}}
\displaystyle{\Rightarrow \lambda\ = {L \over 2}}
W = L

TANGENCY
CONDITION

CONSTRAINT

2L + 2W = F

SOLUTIONS

L^* = {F \over 4}
W^* = {F \over 4}
\lambda^* = {F \over 8}

Meaning of the Lagrange multiplier

Suppose you have \(F\) feet of fence instead of 40.

SOLUTIONS

L^* = {F \over 4}
W^* = {F \over 4}
\lambda^* = {F \over 8}

Maximum enclosable area as a function of F:

A^*(F) = L^*(F) \times W^*(F) = {F \over 4} \times {F \over 4} = {F^2 \over 16}

Meaning of the Lagrange multiplier

Suppose you have \(F\) feet of fence instead of 40.

\mathcal{L}(L,W,\lambda)=
L \times W
40 - 2L - 2W
+ \lambda\ (
)

Fish vs. Coconuts

  • Can spend your time catching fish (good 1) or collecting coconuts (good 2)
  • What is your optimal division of labor between the two?
  • Intuitively: if you're optimizing, you couldn't reallocate your time
    in a way that would make you better off.

Graphical Analysis:
PPFs and Indifference Curves

The story so far, in two graphs

Production Possibilities Frontier
Resources, Production Functions → Stuff

Indifference Curves
Stuff → Happiness (utility)

Both of these graphs are in the same "Good 1 - Good 2" space

Better to produce
more good 1
and less good 2.

MRS
>
MRT

Better to produce
less good 1
and more good 2.

MRS
<
MRT

Better to produce
more good 1
and less good 2.

MRS
>
MRT
MRS
<
MRT

“Gravitational Pull" Towards Optimality

Better to produce
more good 2
and less good 1.

These forces are always true.

In certain circumstances, optimality occurs where MRS = MRT.

Verbal Analysis: MRS, MRT, and the “Gravitational Pull" towards Optimality 

Marginal Rate of Transformation (MRT)

  • The  number of coconuts you need to give up in order to get another fish
  • Opportunity cost of fish in terms of coconuts

Marginal Rate of Substitution (MRS)

  • The number of coconuts you are willing to give up in order to get another fish
  • Willingness to "pay" for fish in terms of coconuts

Both of these are measured in
coconuts per fish

(units of good 2/units of good 1)

Marginal Rate of Transformation (MRT)

  • The  number of coconuts you need to give up in order to get another fish
  • Opportunity cost of fish in terms of coconuts

Marginal Rate of Substitution (MRS)

  • The number of coconuts you are willing to give up in order to get another fish
  • Willingness to "pay" for fish in terms of coconuts

Opportunity cost of marginal fish produced is less than the number of coconuts
you'd be willing to "pay" for a fish.

Opportunity cost of marginal fish produced is more than the number of coconuts
you'd be willing to "pay" for a fish.

Better to spend less time fishing
and more time making coconuts.

Better to spend more time fishing
and less time collecting coconuts.

MRS
>
MRT
MRS
<
MRT

Mathematical Analysis:
Lagrange Multipliers 

 We've just seen that, at least under certain circumstances, the optimal bundle is
"the point along the PPF where MRS = MRT."

CONDITION 1:
CONSTRAINT CONDITION

CONDITION 2:
TANGENCY
 CONDITION

This is just an application of the Lagrange method!

Example: Linear PPF, Cobb-Douglas Utility

Chuck has 150 hours of labor, and can produce 3 fish per hour or 2 coconuts per hour.

His preferences may be represented by the utility function \(u(x_1,x_2) = x_1^2x_2\)

To find the equation of his PPF, we invert the production functions and plug them in to the resource constraint:

L_1(x_1) = {1 \over 3}x_1
L_2(x_2) = {1 \over 2}x_2
{1 \over 3}x_1 + {1 \over 2}x_2 = 150
f_1(L_1) = 3L_1
f_2(L_2) = 2L_2
L_1 + L_2 = 150

Production function for fish

Production function for coconuts

Resource constraint

Example: Linear PPF, Cobb-Douglas Utility

Chuck has 150 hours of labor, and can produce 3 coconuts per hour or 2 fish per hour.

His preferences may be represented by the utility function \(u(x_1,x_2) = x_1^2x_2\)

\text{s.t. }
\mathcal{L}(L,W,\lambda)=
\displaystyle{\max_{x_1,x_2}}
x_1^2x_2
150 - {1 \over 3}x_1 - {1 \over 2}x_2
+ \lambda\ (
)

OBJECTIVE

FUNCTION

CONSTRAINT

x_1^2x_2
150 - {1 \over 3}x_1 - {1 \over 2}x_2 = 0
{1 \over 3}x_1 + {1 \over 2}x_2 = 150
\mathcal{L}(L,W,\lambda)=
x_1^2x_2
150 - {1 \over 3}x_1 - {1 \over 2}x_2
+ \lambda\ (
)
\displaystyle{\partial \mathcal{L} \over \partial x_1} =

FIRST ORDER CONDITIONS

\displaystyle{\partial \mathcal{L} \over \partial x_2} =
\displaystyle{\partial \mathcal{L} \over \partial \lambda} =
2x_1x_2
x_1^2
150 - {1 \over 3}x_1 - {1 \over 2}x_2
=0
- \lambda\ \times
{1 \over 3}
{1 \over 2}
- \lambda\ \times
=0
=0
\displaystyle{\Rightarrow \lambda\ = \ \ \ \ \ \ \ \ \ \ \ \times}
{1 \over 3}x_1 + {1 \over 2}x_2 = 150
\displaystyle{\Rightarrow \lambda\ = \ \ \ \ \ \ \ \ \ \ \ \times}
2x_1x_2
x_1^2
3
2
MU_1
MU_2
MP_{L1}
MP_{L2}
\Rightarrow

Utility from last hour spent fishing

Utility from last hour spent collecting coconuts

Equation of PPF

\displaystyle{\lambda\ = \ \ \ \ \ \ \ \ \ \ \ \times}
{1 \over 3}x_1 + {1 \over 2}x_2 = 150
\displaystyle{ = \ \ \ \ \ \ \ \ \ \ \ \times}
2x_1x_2
x_1^2
3
2
MU_1
MU_2
MP_{L1}
MP_{L2}

Utility from last hour spent fishing

Utility from last hour spent collecting coconuts

Equation of PPF

{1 \over 3}x_1 + {1 \over 2}x_2 = 150
=
2x_1x_2
x_1^2
3
2
MU_1
MU_2
MP_{L1}
MP_{L2}

Equation of PPF

TANGENCY
CONDITION

MRS

MRT

CONSTRAINT

pollev.com/chrismakler

Suppose your preferences may be represented by the utility function

\(u(x_1,x_2) = a \ln x_1 + b \ln x_2\).

What happens to the slope of the line representing the tangency condition if a increases?

Videos of Worked Examples

  • There are videos of worked examples for this class. Watch them, pause them, work along with them.

Next Time

Examine cases where the optimal bundle is not characterized by a tangency condition.

New concepts:
corner solutions and kinks.

Econ 50 | Spring 23 | Lecture 7

By Chris Makler

Econ 50 | Spring 23 | Lecture 7

Constrained Optimization with Calculus

  • 548