Why are these 2 ways of finding eigenvectors different in python?

Viewed 216
import numpy as np
#first way
A = np.array([[1, 0, 1], [-2, 1, 0]])
print(A)
B = A@A.transpose()
print(B)
eig_val, eig_vec = np.linalg.eig(B)
print(eig_vec)

#second way
from sympy import * 
G = Matrix([[2,-2], [-2,5]])
print(G.eigenvects())

Why does these two ways give different result when they are aiming a same goal of finding the eigenvectors?

1 Answers

It has already been mentioned that eignevectors are only unique upto a scalar multiple. That's a mathematical fact. To dig into the implementations of the methods you're using, numpy.linalg.eig returns normalized eigenvectors (i.e. the norm of the vectors would be 1) whereas eigenvects() of sympy does not normalize the vectors.

In some sense, normalized vectors are unique precisely because they have unit norm. They can define a unit eigendirection (geometrically), just like unit vectors in coordinate geometry. (Not strictly important to know)

Related