?

Average Error: 2.9 → 0.2
Time: 14.9s
Precision: binary64
Cost: 13896

?

\[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 0:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{elif}\;e^{z} \leq 2:\\ \;\;\;\;x + \frac{y}{\left(1.1283791670955126 + z \cdot 1.1283791670955126\right) - y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;x + 0\\ \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) 0.0)
   (+ x (/ -1.0 x))
   (if (<= (exp z) 2.0)
     (+ x (/ y (- (+ 1.1283791670955126 (* z 1.1283791670955126)) (* y x))))
     (+ x 0.0))))
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) <= 0.0) {
		tmp = x + (-1.0 / x);
	} else if (exp(z) <= 2.0) {
		tmp = x + (y / ((1.1283791670955126 + (z * 1.1283791670955126)) - (y * x)));
	} else {
		tmp = x + 0.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 + (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) <= 0.0d0) then
        tmp = x + ((-1.0d0) / x)
    else if (exp(z) <= 2.0d0) then
        tmp = x + (y / ((1.1283791670955126d0 + (z * 1.1283791670955126d0)) - (y * x)))
    else
        tmp = x + 0.0d0
    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) <= 0.0) {
		tmp = x + (-1.0 / x);
	} else if (Math.exp(z) <= 2.0) {
		tmp = x + (y / ((1.1283791670955126 + (z * 1.1283791670955126)) - (y * x)));
	} else {
		tmp = x + 0.0;
	}
	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) <= 0.0:
		tmp = x + (-1.0 / x)
	elif math.exp(z) <= 2.0:
		tmp = x + (y / ((1.1283791670955126 + (z * 1.1283791670955126)) - (y * x)))
	else:
		tmp = x + 0.0
	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) <= 0.0)
		tmp = Float64(x + Float64(-1.0 / x));
	elseif (exp(z) <= 2.0)
		tmp = Float64(x + Float64(y / Float64(Float64(1.1283791670955126 + Float64(z * 1.1283791670955126)) - Float64(y * x))));
	else
		tmp = Float64(x + 0.0);
	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) <= 0.0)
		tmp = x + (-1.0 / x);
	elseif (exp(z) <= 2.0)
		tmp = x + (y / ((1.1283791670955126 + (z * 1.1283791670955126)) - (y * x)));
	else
		tmp = x + 0.0;
	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], 0.0], N[(x + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Exp[z], $MachinePrecision], 2.0], N[(x + N[(y / N[(N[(1.1283791670955126 + N[(z * 1.1283791670955126), $MachinePrecision]), $MachinePrecision] - N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + 0.0), $MachinePrecision]]]
x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 0:\\
\;\;\;\;x + \frac{-1}{x}\\

\mathbf{elif}\;e^{z} \leq 2:\\
\;\;\;\;x + \frac{y}{\left(1.1283791670955126 + z \cdot 1.1283791670955126\right) - y \cdot x}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.9
Target0.0
Herbie0.2
\[x + \frac{1}{\frac{1.1283791670955126}{y} \cdot e^{z} - x} \]

Derivation?

  1. Split input into 3 regimes
  2. if (exp.f64 z) < 0.0

    1. Initial program 7.6

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

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

    if 0.0 < (exp.f64 z) < 2

    1. Initial program 0.1

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

      \[\leadsto x + \frac{y}{\color{blue}{\left(1.1283791670955126 + 1.1283791670955126 \cdot z\right) - y \cdot x}} \]
    3. Simplified0.3

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

      [Start]0.3

      \[ x + \frac{y}{\left(1.1283791670955126 + 1.1283791670955126 \cdot z\right) - y \cdot x} \]

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

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

    if 2 < (exp.f64 z)

    1. Initial program 3.9

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

      \[\leadsto x + \frac{y}{\color{blue}{\left(1.1283791670955126 + 1.1283791670955126 \cdot z\right) - y \cdot x}} \]
    3. Simplified16.2

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

      [Start]16.2

      \[ x + \frac{y}{\left(1.1283791670955126 + 1.1283791670955126 \cdot z\right) - y \cdot x} \]

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

      \[ x + \frac{y}{\left(1.1283791670955126 + \color{blue}{z \cdot 1.1283791670955126}\right) - y \cdot x} \]
    4. Applied egg-rr8.8

      \[\leadsto x + \color{blue}{\left(-1 + \left(1 - \frac{y}{y \cdot x - \left(1.1283791670955126 + 1.1283791670955126 \cdot z\right)}\right)\right)} \]
    5. Taylor expanded in z around inf 11.7

      \[\leadsto x + \left(-1 + \left(1 - \frac{y}{\color{blue}{-1.1283791670955126 \cdot z}}\right)\right) \]
    6. Simplified11.7

      \[\leadsto x + \left(-1 + \left(1 - \frac{y}{\color{blue}{z \cdot -1.1283791670955126}}\right)\right) \]
      Proof

      [Start]11.7

      \[ x + \left(-1 + \left(1 - \frac{y}{-1.1283791670955126 \cdot z}\right)\right) \]

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

      \[ x + \left(-1 + \left(1 - \frac{y}{\color{blue}{z \cdot -1.1283791670955126}}\right)\right) \]
    7. Taylor expanded in y around 0 0.2

      \[\leadsto x + \left(-1 + \color{blue}{1}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

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

Alternatives

Alternative 1
Error1.1
Cost13636
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 0:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\\ \end{array} \]
Alternative 2
Error8.5
Cost1104
\[\begin{array}{l} t_0 := x + \frac{-1}{x}\\ \mathbf{if}\;z \leq -215000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-188}:\\ \;\;\;\;x + \frac{y}{1.1283791670955126}\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-221}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.00021:\\ \;\;\;\;x + y \cdot \left(0.8862269254527579 + -0.8862269254527579 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 0\\ \end{array} \]
Alternative 3
Error8.5
Cost848
\[\begin{array}{l} t_0 := x + \frac{-1}{x}\\ t_1 := x + 0.8862269254527579 \cdot y\\ \mathbf{if}\;z \leq -215000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -9.2 \cdot 10^{-187}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-221}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.0003:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + 0\\ \end{array} \]
Alternative 4
Error8.5
Cost848
\[\begin{array}{l} t_0 := x + \frac{-1}{x}\\ t_1 := x + \frac{y}{1.1283791670955126}\\ \mathbf{if}\;z \leq -215000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -8 \cdot 10^{-188}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.35 \cdot 10^{-221}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.75 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + 0\\ \end{array} \]
Alternative 5
Error0.4
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -215000000:\\ \;\;\;\;x + \frac{-1}{x}\\ \mathbf{elif}\;z \leq 205:\\ \;\;\;\;x + \frac{y}{1.1283791670955126 - y \cdot x}\\ \mathbf{else}:\\ \;\;\;\;x + 0\\ \end{array} \]
Alternative 6
Error16.2
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{-52}:\\ \;\;\;\;x + 0\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-6}:\\ \;\;\;\;x + 0.8862269254527579 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x + 0\\ \end{array} \]
Alternative 7
Error26.2
Cost320
\[x + 0.8862269254527579 \cdot y \]

Error

Reproduce?

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