1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{1 + y}\\
t_1 := \frac{y}{1 + y}\\
\mathbf{if}\;t_0 \leq 0.8836801561647109:\\
\;\;\;\;1 + t_1 \cdot \left(x + -1\right)\\
\mathbf{elif}\;t_0 \leq 1.0000000994880573:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\left(x + \frac{x}{y \cdot y}\right) + \left(\frac{1 - x}{{y}^{3}} - \left(\frac{1}{y \cdot y} + \frac{x + -1}{y}\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot t_1 + \left(1 - t_1\right)\\
\end{array}
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (* (- 1.0 x) y) (+ 1.0 y))) (t_1 (/ y (+ 1.0 y))))
(if (<= t_0 0.8836801561647109)
(+ 1.0 (* t_1 (+ x -1.0)))
(if (<= t_0 1.0000000994880573)
(log1p
(expm1
(+
(+ x (/ x (* y y)))
(- (/ (- 1.0 x) (pow y 3.0)) (+ (/ 1.0 (* y y)) (/ (+ x -1.0) y))))))
(+ (* x t_1) (- 1.0 t_1))))))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 t_1 = y / (1.0 + y);
double tmp;
if (t_0 <= 0.8836801561647109) {
tmp = 1.0 + (t_1 * (x + -1.0));
} else if (t_0 <= 1.0000000994880573) {
tmp = log1p(expm1((x + (x / (y * y))) + (((1.0 - x) / pow(y, 3.0)) - ((1.0 / (y * y)) + ((x + -1.0) / y)))));
} else {
tmp = (x * t_1) + (1.0 - t_1);
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 22.7 |
|---|---|
| Target | 0.2 |
| Herbie | 0.1 |
if (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 0.88368015616471085Initial program 7.3
Simplified0.0
Applied fma-udef_binary640.0
Simplified0.0
if 0.88368015616471085 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 1.0000000994880573Initial program 59.0
Simplified58.9
Taylor expanded in y around inf 0.2
Simplified0.2
Applied log1p-expm1-u_binary640.2
Simplified0.2
if 1.0000000994880573 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) Initial program 20.8
Simplified0.4
Applied fma-udef_binary640.4
Simplified0.3
Applied distribute-lft-in_binary640.3
Applied associate-+l+_binary640.2
Simplified0.2
Final simplification0.1
herbie shell --seed 2022077
(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))))