Comment #21 on issue 326 by mattpap: sympy.roots_.sturm(...) hangs
http://code.google.com/p/sympy/issues/detail?id=326
I tried roots_hangs.py and it works for me in polys11. Here is a sample
session:
In [1]: var('p')
Out[1]: p
In [2]: coeffs = [ 1.2102094, -4.77023491, 5.55153282]
In [3]: x = 1.3697
In [4]: y = 1.3202
In [5]: poly = Poly(coeffs, p).as_basic()
In [6]: dist = ((x - p)**2 + (y - poly)**2)
In [7]: diff(dist, p)
Out[7]:
⎛ 2⎞
-2.7394 + 2⋅p - (9.54046982 - 4.8408376⋅p)⋅⎝4.23133282 - 4.77023491⋅p +
1.2102094⋅p ⎠
In [8]: radsimp(_)
Out[8]:
2 3
-43.1083030675855 + 67.9934772063355⋅p - 34.6378987697409⋅p +
5.85842716739344⋅p
In [9]: roots(_, p)
Out[9]:
⎧
⎽⎽⎽ 0.0154732135231477
⎪1.35476753221026: 1, 2.26574512431785 + 0.29491474157582⋅ⅈ⋅╲╱ 3 +
───────────────────────────────────────────
⎨
⎽⎽⎽
⎪
0.29491474157582 + 0.29491474157582⋅ⅈ⋅╲╱ 3
⎩
⎽⎽⎽
0.0154732135231477 ⎫
: 1, 2.26574512431785 - 0.29491474157582⋅ⅈ⋅╲╱ 3 +
───────────────────────────────────────────: 1⎪
⎽⎽⎽
⎬
0.29491474157582 -
0.29491474157582⋅ⅈ⋅╲╱ 3 ⎪
⎭
In [10]: sorted([ e.evalf() for e in _.keys() ])
Out[10]: [1.35476753221026, 2.27886180800791 + 0.488088553732365⋅ⅈ,
2.27886180800791 - 0.488088553732365⋅ⅈ]
In [11]: nroots(_8)
Out[11]: [1.35476753221026, 2.27886180800791 + 0.488088553732363⋅ⅈ,
2.27886180800791 - 0.488088553732363⋅ⅈ]
--
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.