vpa
Variable-precision arithmetic (arbitrary-precision arithmetic)
Description
Examples
Input Arguments
Output Arguments
Tips
vpa
does not convert fractions in the exponent to floating point. For example,vpa(a^sym(2/5))
returnsa^(2/5)
.vpa
uses more digits than the number of digits specified bydigits
. These extra digits guard against round-off errors in subsequent calculations and are called guard digits.When you call
vpa
on a numeric input, such as1/3
,2^(-5)
, orsin(pi/4)
, the numeric expression is evaluated to a double-precision number that contains round-off errors. Then,vpa
is called on that double-precision number. For accurate results, convert numeric expressions to symbolic expressions withsym
. For example, to approximateexp(1)
, usevpa(exp(sym(1)))
.If the second argument
d
is not an integer,vpa
rounds it to the nearest integer withround
.vpa
restores precision for numeric inputs that match the forms p/q, pπ/q, (p/q)1/2, 2q, and 10q, where p and q are modest-sized integers.Variable-precision arithmetic is different from IEEE® Floating-Point Standard 754 in these ways:
Inside computations, division by zero throws an error.
The exponent range is larger than in any predefined IEEE mode.
vpa
underflows below approximately10^(-323228496)
.Denormalized numbers are not implemented.
Zeros are not signed.
The number of binary digits in the mantissa of a result may differ between variable-precision arithmetic and IEEE predefined types.
There is only one
NaN
representation. No distinction is made between quiet and signalingNaN
.No floating-point number exceptions are available.