lettura simple

Characteristic polynomial in Octave

In this lesson I'll explain how to calculate the characteristic polynomial of a square matrix if you use Octave.

What is the characteristic polynomial? You can calculate the characteristic polynomial of a square matrix A by this formula. $$ p_A ( \lambda ) = \det(A - \lambda \cdot Id_n ) $$ It is the determinant of the difference between a square matrix A and an identity matrix Idn of the same order (n) multiplied by a variable lamda (λ). What is it for? The characteristic polynomial is useful for calculating eigenvalues.

I'll give you a practical example.

Create a square matrix in the variable M

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

In this case it is a 2x2 matrix with two rows and two columns.

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

Type poly(M) to get the characteristic polynomial of the matrix M

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

The output result is a list of numbers: 1, -3, 2

They are the coefficients of the lambda variable (λ) in the characteristic polynomial

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

Note. The numbers in the list are the coefficients of the lambda variable (λ) with the degree in descending order. The last number in the sequence is the coefficient of the zero degree variable (λ0). The penultimate is the coefficient of degree one (λ1) etc.

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

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

The final result is the characteristic polynomial of the matrix M.

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

Verify. The calculation of the characteristic polynomial step by step. $$ 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 $$ The final result is correct. It is the same characteristic polynomial calculated with the poly(M) function.




Report a mistake or post a question




FacebookTwitterLinkedinLinkedin