Let HERBIE Make Your Floating Point Better
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.

herbielogo

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:

 

herbie1

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. 

herbielogo

More Information

HERBIE

Related Articles

GNU Octave 4

NAG Library Extended

CheckCell Detects Bugs In Spreadsheets

MathJS A Math Library For JavaScript

Free Sage Math Cloud - Python And Symbolic Math

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin

 

Banner


Intel Divests Itself of Wearables
21/07/2017

According to a report that originated with CNBC and has been widely circulated, Intel completely eliminated the group concerned with wearables earlier this month.



Can You Craft A HTML5 Game In 13Kb?
13/08/2017

The 2017 edition of a long running contest kicks off today. The challenge is to write a HTML5 game in JavaScript whose code and assets can be zipped into a package with a 13Kb limit.


More News

 

 
 

 

blog comments powered by Disqus

 

 

 

Last Updated ( Tuesday, 26 January 2016 )
 
 

   
Banner
Banner
RSS feed of news items only
I Programmer News
Copyright © 2017 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.