in reply to Re: Interval Computation Module Design
in thread Interval Computation Module Design

Number::Interval and Set::Window seem to be concerned with intervals on a number line. Neither module has defined the basic arithmetic operators (+, -, · and ÷) or mathematical functions. I need these along with comparison functions to test the 18 (eep!) relations between two intervals.

For my application an interval represents a value with a known amount of error. The interval [4, 6] means that the real answer is somewhere between 4 and 6, but we don't know exactly where. Because floating point calculations aren't exact, the results of interval calculations are rounded out by rounding the lower bound down and the upper bound up to the next representable numbers. The end result gives you a lower and upper bound that contain the real answer.

The basic operators for intervals are defined as:

x op y = [ min{ lower(x) op lower(y), lower(x) op upper(y), upper(x) op lower(y), upper(x) op upper(y) }, max{ lower(x) op lower(y), lower(x) op upper(y), upper(x) op lower(y), upper(x) op upper(y) } ]
With a few proofs we can eliminate some of the operations. So, to add two intervals you would add the lower bounds together and the upper bounds together. For example, x + y = [lower(x) + lower(y), upper(x) + upper(y)]. So your example of add([1, 4], [9, 12]) would return [10, 16], which does contain 10.

Thank you for your reply.

Owl looked at him, and wondered whether to push him off the tree; but, feeling that he could always do it afterwards, he tried once more to find out what they were talking about.

Replies are listed 'Best First'.
Re^3: Interval Computation Module Design
by rhesa (Vicar) on Feb 21, 2006 at 02:11 UTC
    Thanks for making the difference with more conventional ideas about intervals clearer. I based my answer on the naive interpretation of the notion, and you're right, that's not what you're dealing with.

    Now that I realise that Interval Computation is a whole field of mathematics, I'm more inclined to suggest that your module name should somehow express that. Since interval and computation are both generic and already have broad CS usage, I'd lean toward something like Interval::Analysis. Maybe put it in the Math namespace as well, although Math::Interval::Analysis is pretty long. It does seem like The right thing to do though...