This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

SetAccuracy

SetAccuracy
yields a version of expr in which all numbers have been set to have accuracy a.
  • When SetAccuracy is used to increase the accuracy of a number, the number is padded with zeros. The zeros are taken to be in base 2. In base 10, the additional digits are usually not zeros.
  • When expr contains machine-precision numbers, SetAccuracy can give results that differ from one computer system to another.
  • SetAccuracy will first expose any hidden extra digits in the internal binary representation of a number, and, only after these are exhausted, add trailing zeros. »
  • generates a number with all trailing digits zero and accuracy 25 on any computer system.
Set the accuracy of all numbers in an expression to 20:
Convert from a machine number to an arbitrary-precision number with accuracy 32:
Set the accuracy of all numbers in an expression to 20:
In[1]:=
Click for copyable input
Out[1]=
 
Convert from a machine number to an arbitrary-precision number with accuracy 32:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Set the accuracy of a complex number:
Convert approximate numbers to exact rational numbers:
The result has trailing zeros once any hidden digits are exposed:
SetAccuracy does not affect exact powers:
This allows you to, for example, change the accuracy of polynomial coefficients:
Inexact powers are modified:
Special rules may apply to data objects:
For an InterpolatingFunction object, SetAccuracy changes the appropriate data only:
It works as an approximate function, but with arithmetic appropriate for the modified data:
Find the roundoff error in evaluating an expression with machine numbers:
This dominates the approximation error since the increment is so small:
SetAccuracy just sets the precision of numbers, while N works adaptively:
Since N works adaptively, the result has the requested accuracy of 20:
The accuracy is less than 20 because of the way the exponential function magnifies the result:
SetAccuracy effectively evaluates Exp with argument 10 to accuracy 20:
For nonzero numbers , SetAccuracy is equivalent to SetPrecision:
e is given by RealExponent:
New in 2