3

(edited)
Is there any library or tool that allows for knowing the maximum accumulated error in arithmetic operations?

For example if I make some iterative calculation ...

myVars = initialValues;
while (notEnded) {
    myVars = updateMyVars(myVars)
}

... I want to know at the end not only the calculated values, but also the potential error (the range of posible values if results in each individual operations took the range limits for each operand).

I have already written a Java class called EADouble.java (EA for Error Accounting) which holds and updates the maximum positive and negative errors along with the calculated value, for some basic operations, but I'm afraid I might be reinventing an square wheel.

Any libraries/whatever in Java/whatever? Any suggestions?


  • Updated on July 11th: Examined existing libraries and added link to sample code.
  • As commented by fellows, there is the concept of Interval Arithmetic, and there was a previous question ( A good uncertainty (interval) arithmetic library? ) on the topic. There just a couple of small issues about my intent:
    • I care more about the "main" value than about the upper and lower bounds. However, to add that extra value to an open library should be straight-forward.
    • Accounting the error as an independent floating point might allow for a finer accuracy (e.g. for addition the upper bound would be incremented just half ULP instead of a whole ULP).
  • Libraries I had a look at:
    • ia_math (Java. Just would have to add the main value. My favourite so far)
    • Boost/numeric/Interval (C++, Very complex/complete)
    • ErrorProp (Java, accounts value, and error as standard deviation)
  • The sample code (TestEADouble.java) runs ok a ballistic simulation and a calculation of number e. However those are not very demanding scenarios.
Community
  • 1
  • 1
Javier
  • 678
  • 5
  • 17
  • This is why we use fixed-point types instead. – Ignacio Vazquez-Abrams Jul 09 '12 at 21:08
  • 5
    You may want to try [interval arithmetic](http://en.wikipedia.org/wiki/Interval_arithmetic). – lhf Jul 10 '12 at 00:23
  • 3
    Be aware that "worst case" error can be much greater than "average/expected" error, for large-scale floating point operations such as linear algebra or numerical simulation. A worst case interval analysis should work, but it may end up being unnecessarily conservative. – comingstorm Jul 10 '12 at 00:30
  • 1
    @IgnacioVazquez-Abrams I'm not sure this is 'the usual' problem - the use of the word "accounting" threw me, but I think asker isn't necessarily talking about financial stuff. – AakashM Jul 10 '12 at 07:48
  • @lhf good suggestion. I didn't know about **Interval arithmetic**. I will look it up, but so far there are some details I'm not sure about. I'm working on it. – Javier Jul 10 '12 at 08:38
  • @comingstorm You are right: An over-conservative error accounting might disregard all the precision too easily... But maybe I want to know how bad is that very-very-infrequent worst case. – Javier Jul 10 '12 at 09:00
  • @AakashM Good point. I changed the title to avoid the misleading "accounting" word. – Javier Jul 10 '12 at 09:05
  • 2
    Possible duplicate of http://stackoverflow.com/questions/623660/a-good-uncertainty-interval-arithmetic-library. – lhf Jul 10 '12 at 11:24

1 Answers1

1

probably way too late, but look at BIAS/Profil: http://www.ti3.tuhh.de/keil/profil/index_e.html Pretty complete, simple, account for computer error, and if your errors are centered easy access to your nominal (through Mid(...)).

luneart
  • 182
  • 1
  • 8
  • Thanks for suggestion, and sorry for delay. As stated on the 2012-07-11 edition, interval math was a good approach, but not what I was looking for: By itself does not track the worst case scenario arithmetic error on each operation. On the other hand, if it was a interval math library what i was looking for, then the question itself would had been obliterated. – Javier Aug 03 '15 at 14:23