The roots of the characteristic polynomial and the eigenvalues are not the same

时光毁灭记忆、已成空白 提交于 2019-12-24 07:53:48

问题


This is matrix B

B = [1 2 0 ; 2 4 6 ; 0 6 5]

The result of eig(B) is:

{-2.2240, 1.5109, 10.7131}

and the characteristic polynomial of B by this link is

syms x
polyB = charpoly(B,x)
x^3 - 10*x^2 - 11*x + 36

but the answer of solve(polyB) is

133/(9*(3^(1/2)*5492^(1/2)*(i/3) + 1009/27)^(1/3)) + ((3^(1/2)*5492^(1/2)*i)/3 + 1009/27)^(1/3) + 10/3
 (3^(1/2)*(133/(9*(3^(1/2)*5492^(1/2)*(i/3) + 1009/27)^(1/3)) - ((3^(1/2)*5492^(1/2)*i)/3 + 1009/27)^(1/3))*i)/2 - 133/(18*(3^(1/2)*5492^(1/2)*(i/3) + 1009/27)^(1/3)) - ((3^(1/2)*5492^(1/2)*i)/3 + 1009/27)^(1/3)/2 + 10/3
 10/3 - 133/(18*(3^(1/2)*5492^(1/2)*(i/3) + 1009/27)^(1/3)) - ((3^(1/2)*5492^(1/2)*i)/3 + 1009/27)^(1/3)/2 - (3^(1/2)*(133/(9*(3^(1/2)*5492^(1/2)*(i/3) + 1009/27)^(1/3)) - ((3^(1/2)*5492^(1/2)*i)/3 + 1009/27)^(1/3))*i)/2

which I don't know what it is while I expect it to be the eigenvalues of B. What is the problem?


回答1:


I do not understand why you add x and symbolic maths, they are not required for your task.

B = [1 2 0 ; 2 4 6 ; 0 6 5]
cp=charpoly(B)
eig2=roots(cp)

returns:

eig2 =

   10.7131
   -2.2240
    1.5109

However, if for some reason you insist in using symbolic (which you should not for a numerical task), you can do

double(solve(polyB))

ans =

  10.7131 + 0.0000i
  -2.2240 - 0.0000i
   1.5109 - 0.0000i

(note imaginary parts is zero)




回答2:


Since I do not have MATLAB in this machine, I will use SymPy instead:

>>> from sympy import *
>>> B = Matrix([[1, 2, 0],
                [2, 4, 6],
                [0, 6, 5]])

Computing the characteristic polynomial and its roots:

>>> s = Symbol('s')
>>> p = (s*eye(3) - B).det()
>>> p
s**3 - 10*s**2 - 11*s + 36
>>> roots = solve(p,s)

Computing floating-point approximations of the three roots:

>>> [ r.evalf() for r in roots ]
[1.51092975992931 - 0.e-22*I, -2.22404024437578 + 0.e-22*I, 10.7131104844465 - 0.e-20*I]

Since B is symmetric, its eigenvalues must be real. Note that the imaginary parts of the floating-point approximations of the roots are indeed equal to zero.

Printing in LaTeX, the exact values of the roots are:

Note that some roots are "longer" than others, i.e., they require more symbols. However, they are exact. Using floating-point arithmetic, all roots have the same "size", but they are approximations.



来源:https://stackoverflow.com/questions/49939487/the-roots-of-the-characteristic-polynomial-and-the-eigenvalues-are-not-the-same

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!