Command-line Options

The Herbie command takes several options that influence its search procedure and the types of solutions it finds. These options apply both to the report generator and the one-off command-line tool.

General Options

These options can be set on both the report generator and the one-off tool, and influence the coarse properties of Herbie's search.
--seed
This sets the random seed, which changes the randomly-selected points that Herbie evaluates candidate expressions on. The format of the seed is that used by the Racket vector->pseudo-random-generator! function; in practice, just use a seed produced by an earlier run. This option can be used to make Herbie's results reproducible or to compare two different runs.
--num-iters
The number of improvements Herbie attempts to make to the program. The default, 2, suffices for most programs and helps keep Herbie fast. If this is set very high, Herbie may run out of things to do and terminate before the given number of iterations, but in practice iterations beyond the first few rarely lead to lower error. This option can be increased to 3 or 4 to check that there aren't further improvements that Herbie could seek out.
--num-points
The number of randomly-selected points used to evaluate candidate expressions. The default, 256, gives good behavior for most programs. The more points sampled, the slower Herbie is. This option can be increased to 512 or 1024 if Herbie gives very inconsistent results between runs with different seeds.
--timeout
The timeout to use per-example, in seconds. A fractional number of seconds can be given.

Search Options

These options influence the fine properties of Herbie's search, most importantly the types of transformations that Herbie uses to find candidate programs. These options offer very fine-grained control over Herbie's output, and are only recommended for advanced uses of Herbie. Each option can be toggled with the -o or --option command-line flags. The recommended set of options is the default set; turning a default-on option off typically results in less-accurate results, while turning a default-off option on typically results in more-complex and more-surprising output expressions.
precision:double
This option, on by default, runs Herbie in double-precision mode. If turned off, Herbie runs in single-precision mode.
setup:simplify
This option, on by default, simplifies the expression before passing it to Herbie. If turned off, Herbie will not simplify input programs before improving them. You will want to turn off this option if simplifying the program will create a lot of error, say if the association of operations is cleverly chosen.
setup:early-exit
This option, off by default, causes Herbie to exit without modifying the input program if it determines that the input program has less than 0.1 bits of error. You will want to turn this option on if you are running Herbie on a large corpus of programs that you do not believe to be inaccurate.
generate:rr
This option, on by default, uses Herbie's recursive rewriting algorithm to generate candidate programs. If turned off, Herbie will use a non-recursive rewriting algorithm, which will substantially limit the candidates Herbie finds. You will rarely want to turn this option off.
generate:taylor
This option, on by default, uses series expansion to produce new candidates during the main improvement loop. If turned off, Herbie will not use series expansion in the main improvement loop. You will want to turn this option off if you want to avoid series-expansion-based rewrites, such as if you need to preserve the equivalence of the input and output expressions as real-number formulas.
generate:simplify
This option, on by default, simplifies candidates during the main improvement loop. If turned off, candidates will not be simplified, which typically results in much less accurate expressions, since simplification is often necessary for cancelling terms. You will rarely want to turn this option off.
reduce:regimes
This option, on by default, uses Herbie's regime inference algorithm to branch between several program candidates. If turned off, brances will be inferred and the output program will be straight-line code (if the input was). You will want to turn this option off if your programming environment makes branches too expensive, such as in some cases of GPU programming.
reduce:taylor
This option, on by default, uses a final set of series expansions after all improvements have been made. This sometimes improves accuracy further. If turned off, this final series expansion pass will not be done. You will want to turn this option off if you want to avoid series-expansion-based rewrites, such as if you need to preserve the equivalence of the input and output expressions as real-number formulas.
reduce:simplify
This option, on by default, uses a final simplification pass after all improvements have been made. This sometimes improves accuracy further. If turned off, this final simplification pass will not be done. You will rarely want to turn this option off.
reduce:avg-error
This option, on by default, causes Herbie to output the candidate with the best average error over the chosen inputs. If turned off, Herbie will choose the candidate with the least maximum error instead. This usually produces programs with worse overall accuracy. You may want to turn this option off if worst-case accuracy is more important to you than overall accuracy.
rules:arithmetic
This option, on by default, allows Herbie to use basic arithmetic facts during its search. If turned off, Herbie will not be able to use those facts. You will rarely want to turn this option off.
rules:polynomials
This option, on by default, allows Herbie to use facts about polynomials during its search. If turned off, Herbie will not be able to use those facts. You will rarely want to turn this option off.
rules:fractions
This option, on by default, allows Herbie to use facts about fractions during its search. If turned off, Herbie will not be able to use those facts. You will rarely want to turn this option off.
rules:exponents
This option, on by default, allows Herbie to use facts about exponents during its search. If turned off, Herbie will not be able to use those facts. You rarely want to turn this option off if you do not want to use exponents or logarithms in the output expressions, which might be the case when code runtime is more important than accuracy.
rules:trigonometry
This option, on by default, allows Herbie to use basic trigonometry facts during its search. If turned off, Herbie will not be able to use those facts. Herbie's trigonometry knowledge is extremely basic. You will rarely want to turn this option off.
rules:numerics
This option, off by default, allows Herbie to use special numerical functions. If turned off, Herbie will not be able to use these functions. You will want to turn this option on if these functions (currently expm1, log1p, and hypot) are available in your language.