Ask Your Question
0

sagemath fails to solve an equation and inequation

asked 2020-11-06 12:58:08 +0100

Cyrille gravatar image

updated 2020-11-06 16:05:44 +0100

I do not understand why

var('R','p','x')
sol1=solve(R^(1/3)*p == x^(1/3),x)
show(sol1)

this work but this fails to isolate $x$

var('R','p','x')
sol1=solve(R^(1/3)*p <= x^(1/3),x)
show(sol1)

And that

var('R','p','x')
sol2=solve(0 == (R-x)^(1/3)*p + (1-p)* (-x)^(1/3),x)
show(sol2)

doesn't find $x$. And, as a consequence, of cours this :

var('R','p','x')
sol2=solve(0 <= (R-x)^(1/3)*p + (1-p)* (-x)^(1/3),x)
show(sol2)

fails. I have tried all simplification ways.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-11-06 22:01:03 +0100

Emmanuel Charpentier gravatar image

The first two can be (awkwardly) solved by Sage :

sage: E1=R^(1/3)*p == x^(1/3)
sage: E1.solve(x, algorithm="sympy")
[x == R*p^3]
sage: I1=R^(1/3)*p <= x^(1/3)
sage: [x-v[0] for v in solve(I1^3,x)]
[R*p^3 == x, R*p^3 > x]

But the third one : sage: I2=0 <= (R-x)^(1/3)p + (1-p) (-x)^(1/3)

requires manual solution. Sage can help, at least for record-keeping :

sage: I22=((((I2-I2.rhs().operands()[1])/(1-p))^3)).expand() ; I22
x <= -R*p^3/(p^3 - 3*p^2 + 3*p - 1) + p^3*x/(p^3 - 3*p^2 + 3*p - 1)
sage: I23=I22-I22.rhs().operands()[1] ; I23
-p^3*x/(p^3 - 3*p^2 + 3*p - 1) + x <= -R*p^3/(p^3 - 3*p^2 + 3*p - 1)
sage: I23.factor()/(I23.factor().lhs().coefficient(x))
x <= R*p^3/(3*p^2 - 3*p + 1)

"The competition" fares a bit better :

sage: mathematica.Reduce(I2,x)
Element[p, Reals] && 
 ((R < 0 && ((p <= 1 && x <= R) || (p > 1 && 
     x <= (p^3*R)/(1 - 3*p + 3*p^2)))) || (R == 0 && x <= 0) || 
  (R > 0 && ((p < 0 && x <= (p^3*R)/(1 - 3*p + 3*p^2)) || 
    (p >= 0 && x <= 0))))

HTH,

edit flag offensive delete link more

Comments

Thanks I always forget sympy

Cyrille gravatar imageCyrille ( 2020-11-07 09:01:41 +0100 )edit

Emmanuel I have a big problem. What I do is preparing correction for students under SageCells. Unfortunately, algorithm="sympy" option doesn't work. Are you aware of an other soluytion ? It seems that many things are differently managed under Sagemath notebook and SaeCells which is dommageable. And I do not know how to connect people who develop SageCells

Cyrille gravatar imageCyrille ( 2020-11-08 12:04:44 +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-11-06 12:58:08 +0100

Seen: 238 times

Last updated: Nov 06 '20