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




Bits error versus x
Results
| Original | 32.4 |
|---|---|
| Target | 0 |
| Herbie | 0.0 |
Initial program 32.4
rmApplied associate-*l/30.1
Applied sub-div30.1
Simplified0.0
Final simplification0.0
herbie shell --seed 2020102 +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)))))