\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}
\begin{array}{l}
t_0 := e^{-y}\\
\mathbf{if}\;x \leq -1.2194538249148998:\\
\;\;\;\;\frac{1}{\frac{x}{t_0}}\\
\mathbf{elif}\;x \leq 3.137771231155085 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{y}{\frac{x \cdot e^{y}}{y}}, t_0\right)}{x}\\
\end{array}
(FPCore (x y) :precision binary64 (/ (exp (* x (log (/ x (+ x y))))) x))
(FPCore (x y)
:precision binary64
(let* ((t_0 (exp (- y))))
(if (<= x -1.2194538249148998)
(/ 1.0 (/ x t_0))
(if (<= x 3.137771231155085e-5)
(/ 1.0 x)
(/ (fma 0.5 (/ y (/ (* x (exp y)) y)) t_0) x)))))double code(double x, double y) {
return exp(x * log(x / (x + y))) / x;
}
double code(double x, double y) {
double t_0 = exp(-y);
double tmp;
if (x <= -1.2194538249148998) {
tmp = 1.0 / (x / t_0);
} else if (x <= 3.137771231155085e-5) {
tmp = 1.0 / x;
} else {
tmp = fma(0.5, (y / ((x * exp(y)) / y)), t_0) / x;
}
return tmp;
}




Bits error versus x




Bits error versus y
| Original | 14.5 |
|---|---|
| Target | 14.2 |
| Herbie | 0.3 |
if x < -1.21945382491489984Initial program 15.9
Simplified15.9
Taylor expanded in x around inf 0.1
Applied neg-sub0_binary640.1
Applied exp-diff_binary640.1
Applied associate-/l/_binary640.1
Simplified0.1
if -1.21945382491489984 < x < 3.13777123115508498e-5Initial program 11.5
Simplified11.5
Taylor expanded in x around 0 0.5
if 3.13777123115508498e-5 < x Initial program 17.2
Simplified17.2
Taylor expanded in x around inf 9.4
Simplified0.2
Final simplification0.3
herbie shell --seed 2022068
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, F"
:precision binary64
:herbie-target
(if (< y -3.7311844206647956e+94) (/ (exp (/ -1.0 y)) x) (if (< y 2.817959242728288e+37) (/ (pow (/ x (+ y x)) x) x) (if (< y 2.347387415166998e+178) (log (exp (/ (pow (/ x (+ y x)) x) x))) (/ (exp (/ -1.0 y)) x))))
(/ (exp (* x (log (/ x (+ x y))))) x))