Skip to main content
Tweeted twitter.com/StackMma/status/1207813016349270017
Tags
Link
Michael E2
  • 244.8k
  • 18
  • 351
  • 774
Source Link
Maya
  • 81
  • 4

Linear Algebra in Arbitrary Precision - SLOW

I am trying to implement an arbitrary precision algorithm, but I am not very familiar with Mathematica or arbitrary precision arithmetic. I was able to implement it but surprised by how much slower it is than a machine precision implementation and worried not that I am missing something.

Basic arithmetic seems unreasonably slow in arbitrary precision compared to machine precision. Example:

a = RandomReal[{-10, 10}, {1000, 20}];
Timing[a.Transpose[a];]
Timing[SingularValueDecomposition[a, 20];]

The matrix multiplication takes 0.00657 seconds, the SVD 0.00414 seconds. Now if I would do the same for a number where I set the precision, even if the precision is lower than machine precision, I find:

b =  RandomReal[{-10, 10}, {1000, 20}, WorkingPrecision -> 5];
Timing[b.Transpose[b];]
Timing[SingularValueDecomposition[b, 20];]

where the multiplication takes 7.57129 seconds (!) and the SVD 0.574416 seconds. Is it possible that there are some basic operations that are efficient for arbitrary precision numbers and some are not? How could I make these operations faster? Are there packages available for arbitrary precision linear algebra? I apologise if I am missing something obvious - not a seasoned user.