Frequently Asked Questions

Herbie automatically transforms floating point expressions into more accurate forms. This page catalogs questions frequently asked questions about Herbie.

Troubleshooting common errors

Several Herbie error messages refer to this page for additional information and debugging tips.

“Invalid program” error

This error is most likely due to an error in preparing the input to Herbie. Common errors include misspelling function names and parenthesizing expressions that must not be parenthesized. The stack trace will contain additional information. For example, in the expression (- (exp (x)) 1), the use of x as invalid because x is a variable, so cannot be parenthesized. (- (exp x) 1) would be the correct way of describing that expression.

“Cannot sample enough valid points” error

Herbie uses random sampling to select the points which it will use to evaluate the error of an expression. This error occurs when it is not able to find enough valid points. For example, consider the expression (acos (+ 1000 x)). This expression yields a valid result only when x is between -1001 and -999, a rather narrow range.

The solution is to give a distribution which specifies the bounds on x by adding the line :herbie-samplers ([x (uniform -1001 -999)]) after the parameter list.