Eigenvalue doesn't zero the characteristic polynomial

I created a symmetric 21 x 21 matrix A with condition number 7.5044. I wrote the following code:
syms x;
AS = sym(A);
polyA = charpoly(AS,x);
solve(polyA);
and This is the result
93.988842796147505104718718233034
63.318989852350135397493503048259
38.392863684000190231816927188875
57.023973670819117411135094232301
20.964197497113106525263127789941
52.100859003607712279511955297751
14.457776205660758291480361189262
72.543368263184623095490492872815
-19.500133944896490949432003697463
65.733078713316290701540791543043
71.723898977718034735792925663278
57.262150118578505531059649955477
27.620774843148443240592651344762
49.356126883789838887152595264487
51.847578071455088288616446818711
70.832873937409296415793129090208
12.524474726415933018910355256388
37.721878707889458815773572522044
-39.123034260347914003761194641743
82.618237465274092122200710770248
12.591224787366274858850190258322
I expect the following code to be close to zero
double(subs(polyA,37.721878707889458815773572522044))
But the answer of the matlab is `-2.2191e+11`, other eigenvalues generate other big numbers as well. Why the eigenvalues don't zero the `polyA` while the condition number is low?

3 个评论

I suggest you attach A in a .mat file, so that we can examine this. But there is no obvious reason why `-2.2191e+11` is to be considered a "big number". If non-eigenvalues generate numbers like 1e+22, then -2.2191e+11 is small by comparison.
eig(A) is exactly the same numbers I listed as the eigenvalues, but the float point precision is 4 digits.

请先登录,再进行评论。

 采纳的回答

The reason for this is that the characteristic polynomial for matrices of even moderate size tends to be ill-conditioned, no matter the condition number of the matrix. For this reason, numerical methods do not use the characteristic polynomial.
For symbolic numbers, the characteristic polynomial works great, but copy-pasting a number such as 37.721878707889458815773572522044 puts you back in the numeric point of view. If you pass in
s = solve(polyA);
double(subs(polyA,s(ind)))
this should return zero for every element of s.
To visualize the problem with using the characteristic polynomial, try plotting it:
x = linspace(-100, 100);
y = double(subs(polyA, sym(x)));
plot(x, y);
ylim([-1e10, 1e10]) % adjust according to the values you see
You should see a bunch of nearly vertical lines crossing the x-axis: a small change in x will result in y being way off.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by