www.delorie.com/gnu/docs/calc/calc_133.html | search |
Buy the book! | |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An interval is a subset of consecutive real numbers. For example, the interval `[2 .. 4]' represents all the numbers from 2 to 4, inclusive. If you multiply it by the interval `[0.5 .. 2]' you obtain `[1 .. 8]'. This calculation represents the fact that if you multiply some number in the range `[2 .. 4]' by some other number in the range `[0.5 .. 2]', your result will lie in the range from 1 to 8. Interval arithmetic is used to get a worst-case estimate of the possible range of values a computation will produce, given the set of possible values of the input.
Calc supports several varieties of intervals, including closed intervals of the type shown above, open intervals such as `(2 .. 4)', which represents the range of numbers from 2 to 4 exclusive, and semi-open intervals in which one end uses a round parenthesis and the other a square bracket. In mathematical terms, `[2 .. 4]' means 2 <= x <= 4, whereas `[2 .. 4)' represents 2 <= x < 4, `(2 .. 4]' represents 2 < x <= 4, and `(2 .. 4)' represents 2 < x < 4.
The lower and upper limits of an interval must be either real numbers (or HMS or date forms), or symbolic expressions which are assumed to be real-valued, or `-inf' and `inf'. In general the lower limit must be less than the upper limit. A closed interval containing only one value, `[3 .. 3]', is converted to a plain number (3) automatically. An interval containing no values at all (such as `[3 .. 2]' or `[2 .. 2)') can be represented but is not guaranteed to behave well when used in arithmetic. Note that the interval `[3 .. inf)' represents all real numbers greater than or equal to 3, and `(-inf .. inf)' represents all real numbers. In fact, `[-inf .. inf]' represents all real numbers including the real infinities.
Intervals are entered in the notation shown here, either as algebraic formulas, or using incomplete forms. (See section 5.13 Incomplete Objects.) In algebraic formulas, multiple periods in a row are collected from left to right, so that `1...1e2' is interpreted as `1.0 .. 1e2' rather than `1 .. 0.1e2'. Add spaces or zeros if you want to get the other interpretation. If you omit the lower or upper limit, a default of `-inf' or `inf' (respectively) is furnished.
"Infinite mode" also affects operations on intervals (see section 5.5 Infinities). Calc will always introduce an open infinity, as in `1 / (0 .. 2] = [0.5 .. inf)'. But closed infinities, `1 / [0 .. 2] = [0.5 .. inf]', arise only in infinite mode; otherwise they are left unevaluated. Note that the "direction" of a zero is not an issue in this case since the zero is always assumed to be continuous with the rest of the interval. For intervals that contain zero inside them Calc is forced to give the result, `1 / (-2 .. 2) = [-inf .. inf]'.
While it may seem that intervals and error forms are similar, they are based on entirely different concepts of inexact quantities. An error form `x +/- sigma' means a variable is random, and its value could be anything but is "probably" within one sigma of the mean value x. An interval `[a .. b]' means a variable's value is unknown, but guaranteed to lie in the specified range. Error forms are statistical or "average case" approximations; interval arithmetic tends to produce "worst case" bounds on an answer.
Intervals may not contain complex numbers, but they may contain HMS forms or date forms.
See section 10.6 Set Operations using Vectors, for commands that interpret interval forms as subsets of the set of real numbers.
The algebraic function `intv(n, a, b)' builds an interval form from `a' to `b'; `n' is an integer code which must be 0 for `(..)', 1 for `(..]', 2 for `[..)', or 3 for `[..]'.
Please note that in fully rigorous interval arithmetic, care would be taken to make sure that the computation of the lower bound rounds toward minus infinity, while upper bound computations round toward plus infinity. Calc's arithmetic always uses a round-to-nearest mode, which means that roundoff errors could creep into an interval calculation to produce intervals slightly smaller than they ought to be. For example, entering `[1..2]' and pressing Q 2 ^ should yield the interval `[1..2]' again, but in fact it yields the (slightly too small) interval `[1..1.9999999]' due to roundoff error.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
webmaster | delorie software privacy |
Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |