(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))))
(if (<= t_0 1e-19)
(fma (- 1.0 x) (- (/ y (+ 1.0 y))) 1.0)
(if (<= t_0 2.0)
(-
(+ (/ 1.0 y) (+ x (/ x (pow y 2.0))))
(+ (/ x y) (cbrt (pow y -6.0))))
(fma (- 1.0 x) (log1p (expm1 (/ y (- -1.0 y)))) 1.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 <= 1e-19) {
tmp = fma((1.0 - x), -(y / (1.0 + y)), 1.0);
} else if (t_0 <= 2.0) {
tmp = ((1.0 / y) + (x + (x / pow(y, 2.0)))) - ((x / y) + cbrt(pow(y, -6.0)));
} else {
tmp = fma((1.0 - x), log1p(expm1((y / (-1.0 - y)))), 1.0);
}
return tmp;
}
function code(x, y) return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0))) end
function code(x, y) t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(1.0 + y)) tmp = 0.0 if (t_0 <= 1e-19) tmp = fma(Float64(1.0 - x), Float64(-Float64(y / Float64(1.0 + y))), 1.0); elseif (t_0 <= 2.0) tmp = Float64(Float64(Float64(1.0 / y) + Float64(x + Float64(x / (y ^ 2.0)))) - Float64(Float64(x / y) + cbrt((y ^ -6.0)))); else tmp = fma(Float64(1.0 - x), log1p(expm1(Float64(y / Float64(-1.0 - y)))), 1.0); end return tmp end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-19], N[(N[(1.0 - x), $MachinePrecision] * (-N[(y / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]) + 1.0), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(N[(N[(1.0 / y), $MachinePrecision] + N[(x + N[(x / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] + N[Power[N[Power[y, -6.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - x), $MachinePrecision] * N[Log[1 + N[(Exp[N[(y / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]]]]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{1 + y}\\
\mathbf{if}\;t_0 \leq 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(1 - x, -\frac{y}{1 + y}, 1\right)\\
\mathbf{elif}\;t_0 \leq 2:\\
\;\;\;\;\left(\frac{1}{y} + \left(x + \frac{x}{{y}^{2}}\right)\right) - \left(\frac{x}{y} + \sqrt[3]{{y}^{-6}}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1 - x, \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{y}{-1 - y}\right)\right), 1\right)\\
\end{array}




Bits error versus x




Bits error versus y
| Original | 23.1 |
|---|---|
| Target | 0.2 |
| Herbie | 1.1 |
if (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 9.9999999999999998e-20Initial program 7.7
Simplified0.0
Applied egg-rr0.0
if 9.9999999999999998e-20 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 2Initial program 54.3
Simplified54.2
Taylor expanded in y around inf 4.1
Applied egg-rr4.1
if 2 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) Initial program 21.5
Simplified0.0
Applied egg-rr0.0
Final simplification1.1
herbie shell --seed 2022159
(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))))