Error while Diagonalizing the Matrix

1 vue (au cours des 30 derniers jours)
Kang san Lee
Kang san Lee le 4 Juil 2020
I'm studying State Space function thesedays, and made a code below
A = [ 0 1 0; 0 0 1; -6 -11 -6];
P = [ 1 1 1; -1 -2 -3; 1 4 9 ];
S = P^(-1);
A1 = S*A*P;
Expected answer was
A1 = [ -1 0 0 ; 0 -2 0 ; 0 0 -3 ]
because of the eigenvalue process, however, it made a conclusion as
A1 = [ -1, -1.7764e-15, -2.6645e-15 ; 2.6645e-15, -2, 7.1054e-15 ; -1.3323e-15, -2.6645e-15, -3 ]
And other variables are calculated just as I expected.
I don't know what makes this kind of error and how can I solve it?
It can be a critical error in the process.

Réponses (1)

Walter Roberson
Walter Roberson le 4 Juil 2020
Do not use P^(-1), which is also known as inv(P), if you can avoid doing so. The calculations have too much numeric difficulty.
Use the \ or / operator insted.
A1 = P\A*P
The answer will not be the exact integers you are expecting, but it will be closer to what you are expecting.
If you need exact values then do not work numerically, work symbolically:
A1 = P\sym(A)*P

Catégories

En savoir plus sur Eigenvalues & Eigenvectors dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by