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




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 6.1 |
|---|---|
| Target | 1.0 |
| Herbie | 1.6 |
if (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < -62535188385.70076 or 2.71117316346360791e-71 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) Initial program 5.3
Simplified5.3
Taylor expanded in y around 0 0.3
if -62535188385.70076 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 2.71117316346360791e-71Initial program 8.6
Simplified8.6
Taylor expanded in y around inf 5.5
Final simplification1.6
herbie shell --seed 2022117
(FPCore (x y z)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, G"
:precision binary64
:herbie-target
(if (< (/ y (+ z y)) 7.11541576e-315) (+ x (/ (exp (/ -1.0 z)) y)) (+ x (/ (exp (log (pow (/ y (+ y z)) y))) y)))
(+ x (/ (exp (* y (log (/ y (+ z y))))) y)))