Average Error: 6.1 → 2.1
Time: 4.8s
Precision: binary64
\[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
\[\begin{array}{l} t_0 := x + \frac{1}{y}\\ t_1 := x + \frac{e^{y \cdot \log \left(\frac{y}{y + z}\right)}}{y}\\ \mathbf{if}\;t_1 \leq 9.802750517141011 \cdot 10^{-290}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq 1.2818547459969594 \cdot 10^{-137}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\begin{array}{l}
t_0 := x + \frac{1}{y}\\
t_1 := x + \frac{e^{y \cdot \log \left(\frac{y}{y + z}\right)}}{y}\\
\mathbf{if}\;t_1 \leq 9.802750517141011 \cdot 10^{-290}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_1 \leq 1.2818547459969594 \cdot 10^{-137}:\\
\;\;\;\;x + \frac{e^{-z}}{y}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\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 (/ 1.0 y)))
        (t_1 (+ x (/ (exp (* y (log (/ y (+ y z))))) y))))
   (if (<= t_1 9.802750517141011e-290)
     t_0
     (if (<= t_1 1.2818547459969594e-137) (+ x (/ (exp (- z)) y)) t_0))))
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 + (1.0 / y);
	double t_1 = x + (exp((y * log((y / (y + z))))) / y);
	double tmp;
	if (t_1 <= 9.802750517141011e-290) {
		tmp = t_0;
	} else if (t_1 <= 1.2818547459969594e-137) {
		tmp = x + (exp(-z) / y);
	} else {
		tmp = t_0;
	}
	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
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 2 regimes
  2. if (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 9.80275051714101138e-290 or 1.28185474599695938e-137 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y))

    1. Initial program 5.8

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

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

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

    if 9.80275051714101138e-290 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 1.28185474599695938e-137

    1. Initial program 11.4

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

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

      \[\leadsto x + \frac{\color{blue}{e^{-z}}}{y} \]
  3. Recombined 2 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 9.802750517141011 \cdot 10^{-290}:\\ \;\;\;\;x + \frac{1}{y}\\ \mathbf{elif}\;x + \frac{e^{y \cdot \log \left(\frac{y}{y + z}\right)}}{y} \leq 1.2818547459969594 \cdot 10^{-137}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{y}\\ \end{array} \]

Reproduce

herbie shell --seed 2022130 
(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)))