1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
\mathbf{if}\;\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{1 + y}\\
t_0 \leq 5.6689047161900774 \cdot 10^{-14} \lor \neg \left(t_0 \leq 1.0000000000000002\right)
\end{array}:\\
\;\;\;\;\begin{array}{l}
t_1 := \frac{y}{1 + y}\\
\left(1 - t_1\right) + x \cdot t_1
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\left(x + \left(\frac{x}{{y}^{2}} + \frac{1}{y}\right)\right) - \left(\frac{x}{y} + \frac{1}{{y}^{2}}\right)\\
\end{array}
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
(FPCore (x y)
:precision binary64
(if (let* ((t_0 (/ (* (- 1.0 x) y) (+ 1.0 y))))
(or (<= t_0 5.6689047161900774e-14) (not (<= t_0 1.0000000000000002))))
(let* ((t_1 (/ y (+ 1.0 y)))) (+ (- 1.0 t_1) (* x t_1)))
(- (+ x (+ (/ x (pow y 2.0)) (/ 1.0 y))) (+ (/ x y) (/ 1.0 (pow y 2.0))))))double code(double x, double y) {
return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
double code(double x, double y) {
double t_0 = ((1.0 - x) * y) / (1.0 + y);
double tmp;
if ((t_0 <= 5.6689047161900774e-14) || !(t_0 <= 1.0000000000000002)) {
double t_1_1 = y / (1.0 + y);
tmp = (1.0 - t_1_1) + (x * t_1_1);
} else {
tmp = (x + ((x / pow(y, 2.0)) + (1.0 / y))) - ((x / y) + (1.0 / pow(y, 2.0)));
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 22.0 |
|---|---|
| Target | 0.2 |
| Herbie | 0.7 |
if (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 5.6689047161900774e-14 or 1.00000000000000022 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) Initial program 10.5
Taylor expanded around 0 10.5
Simplified0.4
rmApplied sub-neg_binary640.4
Applied distribute-lft-in_binary640.4
Applied associate--r+_binary640.2
Simplified0.2
if 5.6689047161900774e-14 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 1.00000000000000022Initial program 57.5
Taylor expanded around inf 2.3
Final simplification0.7
herbie shell --seed 2021190
(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))))