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




Bits error versus x
Results
| Original | 32.3 |
|---|---|
| Target | 0 |
| Herbie | 0.0 |
Initial program 32.3
rmApplied add-cube-cbrt32.3
Applied prod-diff45.5
Simplified31.6
Simplified0.0
Final simplification0.0
herbie shell --seed 2020066 +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)))))