Herbie can be used from the command-line or from the browser. This page covers using Herbie from the command line.
The Herbie shell lets you interact with Herbie: you type in input expressions and Herbie prints their more accurate versions. Run the Herbie shell with this command:
racket -l herbie shell Starting Herbie 2.2 with seed 2098242187 Find help on https://herbie.uwplse.org/, exit with Ctrl-D herbie>
Herbie prints a seed, which you can use to reproduce a Herbie run, and links you to documentation. Then, it waits for inputs, which you can type directly into your terminal in FPCore format:
herbie> (FPCore (x) (- (+ 1 x) x)) (FPCore (x) ... 1.0)
Herbie suggests that 1.0
is more accurate than the
original expression (- (+ 1 x) x)
. The
the ... elides
additional information provided
by Herbie.
The Herbie shell only shows Herbie's most accurate variant.
Alternatively, you can run Herbie on a file with multiple expressions in it, writing Herbie's versions of each to a file. This mode is intended for use by scripts.
racket -l herbie improve bench/tutorial.fpcore out.fpcore Starting Herbie 2.2 with seed 1139794558... Warning: 75.2% of points produce a very large (infinite) output. You may want to add a precondition. See <https://herbie.uwplse.org/doc/2.0/faq.html#inf-points> for more.
The output file out.fpcore
contains more accurate
versions of each program:
;; seed: 1139794558 (FPCore (x) :name "Cancel like terms" ... 1.0) (FPCore (x) :name "Expanding a square" ... (fma x x (+ x x))) (FPCore (x y z) :name "Commute and associate" ... 0.0)
Note that output file is in the same order as the input file. For more control over Herbie, see the documentation of Herbie's command-line options.