SetAccuracy
SetAccuracy[expr,a]
yields a version of expr in which all numbers have been set to have accuracy a.
Details
- 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.
- SetAccuracy returns an arbitrary‐precision number even if the number of significant digits obtained will be less than $MachinePrecision.
- When expr contains machine‐precision numbers, SetAccuracy[expr,a] 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. »
- 0.004``25 generates a number with all trailing digits zero and accuracy 25 on any computer system.
- SetAccuracy[expr,a] does not modify expr itself.
Examples
open allclose allBasic Examples (2)
Scope (5)
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:
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:
Applications (1)
Properties & Relations (2)
SetAccuracy just sets the precision of numbers, while N works adaptively:
Since N works adaptively, the result has the requested accuracy of 20:
Use SetAccuracy:
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[x,a] is equivalent to SetPrecision[x,a+e]:
e is given by RealExponent:
Text
Wolfram Research (1991), SetAccuracy, Wolfram Language function, https://reference.wolfram.com/language/ref/SetAccuracy.html.
CMS
Wolfram Language. 1991. "SetAccuracy." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SetAccuracy.html.
APA
Wolfram Language. (1991). SetAccuracy. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SetAccuracy.html