#20019: Wrong approximate real roots of cubic equation and matrix eigenvalues
-------------------------------------+------------------------
       Reporter:  dlaurain           |        Owner:
           Type:  PLEASE CHANGE      |       Status:  new
       Priority:  minor              |    Milestone:  sage-7.1
      Component:  numerical          |   Resolution:
       Keywords:  eigenvalues cubic  |    Merged in:
        Authors:                     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
   Dependencies:                     |     Stopgaps:
-------------------------------------+------------------------

Comment (by dlaurain):

 Thanks jdemyer.

 It's rather confusing, because with the following code (it is the
 classical cubic roots computing) :

 {{{
 # MrcEigenValues returns eigenvalues of matrix mq, roots x of det(xI - mq)
 = 0
 def MrcEigenValues(mq):
     f(x) = mq.charpoly('x') #; print "f : ",f
     cf = f.list() #; print " cf = ",cf
     a = cf[3] ; b = cf[2] ; c = cf[1] ; d = cf[0] # equation ax^3 + bx^2 +
 cx + d = 0
     Q = (3*a*c - b^2)/(9*a^2)
     R = (9*a*b*c - 27*a^2*d - 2*b^3)/(54*a^3)
     U = Q^3 + R^2 ; V = 1
     if U < 0:
             U = -U ; V = I
     S = (R + V*sqrt(U))^(1/3)
     T = (R - V*sqrt(U))^(1/3)
     eig1 = S + T -b/(3*a)
     eig2 = -(S + T)/2 - b/(3*a) + I*(sqrt(3)/2)*(S - T)
     eig3 = -(S + T)/2 - b/(3*a) - I*(sqrt(3)/2)*(S - T)
     #
     return [eig1,eig2,eig3]


 m = matrix(SR,3,3, [ [ -0.5898846112288165,  -1.2780028056044432,
 0.19570118737659], [ -0.6573758889893906, 0.7138094643959463,
 0.5958093145901924], [-0.15581144445167106,
 -1.128948696332049,0.02254152681632878] ])
 e = MrcEigenValues(m)
 print "e = ",e
 for i in xrange(3):
     print "e[",i,"] = ",e[i].n()

 }}}

 I used the symbolic ring, and I have no approximate values :


 {{{
 e =  [0.665664016441795, -0.30389127563424534*sqrt(3) -
 0.2595988182291682, 0.30389127563424534*sqrt(3) - 0.2595988182291682]
 e[ 0 ] =  0.665664016442000
 e[ 1 ] =  -0.785953947604006
 e[ 2 ] =  0.266756311146006

 }}}

 I coded it yesterday and not tested so much.
 I posted long time ago a similar post on googlegroups sage and the answer
 was same than yours : coerce to the solutions field.
 Kind of maxima behaviour with the SR : try to keep all symbolic, rational
 and with sqrt ... I am a math newbie in Galois's theory and expressing
 roots with radicals.

--
Ticket URL: <http://trac.sagemath.org/ticket/20019#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to