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.


In reply to Re^2: Interval Computation Module Design by HollyKing
in thread Interval Computation Module Design by HollyKing

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.