I was looking for speed with Inverse[] by trying different methods when I came across this.
Inverse[] with its default Method->Automatic is extremely fast. The documentation of Inverse[] says that it will choose one of three methods if left to Automatic, but if you choose any of the three they are all orders of magnitude slower- I mean 1000x or more slower on a large system (n=500). Is there another method being chosen? Maybe it’s attempting symbolic computation or no accelerator (i.e., MKL LAPACK) is used?
Mathematica documentation does tend to be a bit cryptic for my taste. It would be interesting to know more about what is going on under the hood here. References and/or documentation on the algorithms would be of great use.
Why the slow timings while Inverse[] left alone is so fast? Thanks in advance.
V13.2 On Core I9-10900K CPU@3.70GHz Windows 11 PC;
You are correct that those methods apply for exact or symbolic inputs. For matrices if reals, default use of Lapack with MKL or other BLAS library will be much faster.
Since the whole procedure seemed a bit strange, I changed the Matrix to normal real values and and changed it for each run and suppress any form of output.
The exercise, as it turned out, was point out that the documentation should reflect the default for reals is MKL-BLAS/LAPACK and not one of the three methods for exact/symbolic .
Don’t know what is accomplished by the eigenvalues and complex numbers; like to know. Inverse is as old as mathematica (1988) and RepeatedTiming is a built-in symbol from 2015. Remember when getting the timing the first part is the time in seconds and the second part is the output . Suppressing output means only printing the first part [[1]].
If your concerned about scale/accuracy then the timing differences will persist in lower order systems because of the Intel-MKL use. It is designed so as to vectorize and parallelize taking full advantage of the CPUs architecture which makes it the industry standard-- and that is Intel.