1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\begin{array}{l}
\mathbf{if}\;\frac{\left(1 - x\right) \cdot y}{1 + y} \leq 0.999425018399054:\\
\;\;\;\;1 - \left(1 - x\right) \cdot \frac{y}{1 + y}\\
\mathbf{elif}\;\frac{\left(1 - x\right) \cdot y}{1 + y} \leq 1.0000201864133105:\\
\;\;\;\;\left(\frac{x}{{y}^{2}} + \left(\frac{1}{{y}^{3}} + \left(x + \frac{1}{y}\right)\right)\right) - \left(\frac{x}{{y}^{3}} + \left(\frac{1}{{y}^{2}} + \frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{1 + y}\\
\end{array}(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
(FPCore (x y)
:precision binary64
(if (<= (/ (* (- 1.0 x) y) (+ 1.0 y)) 0.999425018399054)
(- 1.0 (* (- 1.0 x) (/ y (+ 1.0 y))))
(if (<= (/ (* (- 1.0 x) y) (+ 1.0 y)) 1.0000201864133105)
(-
(+ (/ x (pow y 2.0)) (+ (/ 1.0 (pow y 3.0)) (+ x (/ 1.0 y))))
(+ (/ x (pow y 3.0)) (+ (/ 1.0 (pow y 2.0)) (/ x y))))
(* x (/ y (+ 1.0 y))))))double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
double code(double x, double y) {
double tmp;
if ((((1.0 - x) * y) / (1.0 + y)) <= 0.999425018399054) {
tmp = 1.0 - ((1.0 - x) * (y / (1.0 + y)));
} else if ((((1.0 - x) * y) / (1.0 + y)) <= 1.0000201864133105) {
tmp = ((x / pow(y, 2.0)) + ((1.0 / pow(y, 3.0)) + (x + (1.0 / y)))) - ((x / pow(y, 3.0)) + ((1.0 / pow(y, 2.0)) + (x / y)));
} else {
tmp = x * (y / (1.0 + y));
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 22.4 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 0.999425018399053955Initial program 7.6
Taylor expanded around 0 7.6
Simplified0.0
if 0.999425018399053955 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 1.00002018641331047Initial program 58.6
Taylor expanded around inf 0.1
if 1.00002018641331047 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) Initial program 21.5
rmApplied flip--_binary6431.8
Simplified31.9
Simplified31.9
Taylor expanded around inf 22.8
Simplified1.4
Final simplification0.3
herbie shell --seed 2021118
(FPCore (x y)
:name "Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D"
:precision binary64
:herbie-target
(if (< y -3693.8482788297247) (- (/ 1.0 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) (- (/ 1.0 y) (- (/ x y) x))))
(- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))