Average Error: 6.4 → 2.1
Time: 7.0s
Precision: binary64
\[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} \]
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;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.4
Target1.2
Herbie2.1
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z + y} < 7.11541576 \cdot 10^{-315}:\\ \;\;\;\;x + \frac{e^{\frac{-1}{z}}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{e^{\log \left({\left(\frac{y}{y + z}\right)}^{y}\right)}}{y}\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < -481267374.327217638

    1. Initial program 9.0

      \[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
    2. Simplified9.0

      \[\leadsto \color{blue}{x + \frac{{\left(\frac{y}{y + z}\right)}^{y}}{y}} \]
    3. Taylor expanded in y around 0 0.1

      \[\leadsto x + \frac{\color{blue}{1}}{y} \]

    if -481267374.327217638 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 2.8961637957416529e-119

    1. Initial program 11.0

      \[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
    2. Simplified11.0

      \[\leadsto \color{blue}{x + \frac{{\left(\frac{y}{y + z}\right)}^{y}}{y}} \]
    3. Taylor expanded in y around inf 6.2

      \[\leadsto x + \frac{\color{blue}{e^{-z}}}{y} \]

    if 2.8961637957416529e-119 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y))

    1. Initial program 2.0

      \[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
    2. Simplified2.0

      \[\leadsto \color{blue}{x + \frac{{\left(\frac{y}{y + z}\right)}^{y}}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{e^{y \cdot \log \left(\frac{y}{y + z}\right)}}{y} \leq -481267374.32721764:\\ \;\;\;\;x + \frac{1}{y}\\ \mathbf{elif}\;x + \frac{e^{y \cdot \log \left(\frac{y}{y + z}\right)}}{y} \leq 2.896163795741653 \cdot 10^{-119}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{{\left(\frac{y}{y + z}\right)}^{y}}{y}\\ \end{array} \]

Reproduce

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)))