Controlling Precision of Box Calculations
Description
Local Precision Control
Global Precision Control
Calculations with RealBox and ComplexBox objects are controlled by a value called the precision.
The current default value for the working precision is determined from the value of the environment variable Digits as
1 + ilog2( 10^Digits );
34
Most non-operator methods for RealBox and ComplexBox objects accept an option of the form precision = n, where n is a positive integers.
This sets the precision to be used in the call to that method while not affecting other computations.
Notice that the radius of the resulting box is smaller with a higher precision.
sin( RealBox( 0.5 ) );
⟨RealBox: 0.479426±2.95586ⅇ-11⟩
sin( RealBox( 0.5 ), 'precision' = 100 );
⟨RealBox: 0.479426±4.00593ⅇ-31⟩
plots:-display( Array( [ plot( x -> Radius(sin(RealBox(x), precision = 30)), -2*Pi .. 2*Pi), plot( x -> Radius(sin(RealBox(x), precision = 40)), -2*Pi .. 2*Pi) ] ) );
You can control the precision used by box object methods by setting the value of the environment variable _EnvBoxPrecision to a positive integer.
For more information on the use of environment variables, see envvar.
For calculations with arithmetic operators, this is the only way to control the precision used in calculations involving both real and complex boxes.
p := 7*x^5-22*x^4+55*x^3+94*x^2-87*x+56;
p≔7⁢x5−22⁢x4+55⁢x3+94⁢x2−87⁢x+56
eval( p, x = RealBox( 2.3 ) );
⟨RealBox: 857.239±1.30933ⅇ-06⟩
_EnvBoxPrecision := 100:
⟨RealBox: 857.239±1.66466ⅇ-26⟩
_EnvBoxPrecision := '_EnvBoxPrecision':
Setting the _EnvBoxPrecision variable does not affect the value of Digits. However, changing the value of Digits causes the precision used to be reflected accordingly, although the value of _EnvBoxPrecision itself is not modified.
Digits := 100:
⟨RealBox: 857.239±1.34404ⅇ-96⟩
See Also
ComplexBox
Digits
envvar
RealBox
Download Help Document