\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\log \left(e^{\mathsf{fma}\left(-\frac{1}{x}, \left|x\right|, 1\right)}\right)double code(double x) {
return ((x / x) - ((1.0 / x) * sqrt((x * x))));
}
double code(double x) {
return log(exp(fma(-(1.0 / x), fabs(x), 1.0)));
}




Bits error versus x
Results
| Original | 32.3 |
|---|---|
| Target | 0 |
| Herbie | 4.4 |
Initial program 32.3
Simplified30.6
rmApplied add-log-exp4.4
Final simplification4.4
herbie shell --seed 2020105 +o rules:numerics
(FPCore (x)
:name "sqrt sqr"
:precision binary64
:herbie-target
(if (< x 0.0) 2 0.0)
(- (/ x x) (* (/ 1 x) (sqrt (* x x)))))