I'm not sure if this helps your situation or not, but if you are interested in the roots of "f(x)=0", then using roots has a much more predictable behaviour. So for example: sage: expr=(x^3+10*x^2+11*x+8) sage: expr.roots() <snip> sage: expr.roots(ring=RR) [(-8.86042628425072, 1)] sage: expr.roots(ring=CC) [(-8.86042628425072, 1), (-0.569786857874640 - 0.760417012386730*I, 1), (-0.569786857874640 + 0.760417012386730*I, 1)]
This way, you're giving just enough hint to SAGE to give you exactly the answer you are looking for. Soroosh On Mon, 23 Aug 2010 20:42:39 +0100 robin hankin <hankin.ro...@gmail.com> wrote: > Hi > > thanks for your earlier answers. > > I quite often do this: > > sage: solve(x^3 + 10*x^2+11*x+8==0,x) > [snip] > > Then I realize that the analytic solution is rather complicated. > So I want a numerical approximation. > > I tried this: > > roots = solve(x^3+10*x^2+11*x+8==0,x) > sage: roots > [x == -1/2*(1/3*sqrt(926) - 613/27)^(1/3)*(I*sqrt(3) + 1) - > 1/18*(-67*I*sqrt(3) + 67)/(1/3*sqrt(926) - 613/27)^(1/3) - 10/3, x == > -1/2*(1/3*sqrt(926) - 613/27)^(1/3)*(-I*sqrt(3) + 1) - > 1/18*(67*I*sqrt(3) + 67)/(1/3*sqrt(926) - 613/27)^(1/3) - 10/3, x == > (1/3*sqrt(926) - 613/27)^(1/3) + 67/9/(1/3*sqrt(926) - 613/27)^(1/3) - > 10/3] > sage: N(roots) > > > but this returns an error ("too many values to unpack"). > > > The best I can do is > > N(roots[1].rhs()) > > but this is just one at a time. How do I make N() operate on all of > roots? Or is there a much neater way of accomplishing the same thing? > > cheers > > rksh > > > > >
signature.asc
Description: PGP signature