ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 20 Oct 2013 13:28:25 -0500Wrong solution?http://ask.sagemath.org/question/10592/wrong-solution/Hi, could you help me with this solution of two equations on the interval:
x,a=var('x,a')
f1=10/x
f2=x-**5***a
**assume(a>0,x>0)**
print(solve([f1==f2],x))
Solution given by Sage is:
[
x == 5/2*a - 1/2*sqrt(25*a^2 + 40),
x == 5/2*a + 1/2*sqrt(25*a^2 + 40)
]
The first solution is obviously not solution for me as it is always strictly negative and I don't understand why the Sage gave me it. Assumptions are clear: **x** has to be **>0** When I change second equation slightly:
x,a=var('x,a')
f1=10/x
f2=x-**6***a
**assume(a>0,x>0)**
print(solve([f1==f2],x))
Solution given by Sage is correct now (only the x>0 are reported):
[
x == 3*a + sqrt(9*a^2 + 10)
]
Could you help me explain the difference in results. I am not sure if problem is on python side or with some rules how Sage computes the results.
Thank you in advance.
Sat, 05 Oct 2013 23:39:15 -0500http://ask.sagemath.org/question/10592/wrong-solution/Answer by J.T. for <p>Hi, could you help me with this solution of two equations on the interval:</p>
<p>x,a=var('x,a')</p>
<p>f1=10/x</p>
<p>f2=x-<strong>5*</strong>a</p>
<p><strong>assume(a>0,x>0)</strong></p>
<p>print(solve([f1==f2],x))</p>
<p>Solution given by Sage is:</p>
<p>[
x == 5/2<em>a - 1/2</em>sqrt(25*a^2 + 40),</p>
<p>x == 5/2<em>a + 1/2</em>sqrt(25*a^2 + 40)
]</p>
<p>The first solution is obviously not solution for me as it is always strictly negative and I don't understand why the Sage gave me it. Assumptions are clear: <strong>x</strong> has to be <strong>>0</strong> When I change second equation slightly:</p>
<p>x,a=var('x,a')</p>
<p>f1=10/x</p>
<p>f2=x-<strong>6*</strong>a</p>
<p><strong>assume(a>0,x>0)</strong></p>
<p>print(solve([f1==f2],x))</p>
<p>Solution given by Sage is correct now (only the x>0 are reported):</p>
<p>[
x == 3<em>a + sqrt(9</em>a^2 + 10)
]</p>
<p>Could you help me explain the difference in results. I am not sure if problem is on python side or with some rules how Sage computes the results.
Thank you in advance.</p>
http://ask.sagemath.org/question/10592/wrong-solution/?answer=15564#post-id-15564I used the example only for illustration and I think the problem is more serious than just "inability to multiply everything by 2". The correction is easy in posted example, but the correction is more demanding in case of more complicated functions. For me: provided solutions are untrustworthy.Sat, 19 Oct 2013 20:24:45 -0500http://ask.sagemath.org/question/10592/wrong-solution/?answer=15564#post-id-15564Comment by tmonteil for <p>I used the example only for illustration and I think the problem is more serious than just "inability to multiply everything by 2". The correction is easy in posted example, but the correction is more demanding in case of more complicated functions. For me: provided solutions are untrustworthy.</p>
http://ask.sagemath.org/question/10592/wrong-solution/?comment=16899#post-id-16899I agree with that. There should be a way for Sage to consistently say : "I do not now".Sun, 20 Oct 2013 13:28:25 -0500http://ask.sagemath.org/question/10592/wrong-solution/?comment=16899#post-id-16899Answer by tmonteil for <p>Hi, could you help me with this solution of two equations on the interval:</p>
<p>x,a=var('x,a')</p>
<p>f1=10/x</p>
<p>f2=x-<strong>5*</strong>a</p>
<p><strong>assume(a>0,x>0)</strong></p>
<p>print(solve([f1==f2],x))</p>
<p>Solution given by Sage is:</p>
<p>[
x == 5/2<em>a - 1/2</em>sqrt(25*a^2 + 40),</p>
<p>x == 5/2<em>a + 1/2</em>sqrt(25*a^2 + 40)
]</p>
<p>The first solution is obviously not solution for me as it is always strictly negative and I don't understand why the Sage gave me it. Assumptions are clear: <strong>x</strong> has to be <strong>>0</strong> When I change second equation slightly:</p>
<p>x,a=var('x,a')</p>
<p>f1=10/x</p>
<p>f2=x-<strong>6*</strong>a</p>
<p><strong>assume(a>0,x>0)</strong></p>
<p>print(solve([f1==f2],x))</p>
<p>Solution given by Sage is correct now (only the x>0 are reported):</p>
<p>[
x == 3<em>a + sqrt(9</em>a^2 + 10)
]</p>
<p>Could you help me explain the difference in results. I am not sure if problem is on python side or with some rules how Sage computes the results.
Thank you in advance.</p>
http://ask.sagemath.org/question/10592/wrong-solution/?answer=15517#post-id-15517This is because in the first case, Maxima is not able to decide whether `5/2*a - 1/2*sqrt(25*a^2 + 40)` is negative, and when it does not know, it answers `False`:
sage: bool(5/2*a - 1/2*sqrt(25*a^2 + 40) < 0)
False
sage: bool(5/2*a - 1/2*sqrt(25*a^2 + 40) > 0)
False
to be compared to:
sage: bool(3*a < sqrt(9*a^2 + 10))
True
sage: bool(3*a > sqrt(9*a^2 + 10))
False
The fun thing, it seems that what Maxima is not able to do is to multiply everything by 2 to get the correct result:
sage: bool(5*a - 1*sqrt(25*a^2 + 40) < 0)
True
sage: bool(5*a - 1*sqrt(25*a^2 + 40) > 0)
False
Sun, 06 Oct 2013 09:46:58 -0500http://ask.sagemath.org/question/10592/wrong-solution/?answer=15517#post-id-15517