# Any FOSS MATLAB/Octave toolbox for high-speed variable precision arithmetic?

I need to use variable precision arithmetic in MATLAB for an expensive set of computation.

The vpa function provided by the symbolic math toolbox is very slow. I found a non-free alternative toolbox known as "Advanpix" (http://www.advanpix.com/) ,which sped up things by an order of magnitude, using a trial version.

However, my funding body does not allow purchase of any additional software for this project.

Is there a viable/fast alternative to advanpix/vpa for MATLAB ?

• What about this? – nicoguaro Mar 7 '17 at 21:25
• Still quite slow compared to advanpix. Also, seems to be relatively old package. Is there any other toolbox ? – Dr Krishnakumar Gopalakrishnan Mar 7 '17 at 21:54
• Have you tried [mpmath]( mpmath.org) on Python? – nicoguaro Mar 7 '17 at 21:56
• Do you need full variable precision or just extended precision, e.g., quad precision? – horchler Mar 7 '17 at 22:52
• Sometimes if you want the best stuff, you have to pay up. BTW, I'd like to have the nicest house in the world - and i need to get it for free. – Mark L. Stone Mar 8 '17 at 3:11

## 1 Answer

While I do not know of a toolbox which fits the bill, a good open source alternative to MATLAB and Octave which does have a good solution to this problem is Julia. The linear algebra syntax from MATLAB/Octave almost transfers over to Julia directly, though you need to swap indexing like A(i) to A[i]. But after a quick translation, you can use Julia's BigFloats for variable precision numbers. That's a wrapper of the MPFR library which is pretty standard and does okay. A faster implementation for bitsizes <500 is given in ArbFloats.jl which is based on the Arb library. Lastly, if you just want 128-bit numbers, DecFP.jl gives some good implementations.

What's nice about going this route is that Julia's dispatch system makes these just stand-in for standard numbers, so you can use them in most well written libraries. So you can take these high-speed variable precision numbers and just call generic matrix multiplication, SVD factorization, \, differential equation solvers, optimization routines, etc. and expect them to work in place of Float64s.

• Thank you for the answer. Unfortunately, there are other inseparable pieces of this complex project (about 3000 lines of code) which relies on external MATLAB-only toolboxes, and hence migrating to Julia at this stage looks difficult. However, I had a look at the julia library and it seems to be useful for future projects. Thanks a lot for the suggestion though. – Dr Krishnakumar Gopalakrishnan Mar 8 '17 at 8:01