\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}\begin{array}{l}
\mathbf{if}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -33729989078041.62:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq -1.7207415369154863 \cdot 10^{-265}:\\
\;\;\;\;\frac{e^{-y}}{x}\\
\mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 0:\\
\;\;\;\;\frac{e^{x \cdot \left(\log x - \log \left(x + y\right)\right)}}{x}\\
\mathbf{elif}\;\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x} \leq 1.5382303982872333 \cdot 10^{-46}:\\
\;\;\;\;\frac{e^{-y}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}\right)}^{x} \cdot {\left(\frac{\sqrt[3]{x}}{\sqrt[3]{x + y}}\right)}^{x}}{x}\\
\end{array}(FPCore (x y) :precision binary64 (/ (exp (* x (log (/ x (+ x y))))) x))
(FPCore (x y)
:precision binary64
(if (<= (/ (exp (* x (log (/ x (+ x y))))) x) -33729989078041.62)
(/ 1.0 x)
(if (<= (/ (exp (* x (log (/ x (+ x y))))) x) -1.7207415369154863e-265)
(/ (exp (- y)) x)
(if (<= (/ (exp (* x (log (/ x (+ x y))))) x) 0.0)
(/ (exp (* x (- (log x) (log (+ x y))))) x)
(if (<= (/ (exp (* x (log (/ x (+ x y))))) x) 1.5382303982872333e-46)
(/ (exp (- y)) x)
(/
(*
(pow (/ (* (cbrt x) (cbrt x)) (* (cbrt (+ x y)) (cbrt (+ x y)))) x)
(pow (/ (cbrt x) (cbrt (+ x y))) x))
x))))))double code(double x, double y) {
return exp(x * log(x / (x + y))) / x;
}
double code(double x, double y) {
double tmp;
if ((exp(x * log(x / (x + y))) / x) <= -33729989078041.62) {
tmp = 1.0 / x;
} else if ((exp(x * log(x / (x + y))) / x) <= -1.7207415369154863e-265) {
tmp = exp(-y) / x;
} else if ((exp(x * log(x / (x + y))) / x) <= 0.0) {
tmp = exp(x * (log(x) - log(x + y))) / x;
} else if ((exp(x * log(x / (x + y))) / x) <= 1.5382303982872333e-46) {
tmp = exp(-y) / x;
} else {
tmp = (pow(((cbrt(x) * cbrt(x)) / (cbrt(x + y) * cbrt(x + y))), x) * pow((cbrt(x) / cbrt(x + y)), x)) / x;
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 11.0 |
|---|---|
| Target | 7.9 |
| Herbie | 3.2 |
if (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < -33729989078041.6211Initial program 12.2
Simplified12.1
Taylor expanded around 0 0.1
if -33729989078041.6211 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < -1.7207415369154863e-265 or 0.0 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < 1.5382303982872333e-46Initial program 12.0
Simplified11.9
Taylor expanded around inf 0.5
if -1.7207415369154863e-265 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) < 0.0Initial program 23.9
Simplified23.9
rmApplied add-exp-log_binary6439.5
Applied add-exp-log_binary6439.7
Applied div-exp_binary6439.7
Applied pow-exp_binary6420.9
if 1.5382303982872333e-46 < (/.f64 (exp.f64 (*.f64 x (log.f64 (/.f64 x (+.f64 x y))))) x) Initial program 0.4
Simplified0.4
rmApplied add-cube-cbrt_binary645.6
Applied add-cube-cbrt_binary640.4
Applied times-frac_binary640.4
Applied unpow-prod-down_binary640.4
Final simplification3.2
herbie shell --seed 2021118
(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))