# solving one inequality with assumption

I wonder why Sagemath is not able to solve this

var('x a b c')
U_1 = lambda x, a, b, c: c*x*x^1+b*x+a
show(LatexExpr(r'U(x) = '),U_1(x,a,b,c))
#first order x derivative which must be positive
δU_1(x,a,b,c) = diff(U_1(x,a,b,c),x)
assume(x>=0)
solve_ineq([δU_1(x,a,b,c)>0],[x])

edit retag close merge delete

Sort by » oldest newest most voted

Inequation solving is a (very) weak point of Sage. A peek at Mathematica's solution helps to understand why :

sage: reset()
sage: var('a b c', domain="real")
(a, b, c)
sage: var("x", domain="positive")
x
sage: U_1(x, a, b, c) = c*x*x^1+b*x+a
sage: ineq = U_1(x, a, b, c).diff(x)>0 ; ineq
2*c*x + b > 0
sage: mathematica.Reduce(ineq, x)
Element[x, Reals] && ((b <= 0 && ((c < 0 && x < -1/2*b/c) ||
(c > 0 && x > -1/2*b/c))) || (b > 0 && ((c < 0 && x < -1/2*b/c) ||
c == 0 || (c > 0 && x > -1/2*b/c))))


Sage currently does not have logical functions allowing for such an expression of this solution. However, Sage can help manipulating the inequation to get a solution of sorts :

sage: (ineq-b)/2
c*x > -1/2*b
sage: (ineq-b)/2/c ### ZAssuming c > 0 !
x > -1/2*b/c
sage: (ineq-b)/2/-c ### Assuming c < 0 !
-x > 1/2*b/c


The latter can be rewritten x > -1/2*b/c, leading to rewrite manually ! :

sage: cases([(c>0, x>-b/(2*c)), (c<0, x>b/(2*c)), (c==0, None)])
cases(((c > 0, x > -1/2*b/c), (c < 0, x > 1/2*b/c), (c == 0, None)))


This is more or less consonant with the (intricate) Mathematica solution...

We note that neither Maxima, Sympy, Giac nor Fricas fare better (as far as I have been able to prod them...) ; in particular, the ineq Maxima package currently does not load.

One should note that the optional package qepcad is said to be able to express and solve systemof inequations. I have not (yet) explored it.

HTH,

more

Thanks Elmmanuel; I have tried to install quepcad with pip but It was not founded.

( 2023-05-11 10:17:43 +0200 )edit

qepcad is an optional package. As far as understand it, those are not installable in a binary installation, which lacks the tools necessary for such a task. In an installation from source, make qepcad works, and sage -i qepcadshould work.

HTH,

( 2023-05-12 10:05:24 +0200 )edit

## Stats

Seen: 82 times

Last updated: May 10 '23