\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \leq -3.11516202745543 \cdot 10^{-310}:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}(FPCore (x) :precision binary64 (- (/ x x) (* (/ 1.0 x) (sqrt (* x x)))))
(FPCore (x) :precision binary64 (if (<= x -3.11516202745543e-310) 2.0 0.0))
double code(double x) {
return (x / x) - ((1.0 / x) * sqrt(x * x));
}
double code(double x) {
double tmp;
if (x <= -3.11516202745543e-310) {
tmp = 2.0;
} else {
tmp = 0.0;
}
return tmp;
}






Bits error versus x
Results
| Original | 32.4 |
|---|---|
| Target | 0 |
| Herbie | 0 |
| Alternative 1 | |
|---|---|
| Error | 0 |
| Cost | 6720 |
| Alternative 2 | |
|---|---|
| Error | 30.2 |
| Cost | 64 |


if x < -3.115162027455434e-310Initial program 28.3
Taylor expanded around -inf 0
Simplified0
if -3.115162027455434e-310 < x Initial program 36.7
Taylor expanded around 0 0
Simplified0
Final simplification0
herbie shell --seed 2021040
(FPCore (x)
:name "sqrt sqr"
:precision binary64
:herbie-target
(if (< x 0.0) 2.0 0.0)
(- (/ x x) (* (/ 1.0 x) (sqrt (* x x)))))