?

Average Error: 6.1 → 1.7
Time: 10.7s
Precision: binary64
Cost: 33928

?

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

\mathbf{elif}\;t_1 \leq 4 \cdot 10^{-86}:\\
\;\;\;\;x + \frac{e^{-z}}{y}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.1
Target1.1
Herbie1.7
\[\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)) < -1e-216 or 4.00000000000000034e-86 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y))

    1. Initial program 5.4

      \[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
    2. Taylor expanded in y around inf 11.1

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

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

      [Start]11.1

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

      rational.json-simplify-2 [=>]11.1

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

      rational.json-simplify-9 [=>]11.1

      \[ x + \frac{e^{\color{blue}{-z}}}{y} \]
    4. Taylor expanded in z around 0 1.1

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

    if -1e-216 < (+.f64 x (/.f64 (exp.f64 (*.f64 y (log.f64 (/.f64 y (+.f64 z y))))) y)) < 4.00000000000000034e-86

    1. Initial program 11.7

      \[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
    2. Taylor expanded in y around inf 6.0

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

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

      [Start]6.0

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

      rational.json-simplify-2 [=>]6.0

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

      rational.json-simplify-9 [=>]6.0

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

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

Alternatives

Alternative 1
Error2.5
Cost320
\[x + \frac{1}{y} \]
Alternative 2
Error28.0
Cost64
\[x \]

Error

Reproduce?

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