Explore Library
Code QuizIntermediate

Extracting an Eigenvector from np.linalg.eig

A common indexing mistake when reading eigenvectors returned by NumPy.

Codepython
import numpy as np

A = np.array([[2, 0],
              [0, 3]])

eigenvalues, eigenvectors = np.linalg.eig(A)

# eigenvector corresponding to the first eigenvalue
first_vec = eigenvectors[0]
print(first_vec)

What is the bug in this code?