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.
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.
In this case if you type a.roots? you will see that there are options,
and in fact a.roots(ring=RR) returns
sage: a.roots(ring=RR)
[(0.998467807920657, 1), (1.19783952189421, 1), (1.38386488335712, 1)]
or also
sage: a.roots(ring=RR, multiplicities=False)
[0.998467807920657, 1.19783952189421, 1.38386488335712]
However, I suggest that for many users who are not pure
mathematicians, having a different (or alternative?) name for the
parameter "ring" might be helpful.
John
> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>
If Sage wants to be a viable alternative to the 4 M's, then it needs to be able
to be usable by people who are not mathematicians. Despite having engineering
degrees I had never come across the term ring (in the mathematical sense),
before getting involved in Sage.
Dave
And maybe we can even work some of this into the tutorial: some examples
of situations where you want to use the "ring" parameter together with a
note that "ring=number system" or even "ring=RR or CC or QQ".
Mathematicians reading this are not likely to be confused by it, and
non-mathematicians might not run away screaming.
People are likely to know what a polynomial *function* is, and we might
not need to make them aware that it's not the same thing as a
polynomial. But another bit that could go into the tutorial is some
good examples where you want to use polynomials instead of symbolics.
Best,
Alex
--
Alex Ghitza -- http://aghitza.org/
Lecturer in Mathematics -- The University of Melbourne -- Australia