lettura simple

Characteristic polynomial of a matrix in Matlab

In this lesson, I will explain how to calculate the characteristic polynomial of a matrix in Matlab.

What is the characteristic polynomial? It is the determinant of the difference between a square matrix A and an identity matrix Idn with the same number of rows and columns (n), multiplied by a variable lambda (λ). $$ p_A ( \lambda ) = \det(A - \lambda \cdot Id_n ) $$ It is useful for finding the eigenvalues..

Let's look at a practical example.

Create a 2x2 square matrix in the variable M.

>> M=[2 1;0 1]
M =
2 1
0 1

It is a matrix with two rows and two columns.

$$ M = \begin{pmatrix} 2 & 1 \\ 0 & 1 \end{pmatrix} $$

To calculate the characteristic polynomial of matrix M, type the function poly(M)

>> poly(M)
ans =
1 -3 2

The function returns a sequence of numbers as output: 1, -3, 2.

These are the coefficients of the lambda (λ) variable in the characteristic polynomial, with the degrees in descending order.

$$ 1 \cdot \lambda^2 - 3 \cdot \lambda^1 + 2 \cdot \lambda^0 $$

Note. The last number in the sequence is the coefficient of the lambda variable with degree zero (λ0). The second to last is the coefficient of the lambda variable with degree one (λ1), and so on.

$$ \lambda^2 - 3 \lambda^1 + 2 \cdot 1 $$

$$ \lambda^2 - 3 \lambda + 2 $$

You have found the characteristic polynomial of matrix M.

$$ p_M ( \lambda ) = \lambda^2 - 3 \lambda + 2 $$

Verify. Perform the calculations by hand to verify if the result is correct. $$ p_M ( \lambda ) = \det(M - \lambda \cdot Id_n ) $$ $$ p_M ( \lambda ) = \det [ \ \begin{pmatrix} 2 & 1 \\ 0 & 1 \end{pmatrix} - \lambda \cdot \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} \ ] $$ $$ p_M ( \lambda ) = \det [ \ \begin{pmatrix} 2 & 1 \\ 0 & 1 \end{pmatrix} - \begin{pmatrix} \lambda & 0 \\ 0 & \lambda \end{pmatrix} \ ] $$ $$ p_M ( \lambda ) = \det \ \begin{pmatrix} 2-\lambda & 1 \\ 0 & 1-\lambda \end{pmatrix} $$ $$ p_M ( \lambda ) = (2-\lambda) \cdot (1-\lambda) - 1 \cdot 0 $$ $$ p_M ( \lambda ) = 2 - 2 \lambda - \lambda + \lambda^2 $$ $$ p_M ( \lambda ) = \lambda^2 - 3 \lambda + 2 $$ It is the same result obtained from the poly(M) function. The result is correct.




Report a mistake or post a question




FacebookTwitterLinkedinLinkedin