well, Mathematica probably does a counting of real roots before solving (and in any event an equation of odd degree with real coefficients is guaranteed to get at least one real solution). It could also be that it just does a more aggressive rounding than Sage. In any event you can do this rounding, too, say
for i in b: c=i.rhs() if abs(c.n().imag())<1.e-15: print c.n().real() else: print c.n() gives 1.19783952189420 0.998467807920659 1.38386488335712 On Aug 22, 10:23 pm, Oscar Gerardo Lazo Arjona <algebraicame...@gmail.com> wrote: > I'm trying to find the solutions to solve this equation > > sage: a=8594.0*x^3 - 30768.0 *x^2 + 36399.0 *x -14224.0 > sage: b=solve(a==0,x) > sage: for i in b: > ....: c=i.rhs() > ....: print c.n() > ....: > 1.19783952189420 - 4.16333634234434e-17*I > 0.998467807920659 + 1.38777878078145e-17*I > 1.38386488335712 + 2.08166817117217e-17*I > > But I get complex results instead of real ones. If I plot the function, > I can see that it definitely has 3 real solutions > > plot(a,(x,0.9,1.5)) > > I realize that the imaginary parts of the results are minuscule, but > should they be there? In any case sage returns a symbolic expression, > and since I'm using floating point exponents I'd expect to get a > numerical aproximation to the solution. > > Mathematica gets this right: > > sage: mathematica_console() > Mathematica 7.0 for Linux x86 (32-bit) > Copyright 1988-2008 Wolfram Research, Inc. > > In[1]:= a=8594.0*x^3 - 30768.0 *x^2 + 36399.0 *x -14224.0; > > In[2]:= Solve[a==0,x] > > Out[2]= {{x -> 0.998468}, {x -> 1.19784}, {x -> 1.38386}} > > thanks! > > Oscar. -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org