Average Error: 6.1 → 0.9
Time: 10.7s
Precision: binary64
Cost: 6916
\[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
\[\begin{array}{l} \mathbf{if}\;y \leq 3 \cdot 10^{-18}:\\ \;\;\;\;x + \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ x (/ (exp (* y (log (/ y (+ z y))))) y)))
(FPCore (x y z)
 :precision binary64
 (if (<= y 3e-18) (+ x (/ 1.0 y)) (+ x (/ (exp (- z)) 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 tmp;
	if (y <= 3e-18) {
		tmp = x + (1.0 / y);
	} else {
		tmp = x + (exp(-z) / y);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x + (exp((y * log((y / (z + y))))) / y)
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= 3d-18) then
        tmp = x + (1.0d0 / y)
    else
        tmp = x + (exp(-z) / y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	return x + (Math.exp((y * Math.log((y / (z + y))))) / y);
}
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 3e-18) {
		tmp = x + (1.0 / y);
	} else {
		tmp = x + (Math.exp(-z) / y);
	}
	return tmp;
}
def code(x, y, z):
	return x + (math.exp((y * math.log((y / (z + y))))) / y)
def code(x, y, z):
	tmp = 0
	if y <= 3e-18:
		tmp = x + (1.0 / y)
	else:
		tmp = x + (math.exp(-z) / y)
	return tmp
function code(x, y, z)
	return Float64(x + Float64(exp(Float64(y * log(Float64(y / Float64(z + y))))) / y))
end
function code(x, y, z)
	tmp = 0.0
	if (y <= 3e-18)
		tmp = Float64(x + Float64(1.0 / y));
	else
		tmp = Float64(x + Float64(exp(Float64(-z)) / y));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = x + (exp((y * log((y / (z + y))))) / y);
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 3e-18)
		tmp = x + (1.0 / y);
	else
		tmp = x + (exp(-z) / y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(x + N[(N[Exp[N[(y * N[Log[N[(y / N[(z + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[y, 3e-18], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Exp[(-z)], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\begin{array}{l}
\mathbf{if}\;y \leq 3 \cdot 10^{-18}:\\
\;\;\;\;x + \frac{1}{y}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{e^{-z}}{y}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.1
Target1.1
Herbie0.9
\[\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 y < 2.99999999999999983e-18

    1. Initial program 7.9

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

      \[\leadsto \color{blue}{x + \frac{{\left(e^{y}\right)}^{\log \left(\frac{y}{y + z}\right)}}{y}} \]
      Proof
      (+.f64 x (/.f64 (pow.f64 (exp.f64 y) (log.f64 (/.f64 y (+.f64 y z)))) y)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (/.f64 (pow.f64 (exp.f64 y) (log.f64 (/.f64 y (Rewrite<= +-commutative_binary64 (+.f64 z y))))) y)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (/.f64 (Rewrite=> sqr-pow_binary64 (*.f64 (pow.f64 (exp.f64 y) (/.f64 (log.f64 (/.f64 y (+.f64 z y))) 2)) (pow.f64 (exp.f64 y) (/.f64 (log.f64 (/.f64 y (+.f64 z y))) 2)))) y)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (/.f64 (Rewrite<= sqr-pow_binary64 (pow.f64 (exp.f64 y) (log.f64 (/.f64 y (+.f64 z y))))) y)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (/.f64 (Rewrite<= exp-prod_binary64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y)))))) y)): 19 points increase in error, 2 points decrease in error
    3. Taylor expanded in y around inf 1.1

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

    if 2.99999999999999983e-18 < y

    1. Initial program 1.8

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

      \[\leadsto \color{blue}{x + \frac{{\left(\frac{y}{y + z}\right)}^{y}}{y}} \]
      Proof
      (+.f64 x (/.f64 (pow.f64 (/.f64 y (+.f64 y z)) y) y)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (/.f64 (pow.f64 (/.f64 y (Rewrite<= +-commutative_binary64 (+.f64 z y))) y) y)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (/.f64 (Rewrite=> sqr-pow_binary64 (*.f64 (pow.f64 (/.f64 y (+.f64 z y)) (/.f64 y 2)) (pow.f64 (/.f64 y (+.f64 z y)) (/.f64 y 2)))) y)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (/.f64 (Rewrite<= sqr-pow_binary64 (pow.f64 (/.f64 y (+.f64 z y)) y)) y)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (/.f64 (Rewrite<= exp-to-pow_binary64 (exp.f64 (*.f64 (log.f64 (/.f64 y (+.f64 z y))) y))) y)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (/.f64 (exp.f64 (Rewrite<= *-commutative_binary64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y)))))) y)): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in y around inf 0.6

      \[\leadsto x + \frac{\color{blue}{e^{-1 \cdot z}}}{y} \]
    4. Simplified0.6

      \[\leadsto x + \frac{\color{blue}{e^{-z}}}{y} \]
      Proof
      (exp.f64 (neg.f64 z)): 0 points increase in error, 0 points decrease in error
      (exp.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 z))): 0 points increase in error, 0 points decrease in error
  3. Recombined 2 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3 \cdot 10^{-18}:\\ \;\;\;\;x + \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \end{array} \]

Alternatives

Alternative 1
Error1.2
Cost19840
\[x + \frac{{\left(e^{y}\right)}^{\log \left(\frac{y}{y + z}\right)}}{y} \]
Alternative 2
Error18.9
Cost1248
\[\begin{array}{l} \mathbf{if}\;x \leq -5.3 \cdot 10^{+86}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.16 \cdot 10^{+70}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;x \leq -9.6 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-128}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-159}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-77}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-54}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+47}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error2.6
Cost320
\[x + \frac{1}{y} \]
Alternative 4
Error28.0
Cost64
\[x \]

Error

Reproduce

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