# solve((x^3 - 4*x) > 0,x) does not enforce condition assume(x > 0)

I actually have two (related) questions.

First question, am I misunderstanding the following code?

forget()
assume(x>0)
solve((x^3 - 4*x) > 0,x)


The solution given by sagemath-7.3 is

[[x > -2, x < 0], [x > 2]]


but I would expect only the solution [x > 2] under the condition x > 0.

Is this a bug or am I doing something wrong?

Second question. How can I enforce the condition x > 0 myself and "solve" the resulting conditions of:

[[[D < -2],
[D > 0, D < -1/9*sqrt(1081) + 116/9],
[D > 1/9*sqrt(1081) + 116/9]],
[[D > -4, D < -2],
[D > 2, D < -1/3*sqrt(7009) + 116/3],
[D > 1/3*sqrt(7009) + 116/3]],
[[D > -4, D < 0], [D > 2, D < 11]],
[[D < -6], [D > -2, D < 0], [D > 2, D < 19]],
[[D < -4], [D > -2, D < 0], [D > 2]],
[[D > -6, D < -4], [D > -2, D < 0], [D > 2]]]


How can I solve this type of question efficiently? I believe that discarding the negative solutions in the above system will imply that 2 < D < 1/9(116 - sqrt(1081)), for example. However, I'd like to do this for many other cases as well.

Any help will be appreciated!

edit retag close merge delete

Sort by » oldest newest most voted

Apparently the function solve does not take the assumptions into account.

One thing you can do is to include the assumptions yourself.

Either by hand:

sage: solve([(x^3 - 4*x) > 0, x > 0], x)
[[2 < x]]


Or more automatically.

sage: assume(x > 0)
sage: assumptions()
[x > 0]

sage: A = (x^3 - 4*x) > 0
sage: A
x^3 - 4*x > 0

sage: solve(assumptions() + [A], x)
[[2 < x]]


sage: assume(x > 0)
sage: assume(x^3 - 4*x > 0)
sage: assumptions()
[x > 0, x^3 - 4*x > 0]
sage: solve(assumptions(), x)
[[2 < x]]

more