Comment #1 on issue 2228 by [email protected]: solve_poly_system: too
complicated result
http://code.google.com/p/sympy/issues/detail?id=2228
First of all. Make sure you don't enter equations this way:
eq1 = 15/2 - 5*y/2 - 3*x/4 + y**2/4 + x**2/16
because 15/2 is *not* a rational number, it's a float. Unless of course you
want to use a numerical solver. Use S(15)/2 or Rational(15, 2). Other terms
can stay as they are in eq1. The same applies to eq2.
solve_poly_system() (you can use solve() as well because it uses this
function) is very generic and not very optimized for any particular case
(this was refined a little bit in polys12 development branch). Computing
Groebner basis of [eq1, eq2] reveals why the result is so complicated:
In [5]: groebner([eq1, eq2], x, y)
Out[5]:
⎡ 2 2 3 ⎤
⎢219 157⋅y 63⋅y 91984 1746400⋅y 569528⋅y 1256⋅y 4⎥
⎢─── + x - ───── + ─────, ───── - ───────── + ───────── - ─────── + y ⎥
⎣ 16 16 64 189 3969 3969 63 ⎦
The last equation we obtained, which is univariate (solvable), is of degree
four and SymPy applies quartic formula in this case. Unfortunately,
implementation of quartic formula isn't optimized very well, so the final
result is complicated.
but has unwanted imaginary part.
This is numerical noise. Use evalf(chop=True) to get rid of this.
--
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.