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 1.3651577721425698 \cdot 10^{-6} \lor \neg \left(t_0 \leq 1\right)
\end{array}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{1 + y}, x - 1, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + \frac{x}{y \cdot y}\right) - \left({y}^{-2} + \frac{x - 1}{y}\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 1.3651577721425698e-6) (not (<= t_0 1.0))))
(fma (/ y (+ 1.0 y)) (- x 1.0) 1.0)
(- (+ x (/ x (* y y))) (+ (pow y -2.0) (/ (- x 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 t_0 = ((1.0 - x) * y) / (1.0 + y);
double tmp;
if ((t_0 <= 1.3651577721425698e-6) || !(t_0 <= 1.0)) {
tmp = fma((y / (1.0 + y)), (x - 1.0), 1.0);
} else {
tmp = (x + (x / (y * y))) - (pow(y, -2.0) + ((x - 1.0) / y));
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 22.6 |
|---|---|
| Target | 0.2 |
| Herbie | 0.7 |
if (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 1.3651577721425698e-6 or 1 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) Initial program 11.2
Simplified0.4
Applied fma-udef_binary640.4
Simplified0.4
Taylor expanded in x around 0 11.2
Simplified0.4
if 1.3651577721425698e-6 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 1Initial program 58.0
Simplified58.0
Taylor expanded in y around inf 1.6
Simplified1.6
Applied pow2_binary641.6
Applied pow-flip_binary641.6
Final simplification0.7
herbie shell --seed 2021313
(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))))