?

Average Error: 4.51% → 0.34%
Time: 15.1s
Precision: binary64
Cost: 20168

?

\[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 1.00000000155:\\ \;\;\;\;x + \frac{y}{e^{z} \cdot 1.1283791670955126 - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{0.8862269254527579}{e^{z}}\\ \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) 1.00000000155)
     (+ x (/ y (- (* (exp z) 1.1283791670955126) (* x y))))
     (+ x (* y (/ 0.8862269254527579 (exp z)))))))
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) <= 1.00000000155) {
		tmp = x + (y / ((exp(z) * 1.1283791670955126) - (x * y)));
	} else {
		tmp = x + (y * (0.8862269254527579 / exp(z)));
	}
	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) <= 1.00000000155d0) then
        tmp = x + (y / ((exp(z) * 1.1283791670955126d0) - (x * y)))
    else
        tmp = x + (y * (0.8862269254527579d0 / exp(z)))
    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) <= 1.00000000155) {
		tmp = x + (y / ((Math.exp(z) * 1.1283791670955126) - (x * y)));
	} else {
		tmp = x + (y * (0.8862269254527579 / Math.exp(z)));
	}
	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) <= 1.00000000155:
		tmp = x + (y / ((math.exp(z) * 1.1283791670955126) - (x * y)))
	else:
		tmp = x + (y * (0.8862269254527579 / math.exp(z)))
	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) <= 1.00000000155)
		tmp = Float64(x + Float64(y / Float64(Float64(exp(z) * 1.1283791670955126) - Float64(x * y))));
	else
		tmp = Float64(x + Float64(y * Float64(0.8862269254527579 / exp(z))));
	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) <= 1.00000000155)
		tmp = x + (y / ((exp(z) * 1.1283791670955126) - (x * y)));
	else
		tmp = x + (y * (0.8862269254527579 / exp(z)));
	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], 1.00000000155], N[(x + N[(y / N[(N[(N[Exp[z], $MachinePrecision] * 1.1283791670955126), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(0.8862269254527579 / N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 1.00000000155:\\
\;\;\;\;x + \frac{y}{e^{z} \cdot 1.1283791670955126 - x \cdot y}\\

\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{0.8862269254527579}{e^{z}}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.51%
Target0.08%
Herbie0.34%
\[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 12.02

      \[x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y} \]
    2. Simplified0.05

      \[\leadsto \color{blue}{x + \frac{-1}{\mathsf{fma}\left(e^{z}, \frac{-1.1283791670955126}{y}, x\right)}} \]
      Proof

      [Start]12.02

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

      --rgt-identity [<=]12.02

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

      associate-+l- [=>]12.02

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

      sub-neg [=>]12.02

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

      +-lft-identity [<=]12.02

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

      sub0-neg [=>]12.02

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

      neg-mul-1 [=>]12.02

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

      distribute-lft-neg-in [=>]12.02

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

      +-lft-identity [=>]12.02

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

      associate-*r/ [=>]12.02

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

      sub-neg [=>]12.02

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

      +-commutative [=>]12.02

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

      neg-sub0 [=>]12.02

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

      associate-+l- [=>]12.02

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

      sub0-neg [=>]12.02

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

      neg-mul-1 [=>]12.02

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

      times-frac [=>]12.02

      \[ x + \color{blue}{\frac{--1}{-1} \cdot \frac{y}{x \cdot y - 1.1283791670955126 \cdot e^{z}}} \]
    3. Taylor expanded in x around inf 0

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

    if 0.0 < (exp.f64 z) < 1.00000000154999991

    1. Initial program 0.16

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

    if 1.00000000154999991 < (exp.f64 z)

    1. Initial program 5.52

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

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

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

      [Start]1

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

      *-commutative [=>]1

      \[ x + \frac{y}{\color{blue}{e^{z} \cdot 1.1283791670955126}} \]
    4. Applied egg-rr1

      \[\leadsto x + \color{blue}{\frac{0.8862269254527579}{e^{z}} \cdot y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.34

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

Alternatives

Alternative 1
Error0.53%
Cost19912
\[\begin{array}{l} \mathbf{if}\;e^{z} \leq 0:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;e^{z} \leq 1.00000000155:\\ \;\;\;\;x + \frac{y}{1.1283791670955126 - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{0.8862269254527579}{e^{z}}\\ \end{array} \]
Alternative 2
Error0.08%
Cost13376
\[x + \frac{-1}{\mathsf{fma}\left(e^{z}, \frac{-1.1283791670955126}{y}, x\right)} \]
Alternative 3
Error0.33%
Cost1608
\[\begin{array}{l} \mathbf{if}\;z \leq -130:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;z \leq 0.27:\\ \;\;\;\;x + \frac{y}{\frac{z \cdot \left(z \cdot 1.2732395447351628\right) + -1.2732395447351628}{-1.1283791670955126 + z \cdot 1.1283791670955126} - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error30.22%
Cost1380
\[\begin{array}{l} \mathbf{if}\;x \leq -1.75 \cdot 10^{-10}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-41}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;x \leq -9 \cdot 10^{-128}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-138}:\\ \;\;\;\;y \cdot 0.8862269254527579\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{-181}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.4 \cdot 10^{-205}:\\ \;\;\;\;y \cdot 0.8862269254527579\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-291}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-199}:\\ \;\;\;\;y \cdot 0.8862269254527579\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-17}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error31.49%
Cost1116
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{-10}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.3 \cdot 10^{-41}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{elif}\;x \leq -1 \cdot 10^{-50}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{y}{1.1283791670955126}\\ \mathbf{elif}\;x \leq -5.1 \cdot 10^{-183}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{-197}:\\ \;\;\;\;y \cdot 0.8862269254527579\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-16}:\\ \;\;\;\;\frac{-1}{x}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error15.98%
Cost1112
\[\begin{array}{l} t_0 := x - \frac{1}{x}\\ t_1 := x + \frac{y}{1.1283791670955126}\\ \mathbf{if}\;z \leq -2.3 \cdot 10^{-103}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.45 \cdot 10^{-207}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.1 \cdot 10^{-272}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{-62}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 10^{-55}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error0.33%
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -98:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;z \leq 0.27:\\ \;\;\;\;x + \frac{y}{\left(1.1283791670955126 + z \cdot 1.1283791670955126\right) - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error30.65%
Cost984
\[\begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{-128}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.6 \cdot 10^{-138}:\\ \;\;\;\;y \cdot 0.8862269254527579\\ \mathbf{elif}\;x \leq -9.8 \cdot 10^{-184}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-208}:\\ \;\;\;\;y \cdot 0.8862269254527579\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{-291}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.6 \cdot 10^{-185}:\\ \;\;\;\;y \cdot 0.8862269254527579\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error0.5%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -195:\\ \;\;\;\;x - \frac{1}{x}\\ \mathbf{elif}\;z \leq 0.27:\\ \;\;\;\;x + \frac{y}{1.1283791670955126 - x \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error31.22%
Cost64
\[x \]

Error

Reproduce?

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