Finding Eigenvalues and Eigenvectors Example 1
In this example we will find the eigenvalues and a corresponding eigenvector for each eigenvalue for the matrix
First we introducte the matrix and we store it in the variable A
A = matrix([[ 7, -5], \
[10, -8]])
Eigenvalues
To find the eigenvalues we will calulate
However, in SageMath (as well as in Python), lambda
is a reserved word. So we will use the letter AmlI
:
l = var('l', latex_name=r'\lambda')
AmlI = A - l*identity_matrix(2)
Here, we have used the function identity_matrix
with argument 2
to create the corresponding identity matrix.
To find the eigenvalues we need to calculate the determinant of determinant
from the matrix class. We will create the characteristic equation
p(l) = AmlI.determinant()
We can check the equation by using the function show.
show(p(l).expand())
The output is
Finding the zeros of this equation will give us the eigenvalues.
In our case:
is a zero since . is a zero since .
The eigenvalues are
Eigenvectors
To find the eigenvectors, we need to solve the system
Let’s do it!
Eigenvector with associated eigenvalue .
We substitue L1
:
L1 = AmlI(l=2)
Now we multiply the matrix by the column vector y
NOTE: Although we call it “column vector”, it should be a matrix in SageMath.
y = var('y')
L1xy = L1*matrix([[x],[y]])
If we use the function show
, we can visualize the matrix L1xy
:
Now we can see that one equation is a multiple of the other. Therefore, we could choose, for example, the first equation
And we obtain the line
And we can choose
Eigenvector with associated eigenvalue .
We repeat the same procedure above.
We substitue L2
:
L2 = AmlI(l=-3)
Now we multiply the matrix by the column vector y
y = var('y')
L2xy = L2*matrix([[x],[y]])
If we use the function show
, we can visualize the matrix L2xy
:
Now we can see that one equation is a multiple of the other. Therefore, we could choose, for example, the first equation
And we obtain the line
And we can choose