Ask Your Question
0

Exploiting the results of an optimization

asked 2019-09-13 17:20:56 +0200

Cyrille gravatar image

updated 2019-09-13 18:37:02 +0200

tmonteil gravatar image

The code bellow work perfectly but if i get ride of show(), it doesn't display in LaTeX secondly I would like to display not Simply show(x1) but "x=show(x1)". How can I do that ?

(The question continue after the code)

%display latex
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_l= L.diff(l)
%display latex
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_l= 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)
l1=z[0][2].right().canonicalize_radical()
show(l1)
U1=U.subs(x=x1,y=y1).canonicalize_radical()
show(U1)
latex(U1)

Now yesterday some one shows me how to do the same thing with a dictionary

z=solve([L_x==0, L_y==0, L_l==0,], x, y, l, solution_dict=True)
show(z)

how can I extact $x= solution$ and so on.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-09-13 18:40:38 +0200

tmonteil gravatar image

updated 2019-09-13 18:46:07 +0200

If you put %display latex you do not have to write show(D), simply write D and start a new cell.

Regarding your second question, you can do:

SR.var("x") == x1

and it will look like what you want if you have %display latex

Regarding your last question, you can get the value of x in the first (actually the only one) solution of z by typing z[0][x]

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-13 17:20:56 +0200

Seen: 125 times

Last updated: Sep 13 '19