Challenge - 5 Problems
Eigen Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
â Predict Output
intermediate2:00remaining
What 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
intermediate1:00remaining
Number 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
advanced2:00remaining
Identify 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
advanced1:30remaining
What 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
expert2:30remaining
Find 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.