Ask Your Question
1

can't solve inequality for independent variable

asked 2020-07-23 10:26:30 -0600

cduston gravatar image

updated 2020-10-11 16:13:10 -0600

slelievre gravatar image

One of the frustrations I'm always having with Sage is how it tries to "solve" inequalities. For a random example:

sage: var('a b x')
sage: f = (a - b * x^2) / (x-1)
sage: solve(f > 0, x)
[[x < 1, b*x^2 - a > 0], [1 < x, -b*x^2 + a > 0]]

Which I knew already (since it's just the numerator). Ok, so various signs and things matter, but the fact that it can't even tell me

x^2 > a/b

is frustrating. Is there a reason, or a way to convince Sage to actually "solve" these in some way?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-07-23 16:15:21 -0600

Emmanuel Charpentier gravatar image

Not directly. You may try :

sage: S1=solve_ineq([(a-b*x^2)/(x-1)>0],[x]);S1
[[x < 1, b*x^2 - a > 0], [1 < x, -b*x^2 + a > 0]]

But there, you're on your own:

sage: solve_ineq([(S1[0][1]+a)/b],[x])
[[b > 0, b*x^2 - a > 0], [-b > 0, -b*x^2 + a > 0]]

Sage may help you playing with that :

sage: S2=(S1[0][1]+a)/b; S2
x^2 > a/b

but

sage: solve_ineq([S2],[x])
[[b > 0, b*x^2 - a > 0], [-b > 0, -b*x^2 + a > 0]]

is pretty unhelpful.

Note that "the competition" isn't very helpful, either :

sage: mathematica("Reduce[Element[a, Reals] && Element[b, Reals] && Element[x, Reals] && (a-b*x^2)/(x-1)>0 ,x]")
(b < 0 && ((a < b && (Inequality[-Sqrt[a/b], Less, x, Less, 1] || 
     x > Sqrt[a/b])) || (a == b && (Inequality[-Sqrt[a/b], Less, x, Less, 
      1] || x > 1)) || (Inequality[b, Less, a, LessEqual, 0] && 
    (Inequality[-Sqrt[a/b], Less, x, Less, Sqrt[a/b]] || x > 1)) || 
   (a > 0 && x > 1))) || (b == 0 && ((a < 0 && x < 1) || 
   (a > 0 && x > 1))) || (b > 0 && ((a < 0 && x < 1) || 
   (Inequality[0, LessEqual, a, Less, b] && (x < -Sqrt[a/b] || 
     Inequality[Sqrt[a/b], Less, x, Less, 1])) || 
   (a == b && x < -Sqrt[a/b]) || (a > b && (x < -Sqrt[a/b] || 
     Inequality[1, Less, x, Less, Sqrt[a/b]]))))

Current progress in sympy may someday get us more helpful answere, but we're not here yet.

Another possibility is to use one of the linear prograpping packages available in Sage, bu I do not know them well enough to point you in the right direction...

HTH,

edit flag offensive delete link more

Comments

Unfortunately, it does help demonstrating that Mathematica does no better. I guess this is the answer ("Sage can't do what you want"), but I'll give a few days to see if anyone knows more. Thanks.

cduston gravatar imagecduston ( 2020-07-24 08:18:24 -0600 )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-23 10:26:30 -0600

Seen: 162 times

Last updated: Oct 11