Experiences with the Multiprecision Computing Toolbox
The Advanpix Multiprecision Computing (MP) Toolbox is a MATLAB extension for numerical computing with arbitrary precision . Some members of our Numerical Linear Algebra Group have been long-time users of this toolbox for the research, implementation, and testing of numerical algorithms. A particular feature of the MP Toolbox over MATLAB’s own variable precision arithmetic (VPA) is the comparably low overhead at which multiprecision computations can be performed.
Here is a quick comparison of the MP Toolbox version 22.214.171.12418 versus MATLAB R2022A’s VPA, both run on a standard Windows laptop with a 4-core Intel i7 CPU:
rng(0); A = randn(100); mp.Digits(50); % MP Toolbox A1 = mp(A); tic; [V,D] = eig(A1); % about 1.6 seconds toc digits(50); % VPA A2 = vpa(A); tic; [V,D] = eig(A2); % about 142 seconds toc
For this eigendecomposition of a 100×100 matrix, the measured speedup is about 89. Some of MP Toolbox’s speed advantage might be attributable to the efficient utilization of multiple cores, but the big difference in timing suggests an overall more efficient implementation compared to VPA. More timing comparisons are listed on the MP Toolbox website .
Another advantage of the MP Toolbox is its reliability. MATLAB’s VPA can sometimes give plainly wrong results or behave unexpectedly. Here are two examples taken from :
% completely wrong result with MATLAB’s VPA digits(34); real(bessely(vpa(0),vpa(1000i))) % expect -1.2805717...e-436 (i.e. tiny!) ans = -2.540999...e+381 % diff behaves differently on VPA and double matrices A = [ 1; 2; 3 ] diff(vpa(A)) % expect [ 1; 1 ] ans = 0 0 0
In both cases, the MP Toolbox gives the expected results.
There are situations where VPA cannot be used simply because not all MATLAB functions are overloaded for VPA matrices. We experienced this issue when developing the Rational Krylov Toolbox . One of the functionalities required when converting between different representations of rational functions is the accurate solution of potentially ill-conditioned generalized eigenvalue problems. It is not currently possible to call eig(vpa(A),vpa(B)), while with the MP Toolbox calling eig(mp(A),mp(B)) gives the intended result.
As far as we are aware, the MP Toolbox is the best way to do multiprecision computations in MATLAB efficiently and reliably. Over the years our group had very professional and swift support from Pavel Holoborodko, the lead developer of the Advanpix MP Toolbox. We would like to thank him for his dedication.
 Multiprecision Computing Toolbox for MATLAB (advanpix.com)
 User’s Manual (advanpix.com)
 Computing with rational functions (guettel.com)