Ask Your Question
0

3 questions in one about exploiting the result of an optimization

asked 2019-09-12 21:13:07 +0100

Cyrille gravatar image

updated 2019-09-12 21:52:58 +0100

tmonteil gravatar image

This is an incredible result of SageMath since one is obliged to help Mathematica to obtain the result

 var('A, x, y, l, alpha, beta, R, p_x, p_y');
U= A*x^(alpha)*y^(beta);
show(U)
D = p_x*x + p_y*y;
show(D)
show(U)
solve(D==R, y)
L = U-l*(D-R)
show(L)
L_x= L.diff(x)
show(L_x)
L_y= L.diff(y)
show(L_y)
L_lambda= L.diff(l)
show(L_l)
z=solve([L_x==0, L_y==0, L_l==0,], x, y, l)
show(z[0])
x1=z[0][0].right()
show(x1)
y1=z[0][1].right()
show(y1)
U1=U.subs(x=x1,y=y1)
show(U1)

But I would ameliorate the presentation :

1) How can I substitute greek $\lambda$ to l in the code ?

2) The final result should be simplified because there are possible factorizations ?

3) How can I, without rewriting, all the code add the hypothesis $\alpha+ \beta =1$ ?

4) how to have the results automaticaly written in LaTeX without using show()

A great hand shake for the one who will help me on those maters.

edit retag flag offensive close merge delete

Comments

To the moderator : I have tried to ameliorate my English but the result was not saved.

Cyrille gravatar imageCyrille ( 2019-09-12 21:14:12 +0100 )edit

You can try again.

tmonteil gravatar imagetmonteil ( 2019-09-12 22:01:10 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-09-12 22:00:46 +0100

tmonteil gravatar image

Regarding 1, see the answer of https://ask.sagemath.org/question/478...

Regarding 2, which factorization would you expect ?

Regarding 3, you ar lucky because in the tree of the representation of the expression, alpha+beta appears as subtrees, so the following works:

sage: U1.subs({alpha+beta:1})
A*(R*alpha/p_x)^alpha*(R*beta/p_y)^beta

Regarding 4, if you are using jupyter notebook, you can add the following in the first cell:

%display latex
edit flag offensive delete link more

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: 2019-09-12 20:55:01 +0100

Seen: 216 times

Last updated: Sep 12 '19