x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\begin{array}{l}
t_0 := \frac{y}{y + z}\\
t_1 := x + \frac{e^{y \cdot \log t_0}}{y}\\
\mathbf{if}\;t_1 \leq -481267374.32721764:\\
\;\;\;\;x + \frac{1}{y}\\
\mathbf{elif}\;t_1 \leq 2.896163795741653 \cdot 10^{-119}:\\
\;\;\;\;x + \frac{e^{-z}}{y}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{{t_0}^{y}}{y}\\
\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 (/ y (+ y z))) (t_1 (+ x (/ (exp (* y (log t_0))) y))))
(if (<= t_1 -481267374.32721764)
(+ x (/ 1.0 y))
(if (<= t_1 2.896163795741653e-119)
(+ x (/ (exp (- z)) y))
(+ x (/ (pow t_0 y) y))))))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 = y / (y + z);
double t_1 = x + (exp(y * log(t_0)) / y);
double tmp;
if (t_1 <= -481267374.32721764) {
tmp = x + (1.0 / y);
} else if (t_1 <= 2.896163795741653e-119) {
tmp = x + (exp(-z) / y);
} else {
tmp = x + (pow(t_0, y) / y);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 6.4 |
|---|---|
| Target | 1.2 |
| Herbie | 2.1 |
if (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < -481267374.327217638Initial program 9.0
Simplified9.0
Taylor expanded in y around 0 0.1
if -481267374.327217638 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 2.8961637957416529e-119Initial program 11.0
Simplified11.0
Taylor expanded in y around inf 6.2
if 2.8961637957416529e-119 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) Initial program 2.0
Simplified2.0
Final simplification2.1
herbie shell --seed 2021275
(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)))