?

Average Accuracy: 90.5% → 99.5%
Time: 7.9s
Precision: binary64
Cost: 7049

?

\[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+47} \lor \neg \left(y \leq 2.8 \cdot 10^{-5}\right):\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{y}\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ x (/ (exp (* y (log (/ y (+ z y))))) y)))
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -3.5e+47) (not (<= y 2.8e-5)))
   (+ x (/ (exp (- z)) y))
   (+ x (/ 1.0 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.5e+47) || !(y <= 2.8e-5)) {
		tmp = x + (exp(-z) / y);
	} else {
		tmp = x + (1.0 / 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.5d+47)) .or. (.not. (y <= 2.8d-5))) then
        tmp = x + (exp(-z) / y)
    else
        tmp = x + (1.0d0 / 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.5e+47) || !(y <= 2.8e-5)) {
		tmp = x + (Math.exp(-z) / y);
	} else {
		tmp = x + (1.0 / 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.5e+47) or not (y <= 2.8e-5):
		tmp = x + (math.exp(-z) / y)
	else:
		tmp = x + (1.0 / 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.5e+47) || !(y <= 2.8e-5))
		tmp = Float64(x + Float64(exp(Float64(-z)) / y));
	else
		tmp = Float64(x + Float64(1.0 / 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.5e+47) || ~((y <= 2.8e-5)))
		tmp = x + (exp(-z) / y);
	else
		tmp = x + (1.0 / 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[Or[LessEqual[y, -3.5e+47], N[Not[LessEqual[y, 2.8e-5]], $MachinePrecision]], N[(x + N[(N[Exp[(-z)], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]]
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+47} \lor \neg \left(y \leq 2.8 \cdot 10^{-5}\right):\\
\;\;\;\;x + \frac{e^{-z}}{y}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{1}{y}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original90.5%
Target98.3%
Herbie99.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 2 regimes
  2. if y < -3.50000000000000015e47 or 2.79999999999999996e-5 < y

    1. Initial program 96.8%

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

      \[\leadsto \color{blue}{x + \frac{{\left(\frac{y}{y + z}\right)}^{y}}{y}} \]
      Proof

      [Start]96.8

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

      *-commutative [=>]96.8

      \[ x + \frac{e^{\color{blue}{\log \left(\frac{y}{z + y}\right) \cdot y}}}{y} \]

      exp-prod [=>]96.8

      \[ x + \frac{\color{blue}{{\left(e^{\log \left(\frac{y}{z + y}\right)}\right)}^{y}}}{y} \]

      rem-exp-log [=>]96.8

      \[ x + \frac{{\color{blue}{\left(\frac{y}{z + y}\right)}}^{y}}{y} \]

      +-commutative [=>]96.8

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

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

      \[\leadsto x + \frac{\color{blue}{e^{-z}}}{y} \]
      Proof

      [Start]99.7

      \[ x + \frac{e^{-1 \cdot z}}{y} \]

      mul-1-neg [=>]99.7

      \[ x + \frac{e^{\color{blue}{-z}}}{y} \]

    if -3.50000000000000015e47 < y < 2.79999999999999996e-5

    1. Initial program 84.2%

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

      \[\leadsto \color{blue}{x + \frac{{\left(e^{y}\right)}^{\log \left(\frac{y}{y + z}\right)}}{y}} \]
      Proof

      [Start]84.2

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

      exp-prod [=>]99.7

      \[ x + \frac{\color{blue}{{\left(e^{y}\right)}^{\log \left(\frac{y}{z + y}\right)}}}{y} \]

      sqr-pow [=>]99.7

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

      sqr-pow [<=]99.7

      \[ x + \frac{\color{blue}{{\left(e^{y}\right)}^{\log \left(\frac{y}{z + y}\right)}}}{y} \]

      +-commutative [=>]99.7

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

      \[\leadsto x + \frac{\color{blue}{1}}{y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+47} \lor \neg \left(y \leq 2.8 \cdot 10^{-5}\right):\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{y}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy97.7%
Cost46985
\[\begin{array}{l} t_0 := \log \left(\frac{y}{y + z}\right)\\ t_1 := x + \frac{e^{y \cdot t_0}}{y}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{-146} \lor \neg \left(t_1 \leq 2 \cdot 10^{-132}\right):\\ \;\;\;\;x + \frac{{\left(e^{y}\right)}^{t_0}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \end{array} \]
Alternative 2
Accuracy70.7%
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{-63}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{-139}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-34}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+26}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Accuracy95.3%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq 52000000000000 \lor \neg \left(y \leq 6.9 \cdot 10^{+131}\right):\\ \;\;\;\;x + \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Accuracy55.9%
Cost64
\[x \]

Error

Reproduce?

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