# [NumPy-Tickets] [NumPy] #1947: Numerical error in Numpy causes different eigenvector matrices to be returned when close to identity.

NumPy Trac numpy-tickets@scipy....
Mon Sep 5 15:40:14 CDT 2011

```#1947: Numerical error in Numpy causes different eigenvector matrices to be
returned when close to identity.
--------------------+-------------------------------------------------------
Reporter:  shyuep  |       Owner:  somebody
Type:  defect  |      Status:  new
Priority:  normal  |   Milestone:  Unscheduled
Component:  Other   |     Version:  1.5.1
Keywords:          |
--------------------+-------------------------------------------------------
Using numpy to find eigenvectors, I have found that different results are
returned for matrices very close to identity.

An example of the output:
>>> import numpy as np
>>> mat = np.array([[  1,   0,   5.55111512e-17], [  0,   1,   0],  [
5.55111512e-17,   0,   1]])
>>> np.linalg.eig(mat)
(array([ 1.,  1.,  1.]), array([[ 0.70710678, -0.70710678,  0.        ],
[ 0.        ,  0.        ,  1.        ],
[ 0.70710678,  0.70710678,  0.        ]]))
>>> mat = np.array([[  1,   0,   5.55111512e-19], [  0,   1,   0],  [
5.55111512e-17,   0,   1]])
>>> np.linalg.eig(mat)
(array([ 1.,  1.,  1.]), array([[ 0.09950372, -0.15094684,  0.        ],
[ 0.        ,  0.        ,  1.        ],
[ 0.99503719,  0.98854188,  0.        ]]))
>>> mat = np.array([[  1,   0,   5.55111512e-29], [  0,   1,   0],  [
5.55111512e-17,   0,   1]])
>>> np.linalg.eig(mat)
(array([ 1.,  1.,  1.]), array([[  1.00000000e-06,  -9.09494745e-07,
0.00000000e+00],
[  0.00000000e+00,   0.00000000e+00,   1.00000000e+00],
[  1.00000000e+00,   1.00000000e+00,   0.00000000e+00]]))
>>> mat = np.array([[  1,  0,   0], [  0,   1,   0],  [ 0,   0,   1]])
>>> np.linalg.eig(mat)
(array([ 1.,  1.,  1.]), array([[ 1.,  0.,  0.],
[ 0.,  1.,  0.],
[ 0.,  0.,  1.]]))

The first three matrices only differ in one element in the exponent, going
from 5.55111512e-17 to 5.55111512e-19 to 5.55111512e-29, i.e., very small
numbers and the matrices are essentially the identiy matrix.  However, in
all cases, different eigenvectors are returned.  While all the
eigenvectors are valid of course, the different answers creates issues in
comparing the eigenvectors obtained via automatically generated matrices.

This issue does not appear in other numerical packages in other languages.
I have tested the Jama package in Java and consistent eigenvectors are
obtained.

--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1947>
NumPy <http://projects.scipy.org/numpy>
My example project
```