Symbolic Math Toolbox    

Variable-Precision Arithmetic

Overview

There are three different kinds of arithmetic operations in this toolbox:

Numeric
MATLAB floating-point arithmetic
Rational
Maple's exact symbolic arithmetic
VPA
Maple's variable-precision arithmetic

For example, the MATLAB statements

use numeric computation to produce

With the Symbolic Math Toolbox, the statement

uses symbolic computation to yield

And, also with the toolbox, the statements

use variable-precision arithmetic to return

The floating-point operations used by numeric arithmetic are the fastest of the three, and require the least computer memory, but the results are not exact. The number of digits in the printed output of MATLAB double quantities is controlled by the format statement, but the internal representation is always the eight-byte floating-point representation provided by the particular computer hardware.

In the computation of the numeric result above, there are actually three roundoff errors, one in the division of 1 by 3, one in the addition of 1/2 to the result of the division, and one in the binary to decimal conversion for the printed output. On computers that use IEEE floating-point standard arithmetic, the resulting internal value is the binary expansion of 5/6, truncated to 53 bits. This is approximately 16 decimal digits. But, in this particular case, the printed output shows only 15 digits.

The symbolic operations used by rational arithmetic are potentially the most expensive of the three, in terms of both computer time and memory. The results are exact, as long as enough time and memory are available to complete the computations.

Variable-precision arithmetic falls in between the other two in terms of both cost and accuracy. A global parameter, set by the function digits, controls the number of significant decimal digits. Increasing the number of digits increases the accuracy, but also increases both the time and memory requirements. The default value of digits is 32, corresponding roughly to floating-point accuracy.

The Maple documentation uses the term "hardware floating-point" for what we are calling "numeric" or "floating-point" and uses the term "floating-point arithmetic" for what we are calling "variable-precision arithmetic."


  Substitutions Example: Using the Different Kinds of Arithmetic