Average Error: 6.1 → 1.4
Time: 6.3s
Precision: binary64
Cost: 7172
\[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
\[\begin{array}{l} \mathbf{if}\;y \leq 3.2 \cdot 10^{-51}:\\ \;\;\;\;\frac{1}{y} + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{{\left(\frac{y}{y + z}\right)}^{y}}{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 3.2e-51) (+ (/ 1.0 y) x) (+ x (/ (pow (/ y (+ y z)) 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 tmp;
	if (y <= 3.2e-51) {
		tmp = (1.0 / y) + x;
	} else {
		tmp = x + (pow((y / (y + z)), y) / 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 <= 3.2d-51) then
        tmp = (1.0d0 / y) + x
    else
        tmp = x + (((y / (y + z)) ** y) / 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 <= 3.2e-51) {
		tmp = (1.0 / y) + x;
	} else {
		tmp = x + (Math.pow((y / (y + z)), y) / 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 <= 3.2e-51:
		tmp = (1.0 / y) + x
	else:
		tmp = x + (math.pow((y / (y + z)), y) / 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 <= 3.2e-51)
		tmp = Float64(Float64(1.0 / y) + x);
	else
		tmp = Float64(x + Float64((Float64(y / Float64(y + z)) ^ y) / 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 <= 3.2e-51)
		tmp = (1.0 / y) + x;
	else
		tmp = x + (((y / (y + z)) ^ y) / 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, 3.2e-51], N[(N[(1.0 / y), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(N[Power[N[(y / N[(y + z), $MachinePrecision]), $MachinePrecision], y], $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.2 \cdot 10^{-51}:\\
\;\;\;\;\frac{1}{y} + x\\

\mathbf{else}:\\
\;\;\;\;x + \frac{{\left(\frac{y}{y + z}\right)}^{y}}{y}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.1
Target1.1
Herbie1.4
\[\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 < 3.2e-51

    1. Initial program 8.2

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

      \[\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 z around 0 1.2

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

    if 3.2e-51 < 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. Recombined 2 regimes into one program.
  4. Final simplification1.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.2 \cdot 10^{-51}:\\ \;\;\;\;\frac{1}{y} + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{{\left(\frac{y}{y + z}\right)}^{y}}{y}\\ \end{array} \]

Alternatives

Alternative 1
Error16.3
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -8.8 \cdot 10^{+95}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2 \cdot 10^{-58}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;y \leq -1.9 \cdot 10^{-115}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-10}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error2.5
Cost320
\[\frac{1}{y} + x \]
Alternative 3
Error28.3
Cost64
\[x \]

Error

Reproduce

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