Updates:
Status: Started
Labels: Milestone-Release0.7.0
Comment #13 on issue 326 by mattpap: sympy.roots_.sturm(...) hangs
http://code.google.com/p/sympy/issues/detail?id=326
... and (almost) two years later we arrive with the following session
(using my
development branch):
In [2]: f = sympify('(-1/625) + (1/62500)*x - 4096/625*pi**(-8)*x**4 -
128/625*pi**(-4)*x**2 + \
...: (32/15625)*pi**(-4)*x**3 + (1024/15625)*pi**(-8)*x**5')
In [3]: f
Out[3]:
2 3 4 5
x 128⋅x 32⋅x 4096⋅x 1024⋅x
-1/625 + ───── - ────── + ──────── - ─────── + ────────
62500 4 4 8 8
625⋅π 15625⋅π 625⋅π 15625⋅π
In [4]: sturm(f, x)
Out[4]:
⎡ 4 4 4 ⎛ 4⎞ 4
4 8 12⎤
⎢ 2 3 25⋅π x⋅π 2 π ⎜ π ⎟
25⋅π -
3686400000000⋅π - 11520000⋅π - 9⋅π ⎥
⎢- 100⋅x + x - ───── + ────, -200⋅x + 3⋅x + ──, x⋅⎜20000/9 - ──⎟ + ─────,
────────────────────────────────────────⎥
⎢ 16 64 64 ⎝ 96⎠ 18
4 8 ⎥
⎣
26214400000000 - 245760000⋅π + 576⋅π ⎦
In [5]: %time s = sturm(f, x)
CPU times: user 0.31 s, sys: 0.00 s, total: 0.31 s
Wall time: 0.39 s
In [7]: %time s = sturm(f, x)
CPU times: user 0.30 s, sys: 0.00 s, total: 0.30 s
Wall time: 0.38 s
A bit slow but with gmpy will be better.
In [9]: from sympy.polys.rootfinding import number_of_real_roots
In [10]: number_of_real_roots(f, x)
Out[10]: 1
In [11]: factor(f)
Out[11]:
2
⎛ 2⎞
⎜ 64⋅x ⎟
-⎜1 + ─────⎟ ⋅(100 - x)
⎜ 4 ⎟
⎝ π ⎠
───────────────────────
62500
In [12]: roots(f, x)
Out[12]:
⎧ 2 2 ⎫
⎪ -ⅈ⋅π ⅈ⋅π ⎪
⎨100: 1, ─────: 2, ────: 2⎬
⎪ 8 8 ⎪
⎩ ⎭
And we're done. Lets now use gmpy as ZZ and QQ ground types:
m...@neutrino ~/repo/git/sympy $ SYMPY_GROUND_TYPES=gmpy isympy
Python 2.6.2 console for SymPy 0.7.0-git (cache: off)
In [1]: f = sympify('(-1/625) + (1/62500)*x - 4096/625*pi**(-8)*x**4 -
128/625*pi**(-4)*x**2 + \
...: (32/15625)*pi**(-4)*x**3 + (1024/15625)*pi**(-8)*x**5')
In [2]: %time s = sturm(f, x)
CPU times: user 0.18 s, sys: 0.00 s, total: 0.18 s
Wall time: 0.22 s
In [4]: %time s = sturm(f, x)
CPU times: user 0.18 s, sys: 0.00 s, total: 0.18 s
Wall time: 0.22 s
Almost two times faster than with int and Fraction (2.6).
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en
-~----------~----~----~----~------~----~------~--~---