?

Average Error: 5.6 → 1.0
Time: 23.2s
Precision: binary64
Cost: 6916

?

\[x + \frac{e^{y \cdot \log \left(\frac{y}{z + y}\right)}}{y} \]
\[\begin{array}{l} \mathbf{if}\;y \leq 2.35 \cdot 10^{-35}:\\ \;\;\;\;\frac{1}{y} + x\\ \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
 (if (<= y 2.35e-35) (+ (/ 1.0 y) x) (+ 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 tmp;
	if (y <= 2.35e-35) {
		tmp = (1.0 / y) + x;
	} 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) :: tmp
    if (y <= 2.35d-35) then
        tmp = (1.0d0 / y) + x
    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 tmp;
	if (y <= 2.35e-35) {
		tmp = (1.0 / y) + x;
	} 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):
	tmp = 0
	if y <= 2.35e-35:
		tmp = (1.0 / y) + x
	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)
	tmp = 0.0
	if (y <= 2.35e-35)
		tmp = Float64(Float64(1.0 / y) + x);
	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)
	tmp = 0.0;
	if (y <= 2.35e-35)
		tmp = (1.0 / y) + x;
	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_] := If[LessEqual[y, 2.35e-35], N[(N[(1.0 / y), $MachinePrecision] + x), $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}
\mathbf{if}\;y \leq 2.35 \cdot 10^{-35}:\\
\;\;\;\;\frac{1}{y} + x\\

\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

Original5.6
Target1.0
Herbie1.0
\[\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 < 2.35e-35

    1. Initial program 7.5

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

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

    if 2.35e-35 < y

    1. Initial program 1.7

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

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

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

      [Start]1.2

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.35 \cdot 10^{-35}:\\ \;\;\;\;\frac{1}{y} + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{e^{-z}}{y}\\ \end{array} \]

Alternatives

Alternative 1
Error3.2
Cost584
\[\begin{array}{l} t_0 := \frac{1}{y} + x\\ \mathbf{if}\;y \leq 1.6 \cdot 10^{+22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+134}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error14.8
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -190:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 0.000192:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error28.0
Cost64
\[x \]

Error

Reproduce?

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