-1

When calculating eigenvalues and eigenvectors of a matrix, the eigenmatrix times itself should result in the identity matrix (E @ E.T = I). However, this is rarely the case, as some (small) errors always occurs.

So question 1: how precise are eigenvalues / eigenvectors calculated? And question 2: is there any way to improve precision?

Mark
  • 45
  • 5
  • 3
    This is not a property of the programming language Python, but of the algorithms and libraries used. Python would allow calculations with arbitrary precision. – mkrieger1 Feb 17 '23 at 21:41
  • 1
    can you provide an example of small errors that are occurring? it will be easier to help you if we can reproduce the behavior you're referring to – Derek O Feb 17 '23 at 21:48
  • Any matrix with differing values (large and small) leads to errors. When calculating the eigenmatrix and multiplying as stated, the identity vector is not exactly found. – Mark Feb 17 '23 at 21:56

1 Answers1

3
  1. I assume you are using a standard library for this, such as:

https://numpy.org/doc/stable/reference/generated/numpy.linalg.eigh.html

or

https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eig.html

which I would expect to employ high speed floating point operations under the hood.

And so the (high) precision of 64 bit IEEE floats is a bound.

Far to the right of the decimal, you may find variances in results from run to run, due to the way FPUs cache and process (higher precision) intermediate results during context switches. Google returned a number of quick hits here, such as:

https://indico.cern.ch/event/166141/sessions/125686/attachments/201416/282784/Corden_FP_control.pdf

  1. As for improving precision, your question is well discussed here, where a slower but higher resolution library is mentioned:

Higher precision eigenvalues with numpy

You might also consider using Mathematica.

https://math.stackexchange.com/questions/87871/how-to-obtain-eigenvalues-with-maximum-precision-in-mathematica

Chris Moth
  • 46
  • 2