1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
t_0 := 1 - \frac{\left(1 - x\right) \cdot y}{1 + y}\\
t_1 := \frac{y}{1 + y}\\
\mathbf{if}\;t_0 \leq -0.00029284299176612905:\\
\;\;\;\;\begin{array}{l}
t_2 := \sqrt[3]{1 + y}\\
\mathsf{fma}\left(1, \mathsf{fma}\left(t_1, x, 1\right), -\frac{\sqrt[3]{y}}{t_2} \cdot \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{t_2 \cdot t_2}\right) + \sqrt[3]{0}
\end{array}\\
\mathbf{elif}\;t_0 \leq 3.736924492070415 \cdot 10^{-8}:\\
\;\;\;\;\left(\left(x + \frac{x}{y \cdot y}\right) + \frac{1}{{y}^{3}}\right) - \left(\frac{x}{{y}^{3}} + \left(\frac{1}{y \cdot y} + \frac{x + -1}{y}\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 (/ (* (- 1.0 x) y) (+ 1.0 y)))) (t_1 (/ y (+ 1.0 y))))
(if (<= t_0 -0.00029284299176612905)
(let* ((t_2 (cbrt (+ 1.0 y))))
(+
(fma
1.0
(fma t_1 x 1.0)
(- (* (/ (cbrt y) t_2) (/ (* (cbrt y) (cbrt y)) (* t_2 t_2)))))
(cbrt 0.0)))
(if (<= t_0 3.736924492070415e-8)
(-
(+ (+ x (/ x (* y y))) (/ 1.0 (pow y 3.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 - (((1.0 - x) * y) / (1.0 + y));
double t_1 = y / (1.0 + y);
double tmp;
if (t_0 <= -0.00029284299176612905) {
double t_2_1 = cbrt(1.0 + y);
tmp = fma(1.0, fma(t_1, x, 1.0), -((cbrt(y) / t_2_1) * ((cbrt(y) * cbrt(y)) / (t_2_1 * t_2_1)))) + cbrt(0.0);
} else if (t_0 <= 3.736924492070415e-8) {
tmp = ((x + (x / (y * y))) + (1.0 / pow(y, 3.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
| Original | 21.5 |
|---|---|
| Target | 0.2 |
| Herbie | 0.1 |
if (-.f64 1 (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1))) < -2.9284299176613e-4Initial program 20.2
Simplified0.2
Taylor expanded in x around 0 20.2
Simplified0.1
Applied add-cube-cbrt_binary640.1
Applied add-cube-cbrt_binary640.1
Applied times-frac_binary640.1
Applied *-un-lft-identity_binary640.1
Applied prod-diff_binary640.1
Applied add-cbrt-cube_binary640.1
Simplified0.1
if -2.9284299176613e-4 < (-.f64 1 (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1))) < 3.7369244921e-8Initial program 59.1
Simplified59.2
Taylor expanded in y around inf 0.0
Simplified0.0
if 3.7369244921e-8 < (-.f64 1 (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1))) Initial program 6.4
Simplified0.2
Taylor expanded in x around 0 6.4
Simplified0.1
Applied fma-udef_binary640.1
Applied associate--l+_binary640.1
Final simplification0.1
herbie shell --seed 2022039
(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))))