ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 25 Sep 2016 16:26:10 +0200solve((x^3 - 4*x) > 0,x) does not enforce condition assume(x > 0)https://ask.sagemath.org/question/34923/solvex3-4x-0x-does-not-enforce-condition-assumex-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!Sat, 24 Sep 2016 23:55:43 +0200https://ask.sagemath.org/question/34923/solvex3-4x-0x-does-not-enforce-condition-assumex-0/Answer by slelievre for <p>I actually have two (related) questions.</p>
<p>First question, am I misunderstanding the following code?</p>
<pre><code>forget()
assume(x>0)
solve((x^3 - 4*x) > 0,x)
</code></pre>
<p>The solution given by sagemath-7.3 is </p>
<pre><code>[[x > -2, x < 0], [x > 2]]
</code></pre>
<p>but I would expect only the solution [x > 2] under the condition x > 0. </p>
<p>Is this a bug or am I doing something wrong?</p>
<p>Second question. How can I enforce the condition x > 0 myself and "solve" the resulting conditions of:</p>
<pre><code>[[[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]]]
</code></pre>
<p>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.</p>
<p>Any help will be appreciated!</p>
https://ask.sagemath.org/question/34923/solvex3-4x-0x-does-not-enforce-condition-assumex-0/?answer=34935#post-id-34935Apparently 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]]
You could also add your inequality to the assumptions.
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]]
Sun, 25 Sep 2016 16:26:10 +0200https://ask.sagemath.org/question/34923/solvex3-4x-0x-does-not-enforce-condition-assumex-0/?answer=34935#post-id-34935