Bug with solve

50 views
Skip to first unread message

Arnaud Usciati

unread,
May 19, 2015, 7:29:49 AM5/19/15
to sy...@googlegroups.com
Hello,

I tried to find the roots of : 2*sqrt(x)*sqrt(x**3 - x**2 + 1) + 2*x**3 - x**2 + x*sqrt(x**3 - x**2 + 1) + 2*x**1.5 + 2*x**2.5*sqrt(x**3 - x**2 + 1) - 3*x**2.5 - 4*x**3.5*sqrt(x**3 - x**2 + 1) - 2*x**3.5 + 5*x**4.5 - 3*x**5.5 - 1 = 0.

x = symbols('x', real=True)
f = Lambda(x, 2*sqrt(x)*sqrt(x**3 - x**2 + 1) + 2*x**3 - x**2 + x*sqrt(x**3 - x**2 + 1) + 2*x**1.5 + 2*x**2.5*sqrt(x**3 - x**2 + 1) - 3*x**2.5 - 4*x**3.5*sqrt(x**3 - x**2 + 1) - 2*x**3.5 + 5*x**4.5 - 3*x**5.5 - 1)

Input : solve(f(x), x)
Output : [0.149910458676117, 0.865324593883105, 1.00000000000000, 1.24896947842683, 2.56371129870321, 3.02429035798029]

But only 0.149910458676117 and 1 are really roots :
f(0.865324593883105) = 0.735269457206734
f(1.24896947842683) = -4.09736628717860
f(2.56371129870321) = -509.709822051607
f(3.02429035798029) = -1361.51149028959

Arnaud,

Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32

Aaron Meurer

unread,
May 19, 2015, 12:25:33 PM5/19/15
to sy...@googlegroups.com
What version of SymPy is this? On master I get

In [1]: x = symbols('x', real=True)

In [2]: f = Lambda(x, 2*sqrt(x)*sqrt(x**3 - x**2 + 1) + 2*x**3 - x**2
+ x*sqrt(x**3 - x**2 + 1) + 2*x**1.5 + 2*x**2.5*sqrt(x**3 - x**2 + 1)
- 3*x**2.5 - 4*x**3.5*sqrt(x**3 - x**2 + 1) - 2*x**3.5 + 5*x**4.5 -
3*x**5.5 - 1)

In [3]: solve(f(x), x)
Out[3]: [0.149910458676117, 1.0]

(note that it takes a while)

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/ece1f69e-919b-4bde-ab31-9213adf06c35%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Arnaud Usciati

unread,
May 20, 2015, 1:15:58 AM5/20/15
to sy...@googlegroups.com
Hi,

I have : Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32

Denis Akhiyarov

unread,
May 20, 2015, 1:42:19 AM5/20/15
to sy...@googlegroups.com
You gave Python version not sympy.__version__

Arnaud Usciati

unread,
May 20, 2015, 1:46:09 AM5/20/15
to sy...@googlegroups.com
Right,

I have sympy-0.7.6.win32.

Aaron Meurer

unread,
May 28, 2015, 4:39:00 PM5/28/15
to sy...@googlegroups.com
It looks like this is fixed in master. I bisected it to
https://github.com/sympy/sympy/commit/9b1f3d7402538c587a00fa4df162208998727830.

Aaron Meurer

On Wed, May 20, 2015 at 12:46 AM, Arnaud Usciati <rai...@gmail.com> wrote:
> Right,
>
> I have sympy-0.7.6.win32.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/f0619d17-cdc0-47dd-858c-6a6415d212d3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages