Let HERBIE Make Your Floating Point Better

### New Book Reviews!

 Let HERBIE Make Your Floating Point Better
Written by Mike James
Tuesday, 26 January 2016

A new tool from the University of Washington will take your floating point expressions and convert them into something that does the same calculation, but more accurately. This is worth knowing about.

Floating point arithmetic is at the heart of a lot of computation, and especially in science and engineering. Most of the time, floating point does a good job, but because of the way that it works it usually entails some inaccuracy due to rounding errors.

For example, if you try to add a very small number to a very large number then it is possible that the small number will be rounded to zero and your calculation becomes a+0 not a+something small. This sort of problem can even make algorithms fail. For example, if you add small values to a large value in a loop which stops when the large value is greater than a set limit then the loop might never end if rounding errors reduce the small values to effectively zero.

However, if you arrange to add all the small values together and then add the bigger value that results to the bigger value you get a much smaller total error. With floating point arithmetic you can often improve the accuracy by altering the way the expression is written.

If you are a programmer who occasionally works with floating point values that are problematic then you, at best, learn a few simple rules to protect yourself from this sort of thing. For example, don't ever test for equality of values, only use greater than and less than. Don't add small things to big things and so on. The problem is for any particular floating point expression, you can't be sure that your home spun rules are going to be good enough.

Now you can ask HERBIE to try to find an alternative expression that reduces the rounding error. You provide the expression and HERBIE then uses a range of heuristic search techniques to find rewrites that reduce the error. It tests the expression with a range of floating point values and empirically determines the error. It can find rewrites that have good effects in different numerical ranges and combines these to produce a single result that works well.

To demonstrate how good HERBIE is, the developers applied it to 28 test cases from Richard Hamming's Numerical Methods for Scientists and Engineers with impressive improvements:

Longer arrows are better. Each arrow measures an improvement in accuracy due to Herbie. Each arrow points from the accuracy of the original program, and to the accuracy of Herbie’s output, in each case on random double-precision inputs.

If you just want to try it out there is a web demo, but this has many drawbacks compared to the full program which you can download and install.

HERBIE

#### Related Articles

GNU Octave 4

NAG Library Extended

MathJS A Math Library For JavaScript

Free Sage Math Cloud - Python And Symbolic Math

 Firefox Share Below 10 Percent06/06/2018Despite any confidence we expressed about Firefox Quantum's ability to regain popularity as a desktop browser, its market share has continued to decline and has dipped below 10% for the first tim [ ... ] + Full Story NativeScript Adds LiveSync with Webpack01/06/2018The new release of NativeScript has the ability to enable LiveSync with Webpack simultaneously. Other improvements in  NativeScript 4.1 include more flexible frame composition and an enterprise a [ ... ] + Full Story More News