Challenge - 5 Problems
Eigen Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateWhat is the output of eigenvalues from a 2x2 matrix?
Given the matrix
[[4, 2], [1, 3]], what are the eigenvalues computed by np.linalg.eig()?NumPy
import numpy as np matrix = np.array([[4, 2], [1, 3]]) eigenvalues, _ = np.linalg.eig(matrix) print(eigenvalues)
Attempts:
2 left
💡 Hint
Recall eigenvalues satisfy the characteristic equation det(A - λI) = 0.
✗ Incorrect
The eigenvalues of the matrix [[4, 2], [1, 3]] are 5 and 2, which satisfy the characteristic polynomial λ² - 7λ + 10 = 0.
❓ data_output
intermediateNumber of eigenvalues returned by np.linalg.eig()
If you apply
np.linalg.eig() to a 3x3 matrix, how many eigenvalues will be returned?NumPy
import numpy as np matrix = np.eye(3) eigenvalues, _ = np.linalg.eig(matrix) print(len(eigenvalues))
Attempts:
2 left
💡 Hint
The number of eigenvalues equals the size of the matrix dimension.
✗ Incorrect
For an n x n matrix, np.linalg.eig() returns n eigenvalues.
🔧 Debug
advancedIdentify the error in eigenvalue calculation code
What error will this code raise?
import numpy as np matrix = np.array([1, 2, 3, 4]) eigenvalues, eigenvectors = np.linalg.eig(matrix)
NumPy
import numpy as np matrix = np.array([1, 2, 3, 4]) eigenvalues, eigenvectors = np.linalg.eig(matrix)
Attempts:
2 left
💡 Hint
Check the shape of the input matrix for eig().
✗ Incorrect
np.linalg.eig() requires a square matrix (2D with equal dimensions). A 1D array causes LinAlgError.
🧠 Conceptual
advancedWhat does np.linalg.eig() return?
Which of the following best describes the outputs of
np.linalg.eig() when applied to a square matrix?Attempts:
2 left
💡 Hint
Think about what information is needed to fully describe eigen decomposition.
✗ Incorrect
np.linalg.eig() returns two objects: an array of eigenvalues and a matrix whose columns are the corresponding eigenvectors.
🚀 Application
expertFind the eigenvalue with the largest magnitude
Given the matrix
[[0, -1], [1, 0]], which eigenvalue has the largest absolute value?NumPy
import numpy as np matrix = np.array([[0, -1], [1, 0]]) eigenvalues, _ = np.linalg.eig(matrix) max_abs = max(abs(eigenvalues)) print(max_abs)
Attempts:
2 left
💡 Hint
Consider eigenvalues of rotation matrices and their magnitudes.
✗ Incorrect
The matrix represents a 90-degree rotation; eigenvalues are complex numbers with magnitude 1.
