Interval Arithmetic - x-squared and other functions - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: Not HP Calculators (/forum-7.html) +--- Forum: Not quite HP Calculators - but related (/forum-8.html) +--- Thread: Interval Arithmetic - x-squared and other functions (/thread-18920.html) |
Interval Arithmetic - x-squared and other functions - johnb - 10-03-2022 12:13 AM Sorry, this is an Introduction, so it's somewhat long! The question is about 2/3 of the way down... Off and on for the past few years, I have been writing an HP-48G/GX library and mode of operation that supports so-called Interval Arithmetic. For those who have not encountered this before, in Interval Arithmetic a scalar is a well-bounded continual range of values. This has uses in both scientific measurement and in computing (reliable numerics, which can tell you when a computation looks like it's returning a valid result but the values have degraded to garbage due to numerical instabilities). The basic idea is not so difficult to understand. When you measure a 12 ft by 14 floor (perhaps to know how much 1" x 1" tile to buy), you might really only know the measurements to the nearest half inch. The dimensions you really have are [143.5, 144.5] inches by [167.5, 168.5] inches. Multiplication is pretty simple in this case: the result is [24036.25, 24348.25] inches. My library also carries the "best guess" value through the computation, so that each scalar interval is treated as a triple, which I'll annotate here in the format "best_value:[bottom, top]". This is better than the conventional way of tracking error terms because it doesn't assume the error is evenly distributed above and below the estimated value. The product above would be written 24192:[24036.25, 24348.25] inches. This shows that the "best" estimated value isn't smack in the middle of the range. Other operations and functions are trickier. I've recently picked up my old library and starting going through it and second-guessing some of the decisions I've previously made. QUESTION Suppose you have an interval value x = 2:[-1.5,5]. What, then, is x squared? I can think of two options; you might think of others. I don't think you should just treat the value as a vector {2, -1.5, 5} and square each element. It's a continuous range on the number line, not a vector of discrete values (though we do call out one particular value in the midst of that range). Let's take just the range part [-1.5,5], to start. Is the square of the range [ min( (-1.5)^2, 5^2 ), max( (-1.5)^2, 5^2 ) ] = [ min(2.25, 25), max(2.25, 25) ] = [2.25, 25] Or is it [ min( -1.5*-1.5, -1.5*5, 5*-1.5, 5*5), max( -1.5*-1.5, -1.5*5, 5*-1.5, 5*5) ] = [ min(2.25, -7.5, -7.5, 25), max(2.25, -7.5, -7.5, 25) ] = [-7.5, 25] Or is it something else? Note that I wrote all 4 permutations in the second example because I want to generalize this to other operators, not just multiplication / powers. Now you can see how quickly this starts getting complicated! BTW, I would >LOVE< it if the new WP-43 project included an interval arithmetic mode! Preferably a better one than the one I've been writing. RE: Interval Arithmetic - x-squared and other functions - Paul Dale - 10-03-2022 01:00 AM I'd square [-1.5,5] to [0, 25]. RE: Interval Arithmetic - x-squared and other functions - johnb - 10-03-2022 03:53 AM (10-03-2022 01:00 AM)Paul Dale Wrote: I'd square [-1.5,5] to [0, 25]. I assume you mean to clamp the lower end at zero for squaring any interval that spans the origin? What's your reasoning? And, does it generalize to anything beyond Sqr(x)? RE: Interval Arithmetic - x-squared and other functions - Gjermund Skailand - 10-03-2022 07:12 AM Keep in mind there is a difference between squaring an interval number, and how it would be different from multiplying two interval numbers that just happends to be similar. There are a few examples of interval arithmetic on the longfloat library at https://www.hpcalc.org/hp49/math/numeric/lf393.zip br Gjermund RE: Interval Arithmetic - x-squared and other functions - johnb - 10-03-2022 09:09 PM (10-03-2022 07:12 AM)Gjermund Skailand Wrote: Keep in mind there is a difference between squaring an interval number, and how it would be different from multiplying two interval numbers that just happends to be similar. Yes, I had suspected as much. Intervals don't obey all of the rules that integers and reals do. For fun, I've tried to work out most of the principles of interval arithmetic for myself. There aren't many areas of modern mathematics where the topics are current, but where anyone other than a professional mathematician could get anywhere doing that. But now, I think I just want to finish my program library and have it be correct. I anticipate that looking at the HP-49 library you mentioned will help a lot. Some of it might even be easily ported to the HP-48 series. |