Bird
0
0

What will be the output of the following code?

medium📝 Predict Output Q4 of 15
SciPy - Linear Algebra (scipy.linalg)
What will be the output of the following code?
import numpy as np
from scipy.linalg import eig
A = np.array([[0, -1], [1, 0]])
values, vectors = eig(A)
print(values)
A[1. 0.]
B[0.+1.j 0.-1.j]
C[0. 1.]
D[1.+0.j 1.-0.j]
Step-by-Step Solution
Solution:
  1. Step 1: Understand the matrix

    The matrix A = [[0, -1], [1, 0]] represents a 90-degree rotation in 2D space.
  2. Step 2: Compute eigenvalues

    The eigenvalues of this rotation matrix are complex conjugates: +i and -i, which correspond to 0 + 1j and 0 - 1j in Python notation.
  3. Final Answer:

    [0.+1.j 0.-1.j] -> Option B
  4. Quick Check:

    Eigenvalues of rotation matrices are complex conjugates [OK]
Quick Trick: Rotation matrices have purely imaginary eigenvalues [OK]
Common Mistakes:
MISTAKES
  • Expecting real eigenvalues for rotation matrices
  • Confusing eigenvalues with eigenvectors
  • Ignoring complex number notation in output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes