The Mathematica Journal
Download This Issue
Feature Articles
Graphics Gallery
Tricks of the Trade
In and Out
The Mathematica Programmer
New Products
New Publications
News Bulletins
Editor's Pick
Write Us
About the Journal
Staff and Contributors
Back Issues


Mathematica arbitrary precision arithmetic follows essentially an interval approach. Each number has an associated uncertainty that can be interpreted as the size of an interval. The result of an arithmetic operation or function evaluation is another number with its uncertainty adjusted so that the image of the source interval lies entirely in the result interval. These methods are used most often for high-precision calculations, that is, small intervals. (For information on the details of Mathematica's arithmetic, see Mark Sofroniou's numerics report [4]. This article can also be found in the Version 3.0 Help Browser, hidden in the Notebook Demos section of the Getting Started/Demos category.) Intervals also can be used for low-precision calculations. From the application of a larger interval to a function, we can obtain global information about the function.

An interval [Graphics:../Images/index_gr_6.gif] is described by two real numbers [Graphics:../Images/index_gr_7.gif] and represents all real numbers [Graphics:../Images/index_gr_8.gif] with [Graphics:../Images/index_gr_9.gif]. Mathematica represents such intervals by Interval[[Graphics:../Images/index_gr_10.gif]]. An extension of this notation, Interval[[Graphics:../Images/index_gr_11.gif],[Graphics:../Images/index_gr_12.gif],[Graphics:../Images/index_gr_13.gif]], represents the union of several intervals.

Interval arithmetic guarantees inclusion of results. Let [Graphics:../Images/index_gr_14.gif] be a real-valued function of n real arguments, and let [Graphics:../Images/index_gr_15.gif] be [Graphics:../Images/index_gr_16.gif] intervals. The result [Graphics:../Images/index_gr_17.gif] of applying f to the intervals is defined as the least interval [Graphics:../Images/index_gr_18.gif] such that [Graphics:../Images/index_gr_19.gif] whenever [Graphics:../Images/index_gr_20.gif]. With machine arithmetic, it may be impossible to represent [Graphics:../Images/index_gr_21.gif] precisely; in this case a larger interval [Graphics:../Images/index_gr_22.gif] with representable boundaries is used. It may also be infeasible to find the smallest possible interval [Graphics:../Images/index_gr_23.gif]; in this case a larger interval is used.

In the case of the addition function [Graphics:../Images/index_gr_24.gif], it is easy to find the smallest result [Graphics:../Images/index_gr_25.gif] is equal to [Graphics:../Images/index_gr_26.gif] rounded down, and [Graphics:../Images/index_gr_27.gif] is equal to [Graphics:../Images/index_gr_28.gif] rounded up. Similar methods are used for products and powers of intervals. They form the basis of interval arithmetic.

Here are the internal representations of the numbers [Graphics:../Images/index_gr_29.gif], [Graphics:../Images/index_gr_30.gif], [Graphics:../Images/index_gr_31.gif], and [Graphics:../Images/index_gr_32.gif] as machine numbers. The input form to base 8 lets us see all bits.

BaseForm[{0.3333333333333333, 0.6666666666666666, 0.1111111111111111, 
  0.2222222222222222}, 8]

Machine arithmetic rounds the results to the nearest representable machine numbers.

BaseForm[{0.4444444444444444, 0.8888888888888888}, 8]

Interval arithmetic, on the other hand, rounds down the left end of the interval and rounds up the right end. Compare the values of [Graphics:../Images/index_gr_35.gif] and [Graphics:../Images/index_gr_36.gif] with the previous results.

BaseForm[Interval[{0.4444444444444443, 0.8888888888888891}], 8]

If the argument of Interval[[Graphics:../Images/index_gr_38.gif]] is a single number, the smallest nontrivial interval containing [Graphics:../Images/index_gr_39.gif] is returned. With [Graphics:../Images/index_gr_40.gif] the result is ±$MinMachineNumber.

Interval[{-2.2250738585072014*^-308, 2.2250738585072014*^-308}]

The reciprocal of the interval [Graphics:../Images/index_gr_42.gif] with [Graphics:../Images/index_gr_43.gif] is the union of the two intervals [Graphics:../Images/index_gr_44.gif] and [Graphics:../Images/index_gr_45.gif].


Inverting it again gives an interval that is larger than the original z, because of the outward rounding performed at each step.


For elementary functions [Graphics:../Images/index_gr_50.gif], interval arithmetic uses three techniques to find the result of [Graphics:../Images/index_gr_51.gif]:

· Knowledge of the singularities and discontinuities of [Graphics:../Images/index_gr_52.gif] is used to check whether [Graphics:../Images/index_gr_53.gif] contains any of these special values.
· Taylor-series approximations are used to bound the values of [Graphics:../Images/index_gr_54.gif] for all [Graphics:../Images/index_gr_55.gif].
· Knowledge of properties of [Graphics:../Images/index_gr_56.gif] is used to bound the results more tightly.

For example, the tangent has a singularity at [Graphics:../Images/index_gr_57.gif].


The sine is monotonically increasing between 0 and [Graphics:../Images/index_gr_60.gif], so the following result can be computed simply by rounding down Sin[0.1] and rounding up Sin[1.4].


While a Taylor series could not bound the values of the sine in the interval [Graphics:../Images/index_gr_63.gif] exactly, the fact that [Graphics:../Images/index_gr_64.gif] for all [Graphics:../Images/index_gr_65.gif] is used in this calculation.


In a calculation of [Graphics:../Images/index_gr_68.gif], interval or otherwise, it is assumed that [Graphics:../Images/index_gr_69.gif] and [Graphics:../Images/index_gr_70.gif] are independent. This assumption often leads to overly pessimistic error estimates, as the following example shows.

Both sine and cosine lie between [Graphics:../Images/index_gr_71.gif] and 1, so their product is also between [Graphics:../Images/index_gr_72.gif] and 1. Without knowing that the two arguments are the same, this result is the best possible.


The equivalent formula [Graphics:../Images/index_gr_75.gif] gives a sharper result. Because [Graphics:../Images/index_gr_76.gif] is between [Graphics:../Images/index_gr_77.gif] and 1, [Graphics:../Images/index_gr_78.gif] is between [Graphics:../Images/index_gr_79.gif] and [Graphics:../Images/index_gr_80.gif].


Converted by Mathematica      October 15, 1999

[Next Page]