# Why does np.linalg.eig produce an opposite-signed eigenvector?

I am learning SVD by following this MIT course. In this video, the lecturer is finding the SVD for

$$\begin{pmatrix} 5 & 5 \\ -1 & 7 \end{pmatrix},$$

which involves finding the eigenvalues for

$$C^T C = \begin{pmatrix} 26 & 18 \\ 18 & 74 \end{pmatrix}.$$

In the example (at the time in the link above), the lecturer finds eigenvalues

$$\begin{pmatrix}-3/\sqrt{10} \\ 1/\sqrt{10} \end{pmatrix}, \begin{pmatrix} 1/\sqrt{10} \\ 3/\sqrt{10} \end{pmatrix}.$$

But np.linalg.eig produces the opposite vector to the second one:

w, v = np.linalg.eig(C.T*C)
v
matrix([[-0.9486833 , -0.31622777],
[ 0.31622777, -0.9486833 ]])


Why?

## 1 Answer

Any scalar multiple of an eigenvector is also an eigenvector. LAPACK (which np.linalg.eig uses under the hood) chooses to return unit-length eigenvectors (good for SVD!), but this still leaves two choices, and there doesn't seem to be a convention for which one to return; it's up to the underlying algorithm (which in turn may depend on the input data).

https://stackoverflow.com/questions/17998228/sign-of-eigenvectors-change-depending-on-specification-of-the-symmetric-argument

• thanks for your answer. would you please point out which rule apples for this specific case? – Jay Jun 26 at 7:55
• I've had a quick look, but can't see it yet. numpy is calling _umath_linalg.eig ( github.com/numpy/numpy/blob/v1.16.1/numpy/linalg/… ), which seems to in turn use one of the *geev. As the answer in my SO link says, from there you'd need to understand the FORTRAN code underlying that function, and that's deeper than I want to dig for this. – Ben Reiniger Jun 26 at 14:18
• thanks for your reply! what does "*geev" mean? – Jay Jun 26 at 21:52
• I was trying to reference the different drivers LAPACK uses for solving variants of the eigenproblem; having known about ones named dgeev and zgeev, and having seen somewhere "_geev", I was just trying to indicate the family. As it turns out, there are a lot more: netlib.org/lapack/lug/node32.html#tabdriveseig – Ben Reiniger Jun 27 at 0:54