?

Average Error: 3.1 → 0.4
Time: 14.3s
Precision: binary64
Cost: 20168

?

\[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 5 \cdot 10^{-42}:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;e^{z} \leq 1.0000000000002:\\ \;\;\;\;x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))
(FPCore (x y z)
 :precision binary64
 (if (<= (exp z) 5e-42)
   (- x (/ 1.0 x))
   (if (<= (exp z) 1.0000000000002)
     (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y))))
     x)))
double code(double x, double y, double z) {
	return x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
}
double code(double x, double y, double z) {
	double tmp;
	if (exp(z) <= 5e-42) {
		tmp = x - (1.0 / x);
	} else if (exp(z) <= 1.0000000000002) {
		tmp = x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
	} else {
		tmp = x;
	}
	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 + (y / ((1.1283791670955126d0 * exp(z)) - (x * 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 (exp(z) <= 5d-42) then
        tmp = x - (1.0d0 / x)
    else if (exp(z) <= 1.0000000000002d0) then
        tmp = x + (y / ((1.1283791670955126d0 * exp(z)) - (x * y)))
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	return x + (y / ((1.1283791670955126 * Math.exp(z)) - (x * y)));
}
public static double code(double x, double y, double z) {
	double tmp;
	if (Math.exp(z) <= 5e-42) {
		tmp = x - (1.0 / x);
	} else if (Math.exp(z) <= 1.0000000000002) {
		tmp = x + (y / ((1.1283791670955126 * Math.exp(z)) - (x * y)));
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	return x + (y / ((1.1283791670955126 * math.exp(z)) - (x * y)))
def code(x, y, z):
	tmp = 0
	if math.exp(z) <= 5e-42:
		tmp = x - (1.0 / x)
	elif math.exp(z) <= 1.0000000000002:
		tmp = x + (y / ((1.1283791670955126 * math.exp(z)) - (x * y)))
	else:
		tmp = x
	return tmp
function code(x, y, z)
	return Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y))))
end
function code(x, y, z)
	tmp = 0.0
	if (exp(z) <= 5e-42)
		tmp = Float64(x - Float64(1.0 / x));
	elseif (exp(z) <= 1.0000000000002)
		tmp = Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y))));
	else
		tmp = x;
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (exp(z) <= 5e-42)
		tmp = x - (1.0 / x);
	elseif (exp(z) <= 1.0000000000002)
		tmp = x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[N[Exp[z], $MachinePrecision], 5e-42], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[z], $MachinePrecision], 1.0000000000002], N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 5 \cdot 10^{-42}:\\
\;\;\;\;x - \frac{1}{x}\\

\mathbf{elif}\;e^{z} \leq 1.0000000000002:\\
\;\;\;\;x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.1
Target0.1
Herbie0.4
\[x + \frac{1}{\frac{1.1283791670955126}{y} \cdot e^{z} - x} \]

Derivation?

  1. Split input into 3 regimes
  2. if (exp.f64 z) < 5.00000000000000003e-42

    1. Initial program 8.0

      \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
    2. Taylor expanded in x around inf 0.0

      \[\leadsto \color{blue}{x - \frac{1}{x}} \]

    if 5.00000000000000003e-42 < (exp.f64 z) < 1.00000000000020006

    1. Initial program 0.1

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

    if 1.00000000000020006 < (exp.f64 z)

    1. Initial program 3.9

      \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
    2. Taylor expanded in x around inf 1.4

      \[\leadsto \color{blue}{x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{z} \leq 5 \cdot 10^{-42}:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;e^{z} \leq 1.0000000000002:\\ \;\;\;\;x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternatives

Alternative 1
Error0.5
Cost13896
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 5 \cdot 10^{-42}:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;e^{z} \leq 1.0000000000002:\\ \;\;\;\;x + \frac{y}{\left(1.1283791670955126 + z \cdot 1.1283791670955126\right) - y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error18.0
Cost980
\[\begin{array}{l} \mathbf{if}\;z \leq -2.3 \cdot 10^{+146}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;z \leq -1.85 \cdot 10^{+77}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{-6}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;z \leq -2.19 \cdot 10^{-181}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-13}:\\ \;\;\;\;0.8862269254527579 \cdot y + x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error18.0
Cost980
\[\begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{+147}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{+75}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{-6}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;z \leq -2.19 \cdot 10^{-181}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{-13}:\\ \;\;\;\;\frac{y}{1.1283791670955126} + x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error8.8
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -0.00024:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-13}:\\ \;\;\;\;\frac{y}{1.1283791670955126 + 1.1283791670955126 \cdot z} + x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error0.6
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -95:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{-13}:\\ \;\;\;\;\frac{y}{1.1283791670955126 - y \cdot x} + x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error19.3
Cost588
\[\begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{-154}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-223}:\\ \;\;\;\;0.8862269254527579 \cdot y\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-195}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error19.3
Cost588
\[\begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-154}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-223}:\\ \;\;\;\;\frac{y}{1.1283791670955126}\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-196}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error8.9
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -0.00115:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-13}:\\ \;\;\;\;\frac{y}{1.1283791670955126} + x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error19.4
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{-154}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.06 \cdot 10^{-238}:\\ \;\;\;\;0.8862269254527579 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error20.5
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023077 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:invErfc from math-functions-0.1.5.2, A"
  :precision binary64

  :herbie-target
  (+ x (/ 1.0 (- (* (/ 1.1283791670955126 y) (exp z)) x)))

  (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))