Average Error: 6.1 → 0.5
Time: 13.9s
Precision: binary64
Cost: 7112
\[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{+37}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-37}:\\ \;\;\;\;x + \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{y \cdot e^{z}}\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ x (/ (exp (* y (log (/ y (+ z y))))) y)))
(FPCore (x y z)
 :precision binary64
 (if (<= y -5.8e+37)
   (+ x (/ (exp (- z)) y))
   (if (<= y 1.35e-37) (+ x (/ 1.0 y)) (+ x (/ 1.0 (* y (exp z)))))))
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 <= -5.8e+37) {
		tmp = x + (exp(-z) / y);
	} else if (y <= 1.35e-37) {
		tmp = x + (1.0 / y);
	} else {
		tmp = x + (1.0 / (y * exp(z)));
	}
	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 <= (-5.8d+37)) then
        tmp = x + (exp(-z) / y)
    else if (y <= 1.35d-37) then
        tmp = x + (1.0d0 / y)
    else
        tmp = x + (1.0d0 / (y * exp(z)))
    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 <= -5.8e+37) {
		tmp = x + (Math.exp(-z) / y);
	} else if (y <= 1.35e-37) {
		tmp = x + (1.0 / y);
	} else {
		tmp = x + (1.0 / (y * Math.exp(z)));
	}
	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 <= -5.8e+37:
		tmp = x + (math.exp(-z) / y)
	elif y <= 1.35e-37:
		tmp = x + (1.0 / y)
	else:
		tmp = x + (1.0 / (y * math.exp(z)))
	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 <= -5.8e+37)
		tmp = Float64(x + Float64(exp(Float64(-z)) / y));
	elseif (y <= 1.35e-37)
		tmp = Float64(x + Float64(1.0 / y));
	else
		tmp = Float64(x + Float64(1.0 / Float64(y * exp(z))));
	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 <= -5.8e+37)
		tmp = x + (exp(-z) / y);
	elseif (y <= 1.35e-37)
		tmp = x + (1.0 / y);
	else
		tmp = x + (1.0 / (y * exp(z)));
	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, -5.8e+37], N[(x + N[(N[Exp[(-z)], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e-37], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(1.0 / N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+37}:\\
\;\;\;\;x + \frac{e^{-z}}{y}\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{-37}:\\
\;\;\;\;x + \frac{1}{y}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.1
Target1.0
Herbie0.5
\[\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 y < -5.79999999999999957e37

    1. Initial program 2.3

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

      \[\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)): 1 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, 1 points decrease in error
      (+.f64 x (/.f64 (Rewrite<= exp-to-pow_binary64 (exp.f64 (*.f64 (log.f64 (/.f64 y (+.f64 z y))) y))) y)): 1 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.0

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

      \[\leadsto \color{blue}{x + \frac{e^{-z}}{y}} \]
      Proof
      (+.f64 x (/.f64 (exp.f64 (neg.f64 z)) y)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (/.f64 (exp.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 z))) y)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 (exp.f64 (*.f64 -1 z)) y) x)): 0 points increase in error, 0 points decrease in error

    if -5.79999999999999957e37 < y < 1.35000000000000008e-37

    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}} \]
      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)): 1 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, 1 points decrease in error
      (+.f64 x (/.f64 (Rewrite<= exp-to-pow_binary64 (exp.f64 (*.f64 (log.f64 (/.f64 y (+.f64 z y))) y))) y)): 1 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 z around 0 0.3

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

    if 1.35000000000000008e-37 < y

    1. Initial program 1.6

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

      \[\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)): 1 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, 1 points decrease in error
      (+.f64 x (/.f64 (Rewrite<= exp-to-pow_binary64 (exp.f64 (*.f64 (log.f64 (/.f64 y (+.f64 z y))) y))) y)): 1 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 1.1

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

      \[\leadsto \color{blue}{x + \frac{e^{-z}}{y}} \]
      Proof
      (+.f64 x (/.f64 (exp.f64 (neg.f64 z)) y)): 0 points increase in error, 0 points decrease in error
      (+.f64 x (/.f64 (exp.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 z))) y)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 (exp.f64 (*.f64 -1 z)) y) x)): 0 points increase in error, 0 points decrease in error
    5. Applied egg-rr1.1

      \[\leadsto x + \color{blue}{{\left(y \cdot e^{z}\right)}^{-1}} \]
    6. Taylor expanded in x around 0 1.1

      \[\leadsto \color{blue}{\frac{1}{e^{z} \cdot y} + x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.5

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

Alternatives

Alternative 1
Error0.5
Cost7048
\[\begin{array}{l} t_0 := x + \frac{e^{-z}}{y}\\ \mathbf{if}\;y \leq -5.8 \cdot 10^{+37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-37}:\\ \;\;\;\;x + \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error14.8
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -8 \cdot 10^{-79}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5.7 \cdot 10^{-67}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error2.5
Cost320
\[x + \frac{1}{y} \]
Alternative 4
Error28.3
Cost64
\[x \]

Error

Reproduce

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