Exercise 4.3.1.
(a)
First, enter the matrix and confirm that itβs symmetric. You can compute the transpose of a SymPy matrix
A
using A.T
.xxxxxxxxxx
import sympy as sy
sy.init_printing()
(b)
Now, find the eigenvalues of Yes, we could jump straight to the answer, but letβs go through the steps anyway. First, compute the characteristic polynomial of You may with to refer to Subsection B.3.2 for the correct syntax to use.
xxxxxxxxxx
β
Now, factor the polynomial:
xxxxxxxxxx
β
Finally, based on the output, input the eigenvalues into the cell below.
xxxxxxxxxx
β
(c)
Recall that if is an eigenvector of corresponding to the eigenvalue then belongs to the nullspace of where is the identity matrix. You can create an identity matrix in SymPy using the syntax
eye(n)
.For each eigenvalue found in part (b), compute the nullspace of You will want to refer to these nullspaces later, so give each one a name. For example, if your first eigenvalue was 7, you could enter something like
E1 = (7*sy.eye(5)-A).nullspace() E1
to get the first eigenspace. Three code cells are provided below. If you are in Jupyter, you can add more cells by clicking the button in the toolbar.
xxxxxxxxxx
β
xxxxxxxxxx
β
xxxxxxxxxx
β
Finally, letβs check our work. Use the command
A.eigenvects()
to compute the eigenvalues and eigenvectors in one step, and confirm that the results match what you found above.xxxxxxxxxx
β