Using Herbie from the Command Line

Herbie can be used from the command-line or from the browser. This page covers using Herbie from the command line.

The Herbie shell

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:

herbie shell
Herbie 1.4 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 is more accurate than the original expression (- (+ 1 x) x). The the ... elides additional information provided by Herbie.

The Herbie shell makes it easy to play with different expressions and try multiple variants, informed by Herbie's advice.

Batch processing FPCores

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.

herbie improve bench/tutorial.fpcore out.fpcore
Starting Herbie on 3 problems (seed: 1809676410)...
  1/3	[   0.769s]   29→ 0	Cancel like terms
  2/3	[   1.392s]   39→ 0	Expanding a square
  3/3	[   2.522s]    0→ 0	Commute and associate

The output file out.fpcore contains more accurate versions of each program:

;; seed: 1809676410

(FPCore (x) ... 1.0)
(FPCore (x) ... (* x (+ x 2.0)))
(FPCore (x y z) ... 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.