\frac{x0}{1 - x1} - x0\begin{array}{l}
\mathbf{if}\;1 - x1 \leq 0.9814:\\
\;\;\;\;\frac{1}{\frac{1 - x1}{x0}} - x0\\
\mathbf{else}:\\
\;\;\;\;\left(x1 + x1 \cdot x1\right) \cdot \left(x0 + x0 \cdot \left(x1 \cdot x1\right)\right)\\
\end{array}(FPCore (x0 x1) :precision binary64 (- (/ x0 (- 1.0 x1)) x0))
(FPCore (x0 x1) :precision binary64 (if (<= (- 1.0 x1) 0.9814) (- (/ 1.0 (/ (- 1.0 x1) x0)) x0) (* (+ x1 (* x1 x1)) (+ x0 (* x0 (* x1 x1))))))
double code(double x0, double x1) {
return (x0 / (1.0 - x1)) - x0;
}
double code(double x0, double x1) {
double tmp;
if ((1.0 - x1) <= 0.9814) {
tmp = (1.0 / ((1.0 - x1) / x0)) - x0;
} else {
tmp = (x1 + (x1 * x1)) * (x0 + (x0 * (x1 * x1)));
}
return tmp;
}







Bits error versus x0







Bits error versus x1
Results
| Original | 8.4 |
|---|---|
| Target | 0.5 |
| Herbie | 4.1 |
| Alternative 1 | |
|---|---|
| Error | 7.6 |
| Cost | 576 |
| Alternative 2 | |
|---|---|
| Error | 8.4 |
| Cost | 448 |
| Alternative 3 | |
|---|---|
| Error | 54.8 |
| Cost | 64 |

if (-.f64 1 x1) < 0.98140000000000005Initial program 5.5
rmApplied clear-num_binary64_45104.4
Simplified4.4
if 0.98140000000000005 < (-.f64 1 x1) Initial program 11.3
Taylor expanded around 0 3.9
Simplified3.9
Simplified3.9
Final simplification4.1
herbie shell --seed 2021044
(FPCore (x0 x1)
:name "(- (/ x0 (- 1 x1)) x0)"
:precision binary64
:pre (or (and (== x0 1.855) (== x1 0.000209)) (and (== x0 2.985) (== x1 0.0186)))
:herbie-target
(/ (* x0 x1) (- 1.0 x1))
(- (/ x0 (- 1.0 x1)) x0))