Challenge - 5 Problems
Eigen Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of eigenvalues and eigenvectors calculation
What is the output of the following code that calculates eigenvalues and eigenvectors of a matrix using scipy.linalg.eig?
SciPy
import numpy as np from scipy.linalg import eig A = np.array([[2, 1], [1, 2]]) eigenvalues, eigenvectors = eig(A) print(np.round(eigenvalues, 2)) print(np.round(eigenvectors, 2))
Attempts:
2 left
💡 Hint
Remember eigenvalues are sorted in the order returned by eig, and eigenvectors correspond column-wise.
✗ Incorrect
The matrix [[2,1],[1,2]] has eigenvalues 3 and 1. The eigenvector for eigenvalue 3 is [0.71, 0.71] and for 1 is [-0.71, 0.71]. The output shows eigenvalues as complex numbers with zero imaginary part.
❓ data_output
intermediate2:00remaining
Number of eigenvalues for a non-square matrix
What happens when you try to compute eigenvalues of a non-square matrix using scipy.linalg.eig? How many eigenvalues are returned?
SciPy
import numpy as np from scipy.linalg import eig B = np.array([[1, 2, 3], [4, 5, 6]]) eigenvalues, eigenvectors = eig(B)
Attempts:
2 left
💡 Hint
Eigenvalues are defined only for square matrices.
✗ Incorrect
The eig function requires a square matrix. Passing a non-square matrix raises a ValueError indicating the input must be square.
🧠 Conceptual
advanced2:00remaining
Interpretation of complex eigenvalues
A real 2x2 matrix has eigenvalues 1+2j and 1-2j. What does this imply about the matrix's behavior?
Attempts:
2 left
💡 Hint
Complex conjugate eigenvalues often indicate rotation in 2D space.
✗ Incorrect
Complex conjugate eigenvalues with nonzero imaginary parts indicate the matrix performs a rotation combined with scaling in the plane.
🔧 Debug
advanced2:00remaining
Identify the error in eigenvalue calculation code
What error does the following code produce and why?
import numpy as np
from scipy.linalg import eig
C = np.array([[1, 2], [3, 4], [5, 6]])
eigenvalues, eigenvectors = eig(C)
Attempts:
2 left
💡 Hint
Check the shape of the matrix passed to eig.
✗ Incorrect
The matrix C is 3x2, not square. eig requires a square matrix and raises ValueError.
🚀 Application
expert3:00remaining
Using eigenvectors to diagonalize a matrix
Given a symmetric matrix M, which code snippet correctly diagonalizes M using its eigenvectors and eigenvalues?
SciPy
import numpy as np from scipy.linalg import eig M = np.array([[4, 1], [1, 3]])
Attempts:
2 left
💡 Hint
Diagonalization formula: M = V D V^{-1} where V columns are eigenvectors.
✗ Incorrect
For diagonalization, M = V D V^{-1} where V is eigenvector matrix and D diagonal eigenvalue matrix. Since M is symmetric, eig returns eigenvectors that are orthogonal but eig does not guarantee orthonormality, so inverse is needed, not transpose.