vpa_test


vpa_test, a MATLAB program which demonstrates the use of MATLAB's variable precision arithmetic (VPA) feature.

MATLAB's variable precision arithmetic is only available through the Symbolic Math Toolbox. To find out if you have this toolbox installed, you can type "ver" within your MATLAB session.

In MATLAB, evaluating a symbolic variable means creating a representation of its value, to a given number of digits, as a floating point number. The vpa() command is used to create the floating point representation. Typical uses are:

        r = vpa ( s )
      
which takes the symbolic object s and evaluates it as a symbolic real number to the current default number of digits or
        r = vpa ( s, d )
      
which uses d digits in the real number representation.

The current default number of digits can be found by using the digits() command:

        dignum = digits;
      
or
        dignum = digits ( );
      
The default number of digits can be changed by including an input argument to the digits() command:
        digits ( 50 );
      

To my mind, a significant issue with the symbolic math toolbox is that it is not apparent how to control the printing of the value of a given variable. If I compute something to 80 digits, I can always display it by naming it. But what if I prefer a labeled printout? Various alternatives involving "disp()" and "fprintf()" and string concatenation seem unsatisfactory.

Licensing:

The computer code and data files made available on this web page are distributed under the BSD license.

Languages:

VPA is available in a MATLAB version.

Reference:

  1. David Bailey, Jonathan Borwein,
    Experimental Mathematics: Examples, Methods and Implications,
    Notices of the American Mathematical Society,
    Volume 52, Number 5, pages 502-514.
  2. David Bailey, Karthik Jeyabalan, Xiaoye Li,
    A Comparison of Three High-Precision Quadrature Schemes,
    Experimental Mathematics,
    Volume 14, Number 3, pages 317-329.
  3. Cleve Moler,
    Cleve's Corner: Computing Pi,
    MATLAB News and Notes,
    February 2012.

Source Code:

COMPUTING_PI is a collection of three functions discussed by Cleve Moler for computing pi to many digits.

You can go up one level to the MATLAB source codes.


Last modified on 28 February 2012.