Ask Your Question
0

solving one inequality with assumption

asked 2023-05-09 11:19:52 +0200

Cyrille gravatar image

updated 2023-05-09 11:20:14 +0200

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 flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2023-05-10 00:20:49 +0200

Emmanuel Charpentier gravatar image

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,

edit flag offensive delete link more

Comments

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

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

@Cyrille,

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,

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-05-12 10:05:24 +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

Stats

Asked: 2023-05-09 11:19:52 +0200

Seen: 71 times

Last updated: May 10 '23