简体   繁体   English

特征多项式的根和特征值不相同

[英]The roots of the characteristic polynomial and the eigenvalues are not the same

This is matrix B 这是矩阵B

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

The result of eig(B) is: eig(B)的结果是:

{-2.2240, 1.5109, 10.7131}

and the characteristic polynomial of B by this link is 并且该链路B的特征多项式是

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

but the answer of solve(polyB) is solve(polyB)的答案是

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 . 我不知道它是什么,而我期望它是B的特征值。 What is the problem? 问题是什么?

I do not understand why you add x and symbolic maths, they are not required for your task. 我不明白为什么你要添加x和符号数学,它们不是你的任务所必需的。

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) (注意虚部为零)

Since I do not have MATLAB in this machine, I will use SymPy instead: 由于我在这台机器上没有MATLAB,我将使用SymPy代替:

>>> 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. 由于B是对称的,因此其特征值必须是实数。 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: 在LaTeX中打印,根的确切值是:

LaTeX的根源

Note that some roots are "longer" than others, ie, they require more symbols. 请注意,某些根比其他根“更长”,即它们需要更多符号。 However, they are exact . 但是,它们是准确的 Using floating-point arithmetic, all roots have the same "size", but they are approximations. 使用浮点运算,所有根都具有相同的“大小”,但它们是近似值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM