\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}1 \cdot \frac{-\left|x\right|}{x} + 1double code(double x) {
return ((x / x) - ((1.0 / x) * sqrt((x * x))));
}
double code(double x) {
return ((1.0 * (-fabs(x) / x)) + 1.0);
}




Bits error versus x
Results
| Original | 31.9 |
|---|---|
| Target | 0 |
| Herbie | 0 |
Initial program 31.9
Simplified30.6
rmApplied fma-udef4.7
rmApplied div-inv4.7
Applied distribute-rgt-neg-in4.7
Applied associate-*l*4.7
Simplified0
Final simplification0
herbie shell --seed 2020049 +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)))))