On 2010-08-22 22:23, Oscar Gerardo Lazo Arjona 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 If you're only solving polynomial equations, this problem can be overcome by defining a to be a polynomial:
sage: x = polygen(CC) sage: a = 8594.0*x^3 - 30768.0 *x^2 + 36399.0 *x -14224.0 sage: parent(a) Univariate Polynomial Ring in x over Complex Field with 53 bits of precision sage: a.roots() [(0.998467807920657, 1), (1.19783952189421, 1), (1.38386488335712, 1)] Jeroen. -- 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