Herbie synthesizes floating-point programs from real-number programs, automatically handling simple numerical instabilities.
Herbie can improve the accuracy of many real-world programs, and is used by scientists in many disciplines. It has lead to two patches (for complex square roots and trigonometric functions), in math.js an open-source mathematics library.
Email Zach Tatlock to get involved. He’ll set you up with access to these tools.
Herbie requires Racket 6.3 or later, and works best on Linux.
No installation is needed; just download the source code and you're ready to go.
Herbie 1.0 differs from previous versions by having a new input format. Herbie now uses the FPCore standard for floating point tools. To convert existing files to the new format, use:
racket infra/convert.rkt [file].rkt > [file].fpcore
For details on how to run Herbie, please see the tutorial.
The format of input files is a Scheme-based language;
you can find several examples in
For example, consider this simple cancellation test
(FPCore (x) (- (+ 1 x) x))
Run Herbie from the top-level directory of the repo:
$ racket src/herbie.rkt Seed: #(1046809171 2544984934 1871826185 4237421819 4093186437 162666889)
You can now enter the cancellation test:
$ racket src/herbie.rkt Seed: #(1046809171 2544984934 1871826185 4237421819 4093186437 162666889) (FPCore (x) (- (+ 1 x) x)) [ 1673.401ms] (29→ 0) Cancel like terms (λ (x) 1)
The final is Herbie's improved, more-accurate expression, in this case
You can also save expressions to a file and run them with
racket src/herbie.rkt [file]
Herbie draws its test suite from open source projects, examples emailed to the developers, and from numerical analysis textbooks. Whenever possible, we try to extract all possible tests from a source, to avoid biasing our selection of tests. To run the tests, go to the project root and run
racket infra/travis.rkt [file]
Herbie's main tests are integration tests that test Herbie end-to-end.
They are the benchmarks that ship in the
We often test Herbie on basic but representative examples with:
racket infra/travis.rkt bench/hamming/
This takes approximately 15 minutes. To run all of the default benchmarks, use:
racket infra/travis.rkt bench/
This can take a few hours or more.
Test results are collected on uwplse.org. If you have an account on this server, you can publish your test report with