On 22 ago, 22:23, 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

The problem with using real (floating point) numbers is that they're
probably solved numerically, using an algorithm that may be oriented
to finding also complex roots (the Laguerre method, for example). So
the first thing I'd suggest is entering the polynomial coefficients as
integer values:

sage: x = var('x'); A = 8594*x^3 - 30768*x^2 + 36399*x -14224
sage: B = solve(A, x)
sage: B[0]
x == -1/2*(I*sqrt(3) + 1)*(1/73856836*I*sqrt(2)*sqrt(5159598107) -
6552490/79340706073)^(1/3) - 1/73856836*(-457267*I*sqrt(3) + 457267)/
(1/73856836*I*sqrt(2)*sqrt(5159598107) - 6552490/79340706073)^(1/3) +
5128/4297

Ok, at least this might have an opportunity of getting simplified.
Let's try:

sage: B[0].full_simplify()
x == -1/17188*((I*sqrt(3) + 1)*(4297*I*sqrt(17)*sqrt(313)*sqrt(969667)
- 13104980*sqrt(2))^(2/3) -
10256*(4297*I*sqrt(17)*sqrt(313)*sqrt(969667) -
13104980*sqrt(2))^(1/3)*sqrt(2) - 457267*I*sqrt(3) + 457267)*sqrt(2)/
(4297*I*sqrt(17)*sqrt(313)*sqrt(969667) - 13104980*sqrt(2))^(1/3)

There doesn't seem to be a way to get rid of the I. Maybe Sage should
implement an algorithm for simplifying complex expressions and trying
to isolate real and imaginary parts, removing them if they're found to
be zero.


Back to floating point numbers, an alternative to solve() is
find_root(), which will attempt to find a numerical solution on a
given interval:

sage: a=8594.0*x^3 - 30768.0 *x^2 + 36399.0 *x -14224.0
sage: a.find_root(-5,5)  # only finds a single root
1.383864883357113

-- 
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

Reply via email to