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

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.1
Target1.0
Herbie1.6
\[\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 2 regimes
  2. 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))

    1. Initial program 5.3

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

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

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

    if -62535188385.70076 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 2.71117316346360791e-71

    1. Initial program 8.6

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

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

      \[\leadsto x + \frac{\color{blue}{e^{-z}}}{y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.6

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

Reproduce

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