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 syntax” error

This error means you mis-formatted Herbie's input. Common errors include misspelling function names and parenthesizing expressions that must not be parenthesized. For example, in (- (exp (x)) 1), (x) is incorrect: x is a variable so isn't parenthesized. (- (exp x) 1) would be the correct way of writing that expression. The error message will contain additional information.

“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.