?

Average Error: 6.1 → 1.3
Time: 10.9s
Precision: binary64
Cost: 46985

?

\[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
\[\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 2 \cdot 10^{-271} \lor \neg \left(t_1 \leq 4 \cdot 10^{-105}\right):\\ \;\;\;\;x + \frac{{\left(e^{y}\right)}^{t_0}}{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
 (let* ((t_0 (log (/ y (+ y z)))) (t_1 (+ x (/ (exp (* y t_0)) y))))
   (if (or (<= t_1 2e-271) (not (<= t_1 4e-105)))
     (+ x (/ (pow (exp y) t_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 t_0 = log((y / (y + z)));
	double t_1 = x + (exp((y * t_0)) / y);
	double tmp;
	if ((t_1 <= 2e-271) || !(t_1 <= 4e-105)) {
		tmp = x + (pow(exp(y), t_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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = log((y / (y + z)))
    t_1 = x + (exp((y * t_0)) / y)
    if ((t_1 <= 2d-271) .or. (.not. (t_1 <= 4d-105))) then
        tmp = x + ((exp(y) ** t_0) / 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 t_0 = Math.log((y / (y + z)));
	double t_1 = x + (Math.exp((y * t_0)) / y);
	double tmp;
	if ((t_1 <= 2e-271) || !(t_1 <= 4e-105)) {
		tmp = x + (Math.pow(Math.exp(y), t_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):
	t_0 = math.log((y / (y + z)))
	t_1 = x + (math.exp((y * t_0)) / y)
	tmp = 0
	if (t_1 <= 2e-271) or not (t_1 <= 4e-105):
		tmp = x + (math.pow(math.exp(y), t_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)
	t_0 = log(Float64(y / Float64(y + z)))
	t_1 = Float64(x + Float64(exp(Float64(y * t_0)) / y))
	tmp = 0.0
	if ((t_1 <= 2e-271) || !(t_1 <= 4e-105))
		tmp = Float64(x + Float64((exp(y) ^ t_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)
	t_0 = log((y / (y + z)));
	t_1 = x + (exp((y * t_0)) / y);
	tmp = 0.0;
	if ((t_1 <= 2e-271) || ~((t_1 <= 4e-105)))
		tmp = x + ((exp(y) ^ t_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_] := Block[{t$95$0 = N[Log[N[(y / N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(N[Exp[N[(y * t$95$0), $MachinePrecision]], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, 2e-271], N[Not[LessEqual[t$95$1, 4e-105]], $MachinePrecision]], N[(x + N[(N[Power[N[Exp[y], $MachinePrecision], t$95$0], $MachinePrecision] / 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}
t_0 := \log \left(\frac{y}{y + z}\right)\\
t_1 := x + \frac{e^{y \cdot t_0}}{y}\\
\mathbf{if}\;t_1 \leq 2 \cdot 10^{-271} \lor \neg \left(t_1 \leq 4 \cdot 10^{-105}\right):\\
\;\;\;\;x + \frac{{\left(e^{y}\right)}^{t_0}}{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.2
Herbie1.3
\[\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 (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 1.99999999999999993e-271 or 3.99999999999999986e-105 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y))

    1. Initial program 5.7

      \[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

      [Start]5.7

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

      exp-prod [=>]0.9

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

      sqr-pow [=>]0.9

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

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

      +-commutative [=>]0.9

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

    if 1.99999999999999993e-271 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 3.99999999999999986e-105

    1. Initial program 12.2

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

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

      [Start]12.2

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

      *-commutative [=>]12.2

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

      exp-prod [=>]12.2

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

      rem-exp-log [=>]12.2

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

      +-commutative [=>]12.2

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

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

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

      [Start]6.0

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

      mul-1-neg [=>]6.0

      \[ x + \frac{e^{\color{blue}{-z}}}{y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{e^{y \cdot \log \left(\frac{y}{y + z}\right)}}{y} \leq 2 \cdot 10^{-271} \lor \neg \left(x + \frac{e^{y \cdot \log \left(\frac{y}{y + z}\right)}}{y} \leq 4 \cdot 10^{-105}\right):\\ \;\;\;\;x + \frac{{\left(e^{y}\right)}^{\log \left(\frac{y}{y + z}\right)}}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \end{array} \]

Alternatives

Alternative 1
Error0.8
Cost6916
\[\begin{array}{l} \mathbf{if}\;y \leq 5 \cdot 10^{-9}:\\ \;\;\;\;x + \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \end{array} \]
Alternative 2
Error14.8
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -8.2 \cdot 10^{-30}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-79}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error2.7
Cost320
\[x + \frac{1}{y} \]
Alternative 4
Error27.6
Cost64
\[x \]

Error

Reproduce?

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