Herbie: Automatically improve imprecise floating point formulas

https://news.ycombinator.com/rss Hits: 2
Summary

Herbie Tutorial Herbie rewrites floating point expressions to make them more accurate. Floating point arithmetic is inaccurate; even 0.1 + 0.2 ≠ 0.3 in floating-point. Herbie helps find and fix these mysterious inaccuracies. To get started, download and install Herbie. You're then ready to begin using it. Giving Herbie expressions Start Herbie with: racket -l herbie web Alternatively, if you added herbie to the path, you can always replace racket -l herbie with just herbie. After a brief wait, your web browser should open and show you Herbie's main window. The most important part of the page is this bit: Let's start by just looking at an example of Herbie running. Click "Show an example". This will pre-fill the expression sqrt(x + 1) - sqrt(x) with x ranging from to 0 and 1.79e308. Now that you have an expression and a range for each variable, click the "Improve with Herbie" button. You should see the entry box gray out, and shortly thereafter some text should appear describing what Herbie is doing. After a few seconds, you'll be redirected to a page with Herbie's results. The very top of this results page gives some quick statistics about the alternative ways Herbie found for evaluating this expression: Here, you can see that Herbie's most accurate alternative has an accuracy of 99.7%, much better than the initial program's 53.2%, and that in total Herbie found 5 alternatives. One of those alternatives is both more accurate than the original expression and also 1.9× faster. The rest of the result page shows each of these alternatives, including details like how they were derived. These details are all documented, but for the sake of the tutorial let's move on to a more realistic example. Programming with Herbie You can use Herbie on expressions from source code, mathematical models, or debugging tools. But most users use Herbie as they write code, asking it about any complex floating-point expression they write. Herbie has options to log all the expressions you ent...

First seen: 2026-04-04 01:18

Last seen: 2026-04-04 02:18