?

Average Error: 8.9% → 1.09%
Time: 8.8s
Precision: binary64
Cost: 40456

?

\[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
\[\begin{array}{l} t_0 := \frac{y}{y + z}\\ t_1 := \log t_0\\ t_2 := \frac{e^{y \cdot t_1}}{y}\\ \mathbf{if}\;t_2 \leq 0:\\ \;\;\;\;x + \frac{{\left(e^{y}\right)}^{t_1}}{y}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{-137}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\sqrt{{t_0}^{\left(y \cdot 2\right)}}}{y}\\ \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 (/ y (+ y z))) (t_1 (log t_0)) (t_2 (/ (exp (* y t_1)) y)))
   (if (<= t_2 0.0)
     (+ x (/ (pow (exp y) t_1) y))
     (if (<= t_2 2e-137)
       (+ x (/ (exp (- z)) y))
       (+ x (/ (sqrt (pow t_0 (* y 2.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 t_0 = y / (y + z);
	double t_1 = log(t_0);
	double t_2 = exp((y * t_1)) / y;
	double tmp;
	if (t_2 <= 0.0) {
		tmp = x + (pow(exp(y), t_1) / y);
	} else if (t_2 <= 2e-137) {
		tmp = x + (exp(-z) / y);
	} else {
		tmp = x + (sqrt(pow(t_0, (y * 2.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) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = y / (y + z)
    t_1 = log(t_0)
    t_2 = exp((y * t_1)) / y
    if (t_2 <= 0.0d0) then
        tmp = x + ((exp(y) ** t_1) / y)
    else if (t_2 <= 2d-137) then
        tmp = x + (exp(-z) / y)
    else
        tmp = x + (sqrt((t_0 ** (y * 2.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 t_0 = y / (y + z);
	double t_1 = Math.log(t_0);
	double t_2 = Math.exp((y * t_1)) / y;
	double tmp;
	if (t_2 <= 0.0) {
		tmp = x + (Math.pow(Math.exp(y), t_1) / y);
	} else if (t_2 <= 2e-137) {
		tmp = x + (Math.exp(-z) / y);
	} else {
		tmp = x + (Math.sqrt(Math.pow(t_0, (y * 2.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):
	t_0 = y / (y + z)
	t_1 = math.log(t_0)
	t_2 = math.exp((y * t_1)) / y
	tmp = 0
	if t_2 <= 0.0:
		tmp = x + (math.pow(math.exp(y), t_1) / y)
	elif t_2 <= 2e-137:
		tmp = x + (math.exp(-z) / y)
	else:
		tmp = x + (math.sqrt(math.pow(t_0, (y * 2.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)
	t_0 = Float64(y / Float64(y + z))
	t_1 = log(t_0)
	t_2 = Float64(exp(Float64(y * t_1)) / y)
	tmp = 0.0
	if (t_2 <= 0.0)
		tmp = Float64(x + Float64((exp(y) ^ t_1) / y));
	elseif (t_2 <= 2e-137)
		tmp = Float64(x + Float64(exp(Float64(-z)) / y));
	else
		tmp = Float64(x + Float64(sqrt((t_0 ^ Float64(y * 2.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)
	t_0 = y / (y + z);
	t_1 = log(t_0);
	t_2 = exp((y * t_1)) / y;
	tmp = 0.0;
	if (t_2 <= 0.0)
		tmp = x + ((exp(y) ^ t_1) / y);
	elseif (t_2 <= 2e-137)
		tmp = x + (exp(-z) / y);
	else
		tmp = x + (sqrt((t_0 ^ (y * 2.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_] := Block[{t$95$0 = N[(y / N[(y + z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Log[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Exp[N[(y * t$95$1), $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$2, 0.0], N[(x + N[(N[Power[N[Exp[y], $MachinePrecision], t$95$1], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e-137], N[(x + N[(N[Exp[(-z)], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Sqrt[N[Power[t$95$0, N[(y * 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]
x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y}
\begin{array}{l}
t_0 := \frac{y}{y + z}\\
t_1 := \log t_0\\
t_2 := \frac{e^{y \cdot t_1}}{y}\\
\mathbf{if}\;t_2 \leq 0:\\
\;\;\;\;x + \frac{{\left(e^{y}\right)}^{t_1}}{y}\\

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

\mathbf{else}:\\
\;\;\;\;x + \frac{\sqrt{{t_0}^{\left(y \cdot 2\right)}}}{y}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original8.9%
Target1.53%
Herbie1.09%
\[\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 (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y) < 0.0

    1. Initial program 14.11

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

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

      [Start]14.11

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

      exp-prod [=>]1.38

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

      sqr-pow [=>]1.38

      \[ 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 [<=]1.38

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

      +-commutative [=>]1.38

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

    if 0.0 < (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y) < 1.99999999999999996e-137

    1. Initial program 3.29

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

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

      [Start]3.29

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

      *-commutative [=>]3.29

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

      exp-prod [=>]3.29

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

      rem-exp-log [=>]3.29

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

      +-commutative [=>]3.29

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

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

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

      [Start]0.01

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

      mul-1-neg [=>]0.01

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

    if 1.99999999999999996e-137 < (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)

    1. Initial program 1.03

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

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

      [Start]1.03

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

      *-commutative [=>]1.03

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

      exp-prod [=>]1.03

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

      rem-exp-log [=>]1.03

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

      +-commutative [=>]1.03

      \[ x + \frac{{\left(\frac{y}{\color{blue}{y + z}}\right)}^{y}}{y} \]
    3. Applied egg-rr1.03

      \[\leadsto x + \frac{\color{blue}{\sqrt{{\left(\frac{y}{y + z}\right)}^{\left(y \cdot 2\right)}}}}{y} \]
    4. Simplified1.03

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

      [Start]1.03

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

      +-commutative [=>]1.03

      \[ x + \frac{\sqrt{{\left(\frac{y}{\color{blue}{z + y}}\right)}^{\left(y \cdot 2\right)}}}{y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.09

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{y \cdot \log \left(\frac{y}{y + z}\right)}}{y} \leq 0:\\ \;\;\;\;x + \frac{{\left(e^{y}\right)}^{\log \left(\frac{y}{y + z}\right)}}{y}\\ \mathbf{elif}\;\frac{e^{y \cdot \log \left(\frac{y}{y + z}\right)}}{y} \leq 2 \cdot 10^{-137}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\sqrt{{\left(\frac{y}{y + z}\right)}^{\left(y \cdot 2\right)}}}{y}\\ \end{array} \]

Alternatives

Alternative 1
Error1.26%
Cost6916
\[\begin{array}{l} \mathbf{if}\;y \leq 3.3 \cdot 10^{-9}:\\ \;\;\;\;x + \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \end{array} \]
Alternative 2
Error4.87%
Cost452
\[\begin{array}{l} \mathbf{if}\;y \leq 1.16 \cdot 10^{+87}:\\ \;\;\;\;x + \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error43.5%
Cost64
\[x \]

Error

Reproduce?

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