• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 14:15
CET 20:15
KST 04:15
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband
Tourneys
Sea Duckling Open (Global, Bronze-Diamond) $5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest RSL Revival: Season 3 Tenacious Turtle Tussle
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
Which season is the best in ASL? Data analysis on 70 million replays BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions BW General Discussion
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET [BSL21] RO16 Group C - Saturday 21:00 CET Small VOD Thread 2.0
Strategy
Game Theory for Starcraft How to stay on top of macro? Current Meta PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread ZeroSpace Megathread Nintendo Switch Thread The Perfect Game Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine US Politics Mega-thread The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
James Bond movies ranking - pa…
Topin
Esports Earnings: Bigger Pri…
TrAiDoS
Thanks for the RSL
Hildegard
Saturation point
Uldridge
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1672 users

Caller’s Tutorial: Economics, Part II

Blogs > Caller
Post a Reply
Caller
Profile Blog Joined September 2007
Poland8075 Posts
Last Edited: 2009-11-21 09:13:15
November 21 2009 05:07 GMT
#1
Part 1: http://www.teamliquid.net/blogs/viewblog.php?topic_id=106061

To those of you whom attempt to solve the Utility Maximization Problem, you will probably see something crazy like this:

Maximize U(x1, x2) s.t. M = p1x1 + p2x2
L = U(x1, x2) + λ(M-p1x1 + p2x2)
dL/dx1 = du/dx1 – λp1
dL/dx2 = du/dx2 – λp2
dL/d λ = M –p1x1 + p2x2


WTF???

Fortunately, I’ll help you take this apart. The idea of the above is called Lagrangian multipliers. It’s a way to optimize problems while avoiding as much butthurt as possible, unless you’re good at math, in which case you can probably derive an easier way to do this. Of course, if you’re good at math, you wouldn’t need my help to do this either, so good luck For those of us who aren’t gods among men, here’s an easier way to do this.

The first statement is this:

Maximize U(x1, x2) s.t. M = p1x1 + p2x2


This is simply stating that this is an optimization problem. It says the following in a sentence:
Find the maximum utility that somebody could get from purchasing a certain amount of two items (x1 and x2). However, they have a certain budget (M) that they can spend, and that each item has a price (p1, p2).

This is pretty obvious without the jargon: basically, what’s the most useful combination of things that you can buy with your money and their prices? You can pick how much you want of each kind-namely, you choose x1 and x2. These are what we call endogenous variables, because we are trying to figure those out. We don’t control p1, p2, and M (as those are external to our choice) so we call those exogenous variables.

The second statement is what we call the Lagrangian function. This is basically one of the easiest, most reliable ways to solve this problem. There is no such thing as a real life Lagrangian function-this is just us playing with the math in order to get a solution.

L = U(x1, x2) + λ(M-p1x1 - p2x2)


Now you may be wondering why the hell there is a lambda in our equation all of a sudden. The answer is that it is also a trick of math. Some people that are a lot smarter than I am and a lot better at math figured this out as a shortcut. I’m not going to bother doing the proof because I suck at proofs and I’m a lazy shit. Just pretend that it’s a formula or something.

In any case, we don’t know what lambda is, so we consider it a variable. However, we are trying to find our what we need for our two values, x1 and x2. To solve for them from this equation, we need to find a way to get them all together.

One very easy way is to simply take the partial derivatives of the Lagrangian function with respect to each endogenous variable. So…

dL/dx1 = du/dx1 – λp1
dL/dx2 = du/dx2 – λp2
dL/d λ = M –p1x1 - p2x2


The first expressions are us taking the Lagrangian function with the derivative. This is just mathematical trickery here. They are what we call First Order Conditions, or FOC, or FUUUUUUUUU~

However, we can figure out a little bit of what the hell is going on. We have two equations up there-namely, these two:

dL/dx1 = du/dx1 – λp1
dL/dx2 = du/dx2 – λp2


We want to figure out what x1 and x2 are, but we can’t really isolate them with the lambda present. Instead, we will do a little trick of math. Because this is an optimization problem, we can set the left side of the equation to be zero, so we get:

0 = du/dx1 – λp1
0 = du/dx2 – λp2


Now we set the two equations like this:

λp1= du/dx1
λp2 = du/dx2


Now how do we get rid of the lambda? Easy: we divide one equation by another.

λp1/ λp2= (du/dx1)/(du/dx2) = p1/p2


This happens to be the Marginal Rate of Substitution, or MRS, for those of you paying attention.

So what does this tell us? It tells us that it is possible to figure out what the best amount of x1 and x2 is, in terms of p1, p2, and M. This is called Marshallian Demand.
For instance, suppose our Utility function was U = (x1)(x2).
Then our first order conditions would be:

dL/dx1 = x2 – λp1
dL/dx2 = x1 – λp2
dL/d λ = M –p1x1 - p2x2


And we get:

p1/p2 = x2/x1
so x2 = p1x1/p2.


Now you may be suspicious here. There’s an x1 on the right side, which doesn’t seem to help us here. However, we can abuse math again (don’t try this with women) to get another expression. This time, we use the third equation, and set it to zero, and substitute for x2:

0 = M – p1x1 - p2(p1x1/p2)


And now we do basic math to get:

2p2x1 = M
X1 = M/(2p2)


And we plug this back in for x1 to solve x2,

X2 = p1(M/2p2)/p2, or p1M/(2p2^2)

And thus we have solved our Marshallian demand. If you want to get what those guys call the indirect utility function, simply plug x1 and x2 back into the original utility function. This gives us:

U = (x1)(x2)
U = (M/2p2)(p1M/2p2^2) = (p1M^2)/(4p2^3)


Next topic: The Price Effect and the Lagrangian.

post other things you may or may not want to see ^^


***
Watch me fail at Paradox: http://www.teamliquid.net/forum/viewmessage.php?topic_id=397564
paper
Profile Blog Joined September 2004
13196 Posts
Last Edited: 2009-11-21 05:12:15
November 21 2009 05:12 GMT
#2
oh man

aren't langrange multipliers from linear algebra? D:

bad memories
Hates Fun🤔
Gliche
Profile Blog Joined August 2008
United States811 Posts
November 21 2009 05:43 GMT
#3
yay econ!

can i ask how qualified you are to be teaching this, caller? ;D
KT fighting~!! | Designing things is fun!
AcrossFiveJulys
Profile Blog Joined September 2005
United States3612 Posts
November 21 2009 05:44 GMT
#4
lagrange theory is great =) I had to learn it in detail this semester, since we use it all the time in machine learning to derive data classifiers and regression functions.
pangshai
Profile Blog Joined January 2005
Chinatown5333 Posts
November 21 2009 06:16 GMT
#5
damn i was hoping this would be more for the interested layman, but its getting a bit too complex for me. good job with the tutorials though, i'm sure others will benefit!
#1 midas fan
Empyrean
Profile Blog Joined September 2004
17018 Posts
November 21 2009 06:34 GMT
#6
On November 21 2009 14:12 paper wrote:
oh man

aren't langrange multipliers from linear algebra? D:

bad memories


Err, Lagrangians are generally introduced in calc 3. You're probably thinking of all the times you had to use lambda to calculate eigenvalues and Jordan canonical form and crap.
Moderator
Caller
Profile Blog Joined September 2007
Poland8075 Posts
November 21 2009 06:58 GMT
#7
On November 21 2009 15:16 pangshai wrote:
damn i was hoping this would be more for the interested layman, but its getting a bit too complex for me. good job with the tutorials though, i'm sure others will benefit!

i'm getting back to the layman

hold up
Watch me fail at Paradox: http://www.teamliquid.net/forum/viewmessage.php?topic_id=397564
Carnivorous Sheep
Profile Blog Joined November 2008
Baa?21244 Posts
November 21 2009 07:13 GMT
#8
Lagrangians are kinda everywhere. It's very oppressive, actually, when you start seeing them in every class you take, from physics in the morning to math to econ >.>
TranslatorBaa!
datscilly
Profile Blog Joined November 2007
United States529 Posts
November 21 2009 07:47 GMT
#9
Every part of OP taught me something, and I'm looking forward to the next one.

I have a question though. It's a little long, and here it goes: The overall goal of all this is to solve for x1 and x2 in terms of M, p1, and p2, given M = p1x1 + p2x2, and given that U(x1, x2) = (x1)(x2) is to be maximized. Here x1 and x2 play symmetric roles. + Show Spoiler +
More exactly, if you switch x1 with x2 and switch p1 with p2 at the same time, the equations are unchanged
The answer, X1 = M/(2p2) and X2 = p1M/(2p2^2), is not symmetric.

And I was wondering why symmetry was broken and found that L, the Lagrangian function, was defined asymmetrically: L = U(x1, x2) + λ(M-p1x1 + p2x2). Since M = p1x1 + p2x2, one would expect λ(M-p1x1 - p2x2) instead of λ(M-p1x1 + p2x2).

So my two questions are, why is symmetry broken, which is an iffy question and might not have an answer, and two, why is the Lagrangian function defined the way it is, which should have an answer.
I'm willing to read some links and do some learning myself in order to understand your answer. Wikipedia says in general, to maximize f(x,y), subject to g(x,y) = c, let L = f(x,y) + λ(g(x,y) - c). Actually this would point to λ(M-p1x1 - p2x2), instead of λ(M-p1x1 + p2x2) as you wrote.
Steelflight-Rx
Profile Blog Joined July 2007
United States1389 Posts
November 21 2009 08:10 GMT
#10
yeah man i'm too drunk for this shit, how do i get to that drunk thread..
yubee wrote: you know? it's a great night you should all smile no matter what harddships, because grass grows and the sky is blue and it's a good life.
Scaramanga
Profile Blog Joined March 2008
Australia8091 Posts
November 21 2009 08:32 GMT
#11
Economics maths i was hoping this was theory
Loda talked about the fun counter, it's AdmiralBulldog on his natures prophet
Two_DoWn
Profile Blog Joined October 2009
United States13684 Posts
November 21 2009 08:43 GMT
#12
I come to TL to get away from my econ major, not to be reminded of it. Curse you Caller.
"What is the air speed velocity of an unladen courier?" "Dire or Radiant?"
Caller
Profile Blog Joined September 2007
Poland8075 Posts
Last Edited: 2009-11-21 09:28:38
November 21 2009 09:12 GMT
#13
On November 21 2009 16:47 datscilly wrote:
Every part of OP taught me something, and I'm looking forward to the next one.

I have a question though. It's a little long, and here it goes: The overall goal of all this is to solve for x1 and x2 in terms of M, p1, and p2, given M = p1x1 + p2x2, and given that U(x1, x2) = (x1)(x2) is to be maximized. Here x1 and x2 play symmetric roles. + Show Spoiler +
More exactly, if you switch x1 with x2 and switch p1 with p2 at the same time, the equations are unchanged
The answer, X1 = M/(2p2) and X2 = p1M/(2p2^2), is not symmetric.

And I was wondering why symmetry was broken and found that L, the Lagrangian function, was defined asymmetrically: L = U(x1, x2) + λ(M-p1x1 + p2x2). Since M = p1x1 + p2x2, one would expect λ(M-p1x1 - p2x2) instead of λ(M-p1x1 + p2x2).

So my two questions are, why is symmetry broken, which is an iffy question and might not have an answer, and two, why is the Lagrangian function defined the way it is, which should have an answer.
I'm willing to read some links and do some learning myself in order to understand your answer. Wikipedia says in general, to maximize f(x,y), subject to g(x,y) = c, let L = f(x,y) + λ(g(x,y) - c). Actually this would point to λ(M-p1x1 - p2x2), instead of λ(M-p1x1 + p2x2) as you wrote.


oh whoooooopssssssssssssssss
my bad
thanks for catching that mistake
that'll teach me to half-ass economics
edit: while I did write the wrong thing, the derivatives I took were of the right thing. So the results should still be the same. The reason why symmetry is broken is purely because or the difference between p1 and p2.
It would seem that p1 and p2 would give you the same answer: However, keep in mind that p1 and p2 are different. Let's flip around our results, for instance:
so instead of

p1/p2 = (du/dx1)/(du/dx2)


we now have

p2/p1 = (du/dx2)/(du/dx1)


And using the same equation above, we should get

p2/p1 = x1/x2

which gives us:

x1 = x2p2/p1


If you plug our results in, you see clearly that it forms an identity, confirming our results.
X1 = M/(2p2) and X2 = p1M/(2p2^2).

Also keep in mind that the function itself is not symmetrical-there is an M, for instance, and we cannot split the M up into two parts. As a result, it will be present in both cases, albeit with different contexts.
Because we have these three exogeneous variables, we cannot guarantee that the results will be symmetric. It is possible that these values may be such that our actual numerical answer is symmetric, but it is equally possible that they are not.

There is also one more thing to note about this economic implication:

There is a concept called price effect, which is saying that the amount of stuff you buy changes in response to how the price changes. For instance, usually, when you buy bread, and the price goes down, you may buy more bread. However, there are other possibilities. A Giffin good, for instance, is one where you buy more of it as the price goes up, i.e. that price effect is positive.
There really isn't anything that's a real Giffin good, but one possible example could be toothpaste. Suppose you only do two things with your money: buying toothpaste and going to the dentist. Suppose the price of toothpaste goes up. Now you can't go to the dentist as much. However, because you can't go to the dentist, you need to buy more toothpaste, even though the price went up.
Another possible solution is that you don't change your consumption of the good as the price goes up. For instance, I may use the money I save from bread to hire prostitutes, rather than to buy more bread for my damn kids.

A mathematical version of price effect is, simply, dx1/dp1, or, the change in x1 in response to the change in price. A positive price effect means you buy more x1 in response to an increase in the price of x1. A negative effect means you buy less in response to an increase, etc.

In our case, if we were to calculate the price effect, we would get:

X1 = M/(2p2) and X2 = p1M/(2p2^2).
dx1/dp1 = 0, dx2/dp1 = M/(2p2^2)


This tells us two very interesting things. Firstly, the price effect for x1 is zero. This means that, no matter what the change in price, the person will always buy the same amount of x1. However, for x2, we have a figure. Although it seems tricky, with a little intuition you can figure out the following:
Firstly, M, our budget, has to be positive. This should be obvious.
Secondly, p2, our price, also has to be positive. This should also be obvious because you're not selling bread or prostitutes back.
Therefore, this means that the price effect is positive for x2 in response to x1. That is, if the price in x1 goes up, you buy more x2. This should make sense. If i have to choose between bread and prostitutes, and the price in bread goes down, I hire prostitutes rather than get fat. Similarly, if the price in bread goes up, I hire less prostitutes and buy enough to keep me from starving.

There is also an income effect, which asks whether or not your M value increases or decreases. We quantify that as dx/dM, i.e. how much do you change how much you buy based on how your amount of money changes?

For our case, we could calculate it to be

X1 = M/(2p2) and X2 = p1M/(2p2^2).
dx1/dM = 1/(2p2) and dx2/dM = p1/(2p2^2)

And both of which are positive. This tells us that the more money we have, the more we buy of each stuff. There are cases in which we buy less of something if we have more money, in which case the product is called an inferior good (as opposed to a Giffin good or a normal good). For instance, an inferior good could be ugly prostitutes. The more money I have, the less money I'll spend on ugly prostitutes and the more money I can spend on hot prostitutes.
Watch me fail at Paradox: http://www.teamliquid.net/forum/viewmessage.php?topic_id=397564
imDerek
Profile Blog Joined August 2007
United States1944 Posts
November 21 2009 09:47 GMT
#14
weird i did lagrange multipliers in high school but never did it in college and im in engineering too
Least favorite progamers: Leta, Zero, Mind, Shine, free, really <-- newly added
datscilly
Profile Blog Joined November 2007
United States529 Posts
November 21 2009 10:44 GMT
#15
Hmm, I think I found another mistake, one which means that the solutions are different than up there, and that it's symmetric after all.

On November 21 2009 14:07 Caller wrote:
0 = M – p1x1 - p2(p1x1/p2)

And now we do basic math to get:

2p2x1 = M
X1 = M/(2p2)

It should be
2p1x1 = M
X1 = M/(2p1)

instead. X2 = M/(2p2) will also hold.

The symmetry thing was really bothering me because of the following: if you substitute x1 for x2, x2 for x1, p1 for p2, and p2 for p1, the given equations for the problem, including the equation for U, look exactly the same. Since all the equations after that are logical consequences of the first two equations up top and the equation for U, doing all the substitutions for any equation you get should result in another equation which is true. + Show Spoiler +
One can think of it this way: there are two universes, one where we write down the original equations M = p1x1 + p2x2, L = U(x1, x2) + λ(M-p1x1 + p2x2), U = (x1)(x2), and find consequences of those equations, and another universe where we do those four substitutions on the original equations, and find consequences of those equations. Since the original equations remain unchanged, every logical consequence of the mirror universe is in fact true in the original universe as well.

So X1 = M/(2p2), X2 = p1M/(2p2^2), can't be the solution, since mirroring X1 = M/(2p2) gets us X2 = M/(2p1), and then we have 1 = (p1^2)/(p2^2) after some work, which doesn't make sense.

Right, so I went through all this to talk about a type of reasoning that works for any math problem, and to explain why I looked for a mistake in the first place.
Empyrean
Profile Blog Joined September 2004
17018 Posts
November 22 2009 08:37 GMT
#16
On November 21 2009 18:47 imDerek wrote:
weird i did lagrange multipliers in high school but never did it in college and im in engineering too


You use them a lot in Engineering...especially in optimization problems.

That's kind of strange that you don't use them in your engineering classes.

I assume you took calc 3 in high school? Lagrange multipliers are usually introduced around the time when partial derivatives are introduced, which is fairly early in calc 3.
Moderator
Please log in or register to reply.
Live Events Refresh
StarCraft2.fi
17:00
15V Cup / Groups Day 3
starcraft2fi 133
Reevou 10
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Fuzer 336
BRAT_OK 89
MindelVK 27
StarCraft: Brood War
Calm 3009
Larva 249
Shuttle 157
Dewaltoss 134
ggaemo 103
Rock 23
Dota 2
Gorgc6379
qojqva4676
syndereN359
canceldota33
Counter-Strike
pashabiceps1560
edward273
chrisJcsgo101
Heroes of the Storm
Liquid`Hasu79
Other Games
DeMusliM1122
FrodaN919
Grubby405
KnowMe340
Sick161
C9.Mang0116
QueenE72
Livibee69
Trikslyr68
ViBE31
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• 3DClanTV 61
• FirePhoenix13
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
League of Legends
• Nemesis2699
• TFBlade989
Other Games
• imaqtpie882
• WagamamaTV471
• Scarra419
• Shiphtur134
Upcoming Events
Replay Cast
4h 45m
The PondCast
14h 45m
OSC
20h 45m
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
1d 4h
Korean StarCraft League
2 days
CranKy Ducklings
2 days
WardiTV 2025
2 days
SC Evo League
2 days
BSL 21
3 days
Sziky vs OyAji
Gypsy vs eOnzErG
OSC
3 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
[ Show More ]
Sparkling Tuna Cup
3 days
WardiTV 2025
3 days
OSC
3 days
BSL 21
4 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
4 days
Wardi Open
4 days
StarCraft2.fi
4 days
Monday Night Weeklies
4 days
Replay Cast
5 days
WardiTV 2025
5 days
StarCraft2.fi
5 days
PiGosaur Monday
6 days
StarCraft2.fi
6 days
Liquipedia Results

Completed

Proleague 2025-11-30
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.