Initial due date: Sunday, March 26 at 11:59pm ET
Eigenvalues of a matrix are incredibly useful and important for many applications. (Some of these applications are in Miniprojects 1-3.) But computing eigenvalues of a matrix, even of relatively small size, can be difficult or impossible to do exactly. So we need numerical approximation methods for most practical uses of eigenvalues. This miniproject will teach you one such method.
Prerequisites: You'll need to know what an eigenvalue and eigenvector for a matrix are, and how to find these using SymPy. You'll also need to know how to multiply matrices and vectors.
Complete the following warmup exercises first. These don't go in your writeup. They are just here to teach you some terminology you'll need in the main assignment.
Definition: Suppose \(A\) is an \(n \times n\) matrix and \(\lambda_1, \lambda_2, \dots, \lambda_n\) are its eigenvalues. Then \(\lambda_1\) is called the dominant eigenvalue of \(A\) if \(|\lambda_1| > |\lambda_i|\) for all \(i \neq 1\). The eigenvectors corresponding to \(\lambda_1\) are called dominant eigenvectors of \(A\).
Example: The matrix \(A = \begin{bmatrix} -2 & 0 \\ 0 & 1 \end{bmatrix}\) has eigenvalues of \(-2\) and \(1\). Of these, \(\lambda = -2\) is the dominant eigenvalue since \(|-2| > |1|\). A dominant eigenvector for \(A\) would be \([1,0]^T\) since that's an eigenvector corresponding to the dominant eigenvalue \(\lambda = -2\).
Example: The matrix \(A = \begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix}\) doesn't have a dominant eigenvalue, since its two eigenvalues are \(-1\) and \(1\), and neither \(|-1| > |1|\) nor \(|1| > |-1|\).
Exercise: Find the dominant eigenvalue and a dominant eigenvector for
\[B = \left[\begin{matrix}11 & 0 & -4\\17 & -2 & -5\\30 & 0 & -11\end{matrix}\right]\]
Answer: \(\lambda_1 = -2\) is the dominant eigenvalue and \(\mathbf{v}_1 = [0,1,0]^T\) is a dominant eigenvector.
The first problem illustrates the computational issues with using our basic method for finding eigenvalues. So rather than find the eigenvalues of a matrix algebraically, it's often enough to (1) find just the dominant eigenvalue, and (2) get a reasonable numerical approximation to it. The rest of this miniproject walks you through one method for doing this.
for eigenvalue in B.eigenvals().keys():
print(N(eigenvalue))
This will print approximate values of the eigenvalues. Which one is dominant? What is the percentage error in your approximation?
You will be really well served to use SymPy as much as possible on this miniproject. You should be doing no work by hand; and moreover, tapping in to some of SymPy's capabilities will lighten your load considerably.
Here are some things you can do with SymPy that are relevant to this Miniproject.
**
just like we raise numbers or symbols to powers.a
with the vector b
, enter a.dot(b)
. To take the square root of an number \(x\), enter sqrt(x)
. You can put these functions together with what you already know how to do in SymPy to automate much of the math in question 5.N( )
. For example try N(sqrt(5))
.print( )
around the thing you want to display. For example, try print(Matrix(2,2,[1,2,3,4]))
.for
loop construction in Python is helpful. Here's an example of a for
loop that would print off the squares of the numbers 1 through 100:for i in range(1,101):
print(i**2)
In Python, ranges stop just before the upper limit, so range(1,101)
is 1, 2, 3, …, 100.
Please review the section on Miniprojects in the document Standards For Student Work in MTH 302 before attempting to write up your submission. Note that all Miniprojects:
Your work here is being evaluated partially on whether your math and code are correct; but just as much on whether your reasoning is correct and clearly expressed. Make sure to pay close attention to both.
Miniproject 3 must be done in a Jupyter notebook using SymPy to carry out all mathematical calculations. A sample notebook, demonstrating the solution to a Calculus problem, can be found here. Study this first before writing up your work.
You will submit your work on Blackboard in the Miniproject 4 folder under Assignments > Miniprojects. But you will not upload a PDF for Miniprojects. Instead you will share a link that allows me (Talbert) to comment on your work. As explained in one of the Jupyter and Colab tutorials, the process goes like this:
I will then evaluate your work using the link. Specific comments will be left on the notebook itself. General comments will be left on Blackboard.