This is also a bug in the sense that the only exception that should ever be raised by solve() should be NotImplementedError.
Aaron Meurer On Tue, Sep 3, 2013 at 10:49 AM, Ondřej Čertík <[email protected]> wrote: > Hi Alexandre, > > On Sun, Sep 1, 2013 at 5:05 PM, Alexandre Eudes > <[email protected]> wrote: >> Hello Everyone, >> I have noted some stranges behaviours of solve for polynomial in my use of >> sympy. >> >> In case of 4th degree polynomial with 2 two conjugates solutions, solve >> return only two of the four solutions. >> The problem seems to appear only with real coefficients, integer polynomial >> solutions are fine. > > Is there a reason you need floating point coefficients? In my opinion, > one should use floating point only as a last resort. > >> On the other side, sympy roots always gives the good answer. >> >> Example : >>>>> import sympy as sy >>>>> s = sy.S("s") >>>>> expr = 4.0*s**4 + 3.0*s**3 + 3.0*s**2 - 4.0*s + 4.0 >>>>> rt= sy.roots(expr) >>>>> sl= sy.solve(expr) >>>>> print sl,"\n",rt >> [0.490766420298022 - 0.526081774461482*I, 0.490766420298022 + >> 0.526081774461482*I] >> {-0.865766420298022 - 1.08737810369128*I: 1, 0.490766420298022 - >> 0.526081774461482*I: 1, -0.865766420298022 + 1.08737810369128*I: 1, >> 0.490766420298022 + 0.526081774461482*I: 1} >> >> Similarly, solving for 5th degree polynomial return strange error : >> >>>>> sy.solve(s**5+s**4-1.0) >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> File "sympy/sympy/solvers/solvers.py", line 958, in solve >> solution = nfloat(solution, exponent=False) >> File "sympy/sympy/core/function.py", line 2219, in nfloat >> return type(expr)([nfloat(a, n, exponent) for a in expr]) >> File "sympy/sympy/core/function.py", line 2235, in nfloat >> rv = rv.xreplace(dict(reps)) >> File "sympy/sympy/core/basic.py", line 1106, in xreplace >> return self.func(*args) >> File "sympy/sympy/polys/rootoftools.py", line 62, in __new__ >> raise PolynomialError("only univariate polynomials are allowed") >> sympy.polys.polyerrors.PolynomialError: only univariate polynomials are >> allowed >> >> Should I had an issue in the tracker or this problems are already known ? > > Note that this works: > > In [1]: solve(x**5+x**4-1) > Out[1]: > ⎡ ⎛ 5 4 ⎞ ⎛ 5 4 ⎞ ⎛ 5 4 ⎞ > ⎣RootOf⎝x + x - 1, 0⎠, RootOf⎝x + x - 1, 1⎠, RootOf⎝x + x - 1, 2⎠, RootO > > ⎛ 5 4 ⎞ ⎛ 5 4 ⎞⎤ > f⎝x + x - 1, 3⎠, RootOf⎝x + x - 1, 4⎠⎦ > > but this doesn't: > > In [2]: solve(x**5+x**4-1.0) > > yes, I think you should report it. I am attaching a pdf of what > Mathematica does in this case --- > the integer case work the same as in sympy, but the floating point > case returns numerical solution, > while SymPy fails. > > Ondrej > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
