Ask Your Question

Inequation solution doesn't isolate the operational variable

asked 2021-05-30 16:25:44 +0200

Cyrille gravatar image

updated 2021-05-31 14:05:41 +0200

slelievre gravatar image

This is a follow-up to

One more time I encounter a problem I cannot find a solution by myself. In the following code:

D = polytopes.dodecahedron()
DH = D.Hrepresentation()
x = list(var('x_%i' % i) for i in (0..2))
# show(DH)
Ineq=[[el.A()*vector(x) >= -el.b()] for el in DH]
# show(Ineq)
sol = [solve(ieq[0], x[0]) for ieq in Ineq]
sol1 = [el[1] for el in sol]

when ieq[0] doesn't depend on x[0], sol1 is returned as entered. It's perfectly normal. But I ask to solve on x[0]. Many answers do not isolate x[0] (for instance, it is the case for sol[2]) which is what I ask for. How can I code in such way that SageMath does it by default?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-05-30 17:49:06 +0200

tmonteil gravatar image

Instead of using solve, you could use solve_ineq which is more appropriate. So, you can replace:

sol=[solve(ieq[0],x[0]) for ieq in Ineq]


sol=[solve_ineq(ieq,[x[0]]) for ieq in Ineq]
edit flag offensive delete link more


Tmontheil Thanks.

Cyrille gravatar imageCyrille ( 2021-05-30 21:44:07 +0200 )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


Asked: 2021-05-30 16:25:44 +0200

Seen: 40 times

Last updated: May 31