Ask Your Question
0

Unknown exponents causing problem to not be solved

asked 2020-07-16 22:57:04 +0100

EconJohn gravatar image

updated 2020-07-17 00:51:59 +0100

Right now im trying to solve one of the problems i've encountered using sage and it seems like im onto something. However I've encountered a kink at step3 in my code.

x1, x2, l, p1, p2, a, b,  R= var('x1, x2, l, p1, p2, a, b,  R')
U = x1^a*x2^b
m = p1*x1+p2*x2;
L = m+ l * (R-U);
dLdx = L.diff(x1);
dLdy = L.diff(x2);    
dLdl = L.diff(l);
step1=solve([dLdx == 0, dLdy == 0, dLdl == 0], p1, p2, R)
step2=solve(step1[0][0].rhs()/step1[0][1].rhs()==p1/p2,x1)
step3=solve(U.subs(step2)==R,x2)
step3

Out: x2^b == R/(a*p2*x2/(b*p1))^a

being that I want to isolate x2 im not sure why its power b is not just moved over.

why is this the case?


Note: The following code works

x1, x2, l, p1, p2, a, b,  Ubar= var('x1, x2, l, p1, p2, a, b,  Ubar')
assume(x1>0,x2>0,a>0,b>0)
U = x1*x2
m = p1*x1+p2*x2;
L = m+ l * (Ubar-U);
dLdx = L.diff(x1);
dLdy = L.diff(x2);
dLdl = L.diff(l);
step1=solve([dLdx == 0, dLdy == 0, dLdl == 0], p1, p2, Ubar)
step2=solve(step1[0][0].rhs()/step1[0][1].rhs()==p1/p2,x1)
step3good2=solve(U.subs(step2)==Ubar,x2)
step4good1=solve(step2[0].subs(step3Good2),x1)

step3good2

Out: [x2 == sqrt(R*p1/p2)]

step4good1

Out: [x1 == sqrt(R*p1/p2)*p2/p1]

This works because I'm considering a case where our utility function has no exponents a and b. What am I missing from my code?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-07-17 01:09:44 +0100

Juanjo gravatar image

In the output of your initial question, the unknown x2 has not been isolated, since it appears in both sides. You can formulate step2 in a more friendly way:

step2 = solve((p1/p2).subs(step1)==p1/p2, x1)

Likewise, borrowing an idea from this solution of another question, you can rewrite step3:

step3 = solve((U/R).subs(step2).log().log_expand()==0, x2)
step3

The output is

[x2 == e^(-a*log(a)/(a + b) + a*log(b)/(a + b) + a*log(p1)/(a + b) - a*log(p2)/(a + b) + log(R)/(a + b))]

Let see x2 in a more mathematical notation:

show(x2.subs(step3).canonicalize_radical())

This yields $$ \frac{R^{\left(\frac{1}{a + b}\right)} b^{\frac{a}{a + b}} p_{1}^{\frac{a}{a + b}}}{a^{\frac{a}{a + b}} p_{2}^{\frac{a}{a + b}}} $$

edit flag offensive delete link more

Comments

This is great! Thank you!

EconJohn gravatar imageEconJohn ( 2020-07-17 01:46:04 +0100 )edit

maybe you could accept @Juanjo 's answer, by checking the box just below <1>. I know it is not easy to understand that it is this button that validates the response, it took me a while before I understood it

ortollj gravatar imageortollj ( 2020-07-17 07:55:37 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-07-16 22:57:04 +0100

Seen: 230 times

Last updated: Jul 17 '20