NMSE Section 6.1 mentioned, A

Percentage Accurate: 74.2% → 99.8%
Time: 10.5s
Alternatives: 12
Speedup: 1.9×

Specification

?
\[\begin{array}{l} \\ \frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (/
  (-
   (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))
   (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x)))))
  2.0))
double code(double x, double eps) {
	return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
	return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps):
	return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps)
	return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0)
end
function tmp = code(x, eps)
	tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 12 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 74.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (/
  (-
   (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))
   (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x)))))
  2.0))
double code(double x, double eps) {
	return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
	return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps):
	return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps)
	return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0)
end
function tmp = code(x, eps)
	tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} t_0 := \left(x + 1\right) \cdot e^{-x}\\ \mathbf{if}\;eps\_m \leq 6.2 \cdot 10^{-5}:\\ \;\;\;\;\frac{t\_0 + t\_0}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x \cdot eps\_m} + e^{x \cdot \left(-eps\_m\right)}}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (let* ((t_0 (* (+ x 1.0) (exp (- x)))))
   (if (<= eps_m 6.2e-5)
     (/ (+ t_0 t_0) 2.0)
     (/ (+ (exp (* x eps_m)) (exp (* x (- eps_m)))) 2.0))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double t_0 = (x + 1.0) * exp(-x);
	double tmp;
	if (eps_m <= 6.2e-5) {
		tmp = (t_0 + t_0) / 2.0;
	} else {
		tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0;
	}
	return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x + 1.0d0) * exp(-x)
    if (eps_m <= 6.2d-5) then
        tmp = (t_0 + t_0) / 2.0d0
    else
        tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0d0
    end if
    code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	double t_0 = (x + 1.0) * Math.exp(-x);
	double tmp;
	if (eps_m <= 6.2e-5) {
		tmp = (t_0 + t_0) / 2.0;
	} else {
		tmp = (Math.exp((x * eps_m)) + Math.exp((x * -eps_m))) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	t_0 = (x + 1.0) * math.exp(-x)
	tmp = 0
	if eps_m <= 6.2e-5:
		tmp = (t_0 + t_0) / 2.0
	else:
		tmp = (math.exp((x * eps_m)) + math.exp((x * -eps_m))) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	t_0 = Float64(Float64(x + 1.0) * exp(Float64(-x)))
	tmp = 0.0
	if (eps_m <= 6.2e-5)
		tmp = Float64(Float64(t_0 + t_0) / 2.0);
	else
		tmp = Float64(Float64(exp(Float64(x * eps_m)) + exp(Float64(x * Float64(-eps_m)))) / 2.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	t_0 = (x + 1.0) * exp(-x);
	tmp = 0.0;
	if (eps_m <= 6.2e-5)
		tmp = (t_0 + t_0) / 2.0;
	else
		tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps$95$m, 6.2e-5], N[(N[(t$95$0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
t_0 := \left(x + 1\right) \cdot e^{-x}\\
\mathbf{if}\;eps\_m \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{t\_0 + t\_0}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + e^{x \cdot \left(-eps\_m\right)}}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eps < 6.20000000000000027e-5

    1. Initial program 62.1%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified62.1%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around 0 66.9%

      \[\leadsto \frac{\color{blue}{\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}}{2} \]
    5. Step-by-step derivation
      1. distribute-rgt1-in66.9%

        \[\leadsto \frac{\color{blue}{\left(x + 1\right) \cdot e^{-1 \cdot x}} - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}{2} \]
      2. mul-1-neg66.9%

        \[\leadsto \frac{\left(x + 1\right) \cdot e^{\color{blue}{-x}} - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}{2} \]
      3. distribute-lft-out66.9%

        \[\leadsto \frac{\left(x + 1\right) \cdot e^{-x} - \color{blue}{-1 \cdot \left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right)}}{2} \]
      4. distribute-rgt1-in67.5%

        \[\leadsto \frac{\left(x + 1\right) \cdot e^{-x} - -1 \cdot \color{blue}{\left(\left(x + 1\right) \cdot e^{-1 \cdot x}\right)}}{2} \]
      5. mul-1-neg67.5%

        \[\leadsto \frac{\left(x + 1\right) \cdot e^{-x} - -1 \cdot \left(\left(x + 1\right) \cdot e^{\color{blue}{-x}}\right)}{2} \]
    6. Simplified67.5%

      \[\leadsto \frac{\color{blue}{\left(x + 1\right) \cdot e^{-x} - -1 \cdot \left(\left(x + 1\right) \cdot e^{-x}\right)}}{2} \]

    if 6.20000000000000027e-5 < eps

    1. Initial program 99.9%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified99.9%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 100.0%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in eps around inf 100.0%

      \[\leadsto \frac{e^{\color{blue}{\varepsilon \cdot x}} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    6. Taylor expanded in eps around -inf 100.0%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{-1 \cdot e^{-1 \cdot \left(x \cdot \left(1 - -1 \cdot \varepsilon\right)\right)}}}{2} \]
    7. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{\left(-e^{-1 \cdot \left(x \cdot \left(1 - -1 \cdot \varepsilon\right)\right)}\right)}}{2} \]
      2. associate-*r*100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{\left(-1 \cdot x\right) \cdot \left(1 - -1 \cdot \varepsilon\right)}}\right)}{2} \]
      3. sub-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\left(-1 \cdot x\right) \cdot \color{blue}{\left(1 + \left(--1 \cdot \varepsilon\right)\right)}}\right)}{2} \]
      4. mul-1-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\left(-1 \cdot x\right) \cdot \left(1 + \left(-\color{blue}{\left(-\varepsilon\right)}\right)\right)}\right)}{2} \]
      5. remove-double-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\left(-1 \cdot x\right) \cdot \left(1 + \color{blue}{\varepsilon}\right)}\right)}{2} \]
      6. *-commutative100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{\left(x \cdot -1\right)} \cdot \left(1 + \varepsilon\right)}\right)}{2} \]
      7. associate-*l*100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{x \cdot \left(-1 \cdot \left(1 + \varepsilon\right)\right)}}\right)}{2} \]
      8. distribute-lft-in100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \color{blue}{\left(-1 \cdot 1 + -1 \cdot \varepsilon\right)}}\right)}{2} \]
      9. metadata-eval100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \left(\color{blue}{-1} + -1 \cdot \varepsilon\right)}\right)}{2} \]
      10. mul-1-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \left(-1 + \color{blue}{\left(-\varepsilon\right)}\right)}\right)}{2} \]
      11. unsub-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \color{blue}{\left(-1 - \varepsilon\right)}}\right)}{2} \]
    8. Simplified100.0%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{\left(-e^{x \cdot \left(-1 - \varepsilon\right)}\right)}}{2} \]
    9. Taylor expanded in eps around inf 100.0%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{-1 \cdot \left(\varepsilon \cdot x\right)}}\right)}{2} \]
    10. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{-\varepsilon \cdot x}}\right)}{2} \]
      2. distribute-lft-neg-out100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{\left(-\varepsilon\right) \cdot x}}\right)}{2} \]
      3. *-commutative100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{x \cdot \left(-\varepsilon\right)}}\right)}{2} \]
    11. Simplified100.0%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{x \cdot \left(-\varepsilon\right)}}\right)}{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq 6.2 \cdot 10^{-5}:\\ \;\;\;\;\frac{\left(x + 1\right) \cdot e^{-x} + \left(x + 1\right) \cdot e^{-x}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x \cdot \varepsilon} + e^{x \cdot \left(-\varepsilon\right)}}{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} t_0 := e^{-x}\\ \mathbf{if}\;eps\_m \leq 6.2 \cdot 10^{-5}:\\ \;\;\;\;\frac{t\_0 \cdot \left(\left(x + 1\right) + 1\right) + x \cdot t\_0}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x \cdot eps\_m} + e^{x \cdot \left(-eps\_m\right)}}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (let* ((t_0 (exp (- x))))
   (if (<= eps_m 6.2e-5)
     (/ (+ (* t_0 (+ (+ x 1.0) 1.0)) (* x t_0)) 2.0)
     (/ (+ (exp (* x eps_m)) (exp (* x (- eps_m)))) 2.0))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double t_0 = exp(-x);
	double tmp;
	if (eps_m <= 6.2e-5) {
		tmp = ((t_0 * ((x + 1.0) + 1.0)) + (x * t_0)) / 2.0;
	} else {
		tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0;
	}
	return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-x)
    if (eps_m <= 6.2d-5) then
        tmp = ((t_0 * ((x + 1.0d0) + 1.0d0)) + (x * t_0)) / 2.0d0
    else
        tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0d0
    end if
    code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	double t_0 = Math.exp(-x);
	double tmp;
	if (eps_m <= 6.2e-5) {
		tmp = ((t_0 * ((x + 1.0) + 1.0)) + (x * t_0)) / 2.0;
	} else {
		tmp = (Math.exp((x * eps_m)) + Math.exp((x * -eps_m))) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	t_0 = math.exp(-x)
	tmp = 0
	if eps_m <= 6.2e-5:
		tmp = ((t_0 * ((x + 1.0) + 1.0)) + (x * t_0)) / 2.0
	else:
		tmp = (math.exp((x * eps_m)) + math.exp((x * -eps_m))) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	t_0 = exp(Float64(-x))
	tmp = 0.0
	if (eps_m <= 6.2e-5)
		tmp = Float64(Float64(Float64(t_0 * Float64(Float64(x + 1.0) + 1.0)) + Float64(x * t_0)) / 2.0);
	else
		tmp = Float64(Float64(exp(Float64(x * eps_m)) + exp(Float64(x * Float64(-eps_m)))) / 2.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	t_0 = exp(-x);
	tmp = 0.0;
	if (eps_m <= 6.2e-5)
		tmp = ((t_0 * ((x + 1.0) + 1.0)) + (x * t_0)) / 2.0;
	else
		tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[eps$95$m, 6.2e-5], N[(N[(N[(t$95$0 * N[(N[(x + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;eps\_m \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{t\_0 \cdot \left(\left(x + 1\right) + 1\right) + x \cdot t\_0}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + e^{x \cdot \left(-eps\_m\right)}}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if eps < 6.20000000000000027e-5

    1. Initial program 62.1%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified62.1%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around 0 66.9%

      \[\leadsto \frac{\color{blue}{\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}}{2} \]
    5. Step-by-step derivation
      1. associate--r+66.9%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. associate-*r*66.9%

        \[\leadsto \frac{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - \color{blue}{\left(-1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      3. cancel-sign-sub-inv66.9%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      4. distribute-rgt1-in66.9%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right) \cdot e^{-1 \cdot x}} - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      5. distribute-rgt-out--67.5%

        \[\leadsto \frac{\color{blue}{e^{-1 \cdot x} \cdot \left(\left(x + 1\right) - -1\right)} + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      6. mul-1-neg67.5%

        \[\leadsto \frac{e^{\color{blue}{-x}} \cdot \left(\left(x + 1\right) - -1\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      7. mul-1-neg67.5%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \left(-\color{blue}{\left(-x\right)}\right) \cdot e^{-1 \cdot x}}{2} \]
      8. remove-double-neg67.5%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \color{blue}{x} \cdot e^{-1 \cdot x}}{2} \]
      9. mul-1-neg67.5%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{\color{blue}{-x}}}{2} \]
    6. Simplified67.5%

      \[\leadsto \frac{\color{blue}{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{-x}}}{2} \]

    if 6.20000000000000027e-5 < eps

    1. Initial program 99.9%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified99.9%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 100.0%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in eps around inf 100.0%

      \[\leadsto \frac{e^{\color{blue}{\varepsilon \cdot x}} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    6. Taylor expanded in eps around -inf 100.0%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{-1 \cdot e^{-1 \cdot \left(x \cdot \left(1 - -1 \cdot \varepsilon\right)\right)}}}{2} \]
    7. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{\left(-e^{-1 \cdot \left(x \cdot \left(1 - -1 \cdot \varepsilon\right)\right)}\right)}}{2} \]
      2. associate-*r*100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{\left(-1 \cdot x\right) \cdot \left(1 - -1 \cdot \varepsilon\right)}}\right)}{2} \]
      3. sub-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\left(-1 \cdot x\right) \cdot \color{blue}{\left(1 + \left(--1 \cdot \varepsilon\right)\right)}}\right)}{2} \]
      4. mul-1-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\left(-1 \cdot x\right) \cdot \left(1 + \left(-\color{blue}{\left(-\varepsilon\right)}\right)\right)}\right)}{2} \]
      5. remove-double-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\left(-1 \cdot x\right) \cdot \left(1 + \color{blue}{\varepsilon}\right)}\right)}{2} \]
      6. *-commutative100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{\left(x \cdot -1\right)} \cdot \left(1 + \varepsilon\right)}\right)}{2} \]
      7. associate-*l*100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{x \cdot \left(-1 \cdot \left(1 + \varepsilon\right)\right)}}\right)}{2} \]
      8. distribute-lft-in100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \color{blue}{\left(-1 \cdot 1 + -1 \cdot \varepsilon\right)}}\right)}{2} \]
      9. metadata-eval100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \left(\color{blue}{-1} + -1 \cdot \varepsilon\right)}\right)}{2} \]
      10. mul-1-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \left(-1 + \color{blue}{\left(-\varepsilon\right)}\right)}\right)}{2} \]
      11. unsub-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \color{blue}{\left(-1 - \varepsilon\right)}}\right)}{2} \]
    8. Simplified100.0%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{\left(-e^{x \cdot \left(-1 - \varepsilon\right)}\right)}}{2} \]
    9. Taylor expanded in eps around inf 100.0%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{-1 \cdot \left(\varepsilon \cdot x\right)}}\right)}{2} \]
    10. Step-by-step derivation
      1. mul-1-neg100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{-\varepsilon \cdot x}}\right)}{2} \]
      2. distribute-lft-neg-out100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{\left(-\varepsilon\right) \cdot x}}\right)}{2} \]
      3. *-commutative100.0%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{x \cdot \left(-\varepsilon\right)}}\right)}{2} \]
    11. Simplified100.0%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{x \cdot \left(-\varepsilon\right)}}\right)}{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \leq 6.2 \cdot 10^{-5}:\\ \;\;\;\;\frac{e^{-x} \cdot \left(\left(x + 1\right) + 1\right) + x \cdot e^{-x}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x \cdot \varepsilon} + e^{x \cdot \left(-\varepsilon\right)}}{2}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.4% accurate, 1.1× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 4.8 \cdot 10^{+127}:\\ \;\;\;\;\frac{e^{x \cdot eps\_m} + e^{x \cdot \left(-eps\_m\right)}}{2}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{-x}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= x 4.8e+127)
   (/ (+ (exp (* x eps_m)) (exp (* x (- eps_m)))) 2.0)
   (* x (exp (- x)))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (x <= 4.8e+127) {
		tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0;
	} else {
		tmp = x * exp(-x);
	}
	return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    real(8) :: tmp
    if (x <= 4.8d+127) then
        tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0d0
    else
        tmp = x * exp(-x)
    end if
    code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	double tmp;
	if (x <= 4.8e+127) {
		tmp = (Math.exp((x * eps_m)) + Math.exp((x * -eps_m))) / 2.0;
	} else {
		tmp = x * Math.exp(-x);
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if x <= 4.8e+127:
		tmp = (math.exp((x * eps_m)) + math.exp((x * -eps_m))) / 2.0
	else:
		tmp = x * math.exp(-x)
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (x <= 4.8e+127)
		tmp = Float64(Float64(exp(Float64(x * eps_m)) + exp(Float64(x * Float64(-eps_m)))) / 2.0);
	else
		tmp = Float64(x * exp(Float64(-x)));
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (x <= 4.8e+127)
		tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0;
	else
		tmp = x * exp(-x);
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[x, 4.8e+127], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(x * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.8 \cdot 10^{+127}:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + e^{x \cdot \left(-eps\_m\right)}}{2}\\

\mathbf{else}:\\
\;\;\;\;x \cdot e^{-x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4.8000000000000004e127

    1. Initial program 69.3%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified69.3%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 99.2%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in eps around inf 94.4%

      \[\leadsto \frac{e^{\color{blue}{\varepsilon \cdot x}} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    6. Taylor expanded in eps around -inf 94.4%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{-1 \cdot e^{-1 \cdot \left(x \cdot \left(1 - -1 \cdot \varepsilon\right)\right)}}}{2} \]
    7. Step-by-step derivation
      1. mul-1-neg94.4%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{\left(-e^{-1 \cdot \left(x \cdot \left(1 - -1 \cdot \varepsilon\right)\right)}\right)}}{2} \]
      2. associate-*r*94.4%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{\left(-1 \cdot x\right) \cdot \left(1 - -1 \cdot \varepsilon\right)}}\right)}{2} \]
      3. sub-neg94.4%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\left(-1 \cdot x\right) \cdot \color{blue}{\left(1 + \left(--1 \cdot \varepsilon\right)\right)}}\right)}{2} \]
      4. mul-1-neg94.4%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\left(-1 \cdot x\right) \cdot \left(1 + \left(-\color{blue}{\left(-\varepsilon\right)}\right)\right)}\right)}{2} \]
      5. remove-double-neg94.4%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\left(-1 \cdot x\right) \cdot \left(1 + \color{blue}{\varepsilon}\right)}\right)}{2} \]
      6. *-commutative94.4%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{\left(x \cdot -1\right)} \cdot \left(1 + \varepsilon\right)}\right)}{2} \]
      7. associate-*l*94.4%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{x \cdot \left(-1 \cdot \left(1 + \varepsilon\right)\right)}}\right)}{2} \]
      8. distribute-lft-in94.4%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \color{blue}{\left(-1 \cdot 1 + -1 \cdot \varepsilon\right)}}\right)}{2} \]
      9. metadata-eval94.4%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \left(\color{blue}{-1} + -1 \cdot \varepsilon\right)}\right)}{2} \]
      10. mul-1-neg94.4%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \left(-1 + \color{blue}{\left(-\varepsilon\right)}\right)}\right)}{2} \]
      11. unsub-neg94.4%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \color{blue}{\left(-1 - \varepsilon\right)}}\right)}{2} \]
    8. Simplified94.4%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{\left(-e^{x \cdot \left(-1 - \varepsilon\right)}\right)}}{2} \]
    9. Taylor expanded in eps around inf 94.5%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{-1 \cdot \left(\varepsilon \cdot x\right)}}\right)}{2} \]
    10. Step-by-step derivation
      1. mul-1-neg94.5%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{-\varepsilon \cdot x}}\right)}{2} \]
      2. distribute-lft-neg-out94.5%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{\left(-\varepsilon\right) \cdot x}}\right)}{2} \]
      3. *-commutative94.5%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{x \cdot \left(-\varepsilon\right)}}\right)}{2} \]
    11. Simplified94.5%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{x \cdot \left(-\varepsilon\right)}}\right)}{2} \]

    if 4.8000000000000004e127 < x

    1. Initial program 100.0%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around 0 60.6%

      \[\leadsto \frac{\color{blue}{\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}}{2} \]
    5. Step-by-step derivation
      1. associate--r+60.6%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. associate-*r*60.6%

        \[\leadsto \frac{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - \color{blue}{\left(-1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      3. cancel-sign-sub-inv60.6%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      4. distribute-rgt1-in60.6%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right) \cdot e^{-1 \cdot x}} - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      5. distribute-rgt-out--60.6%

        \[\leadsto \frac{\color{blue}{e^{-1 \cdot x} \cdot \left(\left(x + 1\right) - -1\right)} + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      6. mul-1-neg60.6%

        \[\leadsto \frac{e^{\color{blue}{-x}} \cdot \left(\left(x + 1\right) - -1\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      7. mul-1-neg60.6%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \left(-\color{blue}{\left(-x\right)}\right) \cdot e^{-1 \cdot x}}{2} \]
      8. remove-double-neg60.6%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \color{blue}{x} \cdot e^{-1 \cdot x}}{2} \]
      9. mul-1-neg60.6%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{\color{blue}{-x}}}{2} \]
    6. Simplified60.6%

      \[\leadsto \frac{\color{blue}{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{-x}}}{2} \]
    7. Taylor expanded in x around inf 60.6%

      \[\leadsto \color{blue}{x \cdot e^{-x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.8 \cdot 10^{+127}:\\ \;\;\;\;\frac{e^{x \cdot \varepsilon} + e^{x \cdot \left(-\varepsilon\right)}}{2}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{-x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 98.9% accurate, 1.1× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \frac{e^{x \cdot \left(-1 + eps\_m\right)} + e^{x \cdot \left(-1 - eps\_m\right)}}{2} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (/ (+ (exp (* x (+ -1.0 eps_m))) (exp (* x (- -1.0 eps_m)))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	return (exp((x * (-1.0 + eps_m))) + exp((x * (-1.0 - eps_m)))) / 2.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    code = (exp((x * ((-1.0d0) + eps_m))) + exp((x * ((-1.0d0) - eps_m)))) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	return (Math.exp((x * (-1.0 + eps_m))) + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	return (math.exp((x * (-1.0 + eps_m))) + math.exp((x * (-1.0 - eps_m)))) / 2.0
eps_m = abs(eps)
function code(x, eps_m)
	return Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0)
end
eps_m = abs(eps);
function tmp = code(x, eps_m)
	tmp = (exp((x * (-1.0 + eps_m))) + exp((x * (-1.0 - eps_m)))) / 2.0;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\frac{e^{x \cdot \left(-1 + eps\_m\right)} + e^{x \cdot \left(-1 - eps\_m\right)}}{2}
\end{array}
Derivation
  1. Initial program 73.5%

    \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
  2. Simplified73.5%

    \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
  3. Add Preprocessing
  4. Taylor expanded in eps around inf 99.3%

    \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
  5. Final simplification99.3%

    \[\leadsto \frac{e^{x \cdot \left(-1 + \varepsilon\right)} + e^{x \cdot \left(-1 - \varepsilon\right)}}{2} \]
  6. Add Preprocessing

Alternative 5: 84.7% accurate, 1.8× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} t_0 := e^{-x}\\ \mathbf{if}\;x \leq -10000000:\\ \;\;\;\;\frac{t\_0 + 1}{2}\\ \mathbf{elif}\;x \leq -1 \cdot 10^{-279}:\\ \;\;\;\;\frac{\left(x \cdot eps\_m + 1\right) + e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{+127}:\\ \;\;\;\;\frac{e^{x \cdot eps\_m} + 1}{2}\\ \mathbf{else}:\\ \;\;\;\;x \cdot t\_0\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (let* ((t_0 (exp (- x))))
   (if (<= x -10000000.0)
     (/ (+ t_0 1.0) 2.0)
     (if (<= x -1e-279)
       (/ (+ (+ (* x eps_m) 1.0) (exp (* x (- -1.0 eps_m)))) 2.0)
       (if (<= x 2.6e+127) (/ (+ (exp (* x eps_m)) 1.0) 2.0) (* x t_0))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double t_0 = exp(-x);
	double tmp;
	if (x <= -10000000.0) {
		tmp = (t_0 + 1.0) / 2.0;
	} else if (x <= -1e-279) {
		tmp = (((x * eps_m) + 1.0) + exp((x * (-1.0 - eps_m)))) / 2.0;
	} else if (x <= 2.6e+127) {
		tmp = (exp((x * eps_m)) + 1.0) / 2.0;
	} else {
		tmp = x * t_0;
	}
	return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-x)
    if (x <= (-10000000.0d0)) then
        tmp = (t_0 + 1.0d0) / 2.0d0
    else if (x <= (-1d-279)) then
        tmp = (((x * eps_m) + 1.0d0) + exp((x * ((-1.0d0) - eps_m)))) / 2.0d0
    else if (x <= 2.6d+127) then
        tmp = (exp((x * eps_m)) + 1.0d0) / 2.0d0
    else
        tmp = x * t_0
    end if
    code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	double t_0 = Math.exp(-x);
	double tmp;
	if (x <= -10000000.0) {
		tmp = (t_0 + 1.0) / 2.0;
	} else if (x <= -1e-279) {
		tmp = (((x * eps_m) + 1.0) + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
	} else if (x <= 2.6e+127) {
		tmp = (Math.exp((x * eps_m)) + 1.0) / 2.0;
	} else {
		tmp = x * t_0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	t_0 = math.exp(-x)
	tmp = 0
	if x <= -10000000.0:
		tmp = (t_0 + 1.0) / 2.0
	elif x <= -1e-279:
		tmp = (((x * eps_m) + 1.0) + math.exp((x * (-1.0 - eps_m)))) / 2.0
	elif x <= 2.6e+127:
		tmp = (math.exp((x * eps_m)) + 1.0) / 2.0
	else:
		tmp = x * t_0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	t_0 = exp(Float64(-x))
	tmp = 0.0
	if (x <= -10000000.0)
		tmp = Float64(Float64(t_0 + 1.0) / 2.0);
	elseif (x <= -1e-279)
		tmp = Float64(Float64(Float64(Float64(x * eps_m) + 1.0) + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0);
	elseif (x <= 2.6e+127)
		tmp = Float64(Float64(exp(Float64(x * eps_m)) + 1.0) / 2.0);
	else
		tmp = Float64(x * t_0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	t_0 = exp(-x);
	tmp = 0.0;
	if (x <= -10000000.0)
		tmp = (t_0 + 1.0) / 2.0;
	elseif (x <= -1e-279)
		tmp = (((x * eps_m) + 1.0) + exp((x * (-1.0 - eps_m)))) / 2.0;
	elseif (x <= 2.6e+127)
		tmp = (exp((x * eps_m)) + 1.0) / 2.0;
	else
		tmp = x * t_0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -10000000.0], N[(N[(t$95$0 + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1e-279], N[(N[(N[(N[(x * eps$95$m), $MachinePrecision] + 1.0), $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.6e+127], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -10000000:\\
\;\;\;\;\frac{t\_0 + 1}{2}\\

\mathbf{elif}\;x \leq -1 \cdot 10^{-279}:\\
\;\;\;\;\frac{\left(x \cdot eps\_m + 1\right) + e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\

\mathbf{elif}\;x \leq 2.6 \cdot 10^{+127}:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + 1}{2}\\

\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1e7

    1. Initial program 97.4%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified97.4%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 97.4%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in eps around inf 97.4%

      \[\leadsto \frac{e^{\color{blue}{\varepsilon \cdot x}} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    6. Taylor expanded in eps around 0 97.4%

      \[\leadsto \frac{\color{blue}{1 - -1 \cdot e^{-1 \cdot x}}}{2} \]
    7. Step-by-step derivation
      1. sub-neg97.4%

        \[\leadsto \frac{\color{blue}{1 + \left(--1 \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. mul-1-neg97.4%

        \[\leadsto \frac{1 + \left(-\color{blue}{\left(-e^{-1 \cdot x}\right)}\right)}{2} \]
      3. remove-double-neg97.4%

        \[\leadsto \frac{1 + \color{blue}{e^{-1 \cdot x}}}{2} \]
      4. neg-mul-197.4%

        \[\leadsto \frac{1 + e^{\color{blue}{-x}}}{2} \]
    8. Simplified97.4%

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

    if -1e7 < x < -1.00000000000000006e-279

    1. Initial program 52.4%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified52.4%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 98.9%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in eps around inf 98.9%

      \[\leadsto \frac{e^{\color{blue}{\varepsilon \cdot x}} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    6. Taylor expanded in eps around -inf 98.9%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{-1 \cdot e^{-1 \cdot \left(x \cdot \left(1 - -1 \cdot \varepsilon\right)\right)}}}{2} \]
    7. Step-by-step derivation
      1. mul-1-neg98.9%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{\left(-e^{-1 \cdot \left(x \cdot \left(1 - -1 \cdot \varepsilon\right)\right)}\right)}}{2} \]
      2. associate-*r*98.9%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{\left(-1 \cdot x\right) \cdot \left(1 - -1 \cdot \varepsilon\right)}}\right)}{2} \]
      3. sub-neg98.9%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\left(-1 \cdot x\right) \cdot \color{blue}{\left(1 + \left(--1 \cdot \varepsilon\right)\right)}}\right)}{2} \]
      4. mul-1-neg98.9%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\left(-1 \cdot x\right) \cdot \left(1 + \left(-\color{blue}{\left(-\varepsilon\right)}\right)\right)}\right)}{2} \]
      5. remove-double-neg98.9%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\left(-1 \cdot x\right) \cdot \left(1 + \color{blue}{\varepsilon}\right)}\right)}{2} \]
      6. *-commutative98.9%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{\left(x \cdot -1\right)} \cdot \left(1 + \varepsilon\right)}\right)}{2} \]
      7. associate-*l*98.9%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{\color{blue}{x \cdot \left(-1 \cdot \left(1 + \varepsilon\right)\right)}}\right)}{2} \]
      8. distribute-lft-in98.9%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \color{blue}{\left(-1 \cdot 1 + -1 \cdot \varepsilon\right)}}\right)}{2} \]
      9. metadata-eval98.9%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \left(\color{blue}{-1} + -1 \cdot \varepsilon\right)}\right)}{2} \]
      10. mul-1-neg98.9%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \left(-1 + \color{blue}{\left(-\varepsilon\right)}\right)}\right)}{2} \]
      11. unsub-neg98.9%

        \[\leadsto \frac{e^{\varepsilon \cdot x} - \left(-e^{x \cdot \color{blue}{\left(-1 - \varepsilon\right)}}\right)}{2} \]
    8. Simplified98.9%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{\left(-e^{x \cdot \left(-1 - \varepsilon\right)}\right)}}{2} \]
    9. Taylor expanded in eps around 0 85.2%

      \[\leadsto \frac{\color{blue}{\left(1 + \varepsilon \cdot x\right)} - \left(-e^{x \cdot \left(-1 - \varepsilon\right)}\right)}{2} \]

    if -1.00000000000000006e-279 < x < 2.6000000000000002e127

    1. Initial program 68.7%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified68.7%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 100.0%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in eps around inf 91.4%

      \[\leadsto \frac{e^{\color{blue}{\varepsilon \cdot x}} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    6. Taylor expanded in x around 0 71.2%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{-1}}{2} \]

    if 2.6000000000000002e127 < x

    1. Initial program 100.0%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around 0 60.6%

      \[\leadsto \frac{\color{blue}{\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}}{2} \]
    5. Step-by-step derivation
      1. associate--r+60.6%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. associate-*r*60.6%

        \[\leadsto \frac{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - \color{blue}{\left(-1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      3. cancel-sign-sub-inv60.6%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      4. distribute-rgt1-in60.6%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right) \cdot e^{-1 \cdot x}} - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      5. distribute-rgt-out--60.6%

        \[\leadsto \frac{\color{blue}{e^{-1 \cdot x} \cdot \left(\left(x + 1\right) - -1\right)} + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      6. mul-1-neg60.6%

        \[\leadsto \frac{e^{\color{blue}{-x}} \cdot \left(\left(x + 1\right) - -1\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      7. mul-1-neg60.6%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \left(-\color{blue}{\left(-x\right)}\right) \cdot e^{-1 \cdot x}}{2} \]
      8. remove-double-neg60.6%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \color{blue}{x} \cdot e^{-1 \cdot x}}{2} \]
      9. mul-1-neg60.6%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{\color{blue}{-x}}}{2} \]
    6. Simplified60.6%

      \[\leadsto \frac{\color{blue}{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{-x}}}{2} \]
    7. Taylor expanded in x around inf 60.6%

      \[\leadsto \color{blue}{x \cdot e^{-x}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification76.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -10000000:\\ \;\;\;\;\frac{e^{-x} + 1}{2}\\ \mathbf{elif}\;x \leq -1 \cdot 10^{-279}:\\ \;\;\;\;\frac{\left(x \cdot \varepsilon + 1\right) + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{+127}:\\ \;\;\;\;\frac{e^{x \cdot \varepsilon} + 1}{2}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{-x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 77.7% accurate, 1.9× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} t_0 := e^{-x}\\ \mathbf{if}\;x \leq -2 \cdot 10^{-280}:\\ \;\;\;\;\frac{t\_0 + 1}{2}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{+127}:\\ \;\;\;\;\frac{e^{x \cdot eps\_m} + 1}{2}\\ \mathbf{else}:\\ \;\;\;\;x \cdot t\_0\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (let* ((t_0 (exp (- x))))
   (if (<= x -2e-280)
     (/ (+ t_0 1.0) 2.0)
     (if (<= x 6e+127) (/ (+ (exp (* x eps_m)) 1.0) 2.0) (* x t_0)))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double t_0 = exp(-x);
	double tmp;
	if (x <= -2e-280) {
		tmp = (t_0 + 1.0) / 2.0;
	} else if (x <= 6e+127) {
		tmp = (exp((x * eps_m)) + 1.0) / 2.0;
	} else {
		tmp = x * t_0;
	}
	return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-x)
    if (x <= (-2d-280)) then
        tmp = (t_0 + 1.0d0) / 2.0d0
    else if (x <= 6d+127) then
        tmp = (exp((x * eps_m)) + 1.0d0) / 2.0d0
    else
        tmp = x * t_0
    end if
    code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	double t_0 = Math.exp(-x);
	double tmp;
	if (x <= -2e-280) {
		tmp = (t_0 + 1.0) / 2.0;
	} else if (x <= 6e+127) {
		tmp = (Math.exp((x * eps_m)) + 1.0) / 2.0;
	} else {
		tmp = x * t_0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	t_0 = math.exp(-x)
	tmp = 0
	if x <= -2e-280:
		tmp = (t_0 + 1.0) / 2.0
	elif x <= 6e+127:
		tmp = (math.exp((x * eps_m)) + 1.0) / 2.0
	else:
		tmp = x * t_0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	t_0 = exp(Float64(-x))
	tmp = 0.0
	if (x <= -2e-280)
		tmp = Float64(Float64(t_0 + 1.0) / 2.0);
	elseif (x <= 6e+127)
		tmp = Float64(Float64(exp(Float64(x * eps_m)) + 1.0) / 2.0);
	else
		tmp = Float64(x * t_0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	t_0 = exp(-x);
	tmp = 0.0;
	if (x <= -2e-280)
		tmp = (t_0 + 1.0) / 2.0;
	elseif (x <= 6e+127)
		tmp = (exp((x * eps_m)) + 1.0) / 2.0;
	else
		tmp = x * t_0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -2e-280], N[(N[(t$95$0 + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6e+127], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-280}:\\
\;\;\;\;\frac{t\_0 + 1}{2}\\

\mathbf{elif}\;x \leq 6 \cdot 10^{+127}:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + 1}{2}\\

\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.9999999999999999e-280

    1. Initial program 70.0%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified70.0%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 98.3%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in eps around inf 98.3%

      \[\leadsto \frac{e^{\color{blue}{\varepsilon \cdot x}} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    6. Taylor expanded in eps around 0 83.9%

      \[\leadsto \frac{\color{blue}{1 - -1 \cdot e^{-1 \cdot x}}}{2} \]
    7. Step-by-step derivation
      1. sub-neg83.9%

        \[\leadsto \frac{\color{blue}{1 + \left(--1 \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. mul-1-neg83.9%

        \[\leadsto \frac{1 + \left(-\color{blue}{\left(-e^{-1 \cdot x}\right)}\right)}{2} \]
      3. remove-double-neg83.9%

        \[\leadsto \frac{1 + \color{blue}{e^{-1 \cdot x}}}{2} \]
      4. neg-mul-183.9%

        \[\leadsto \frac{1 + e^{\color{blue}{-x}}}{2} \]
    8. Simplified83.9%

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

    if -1.9999999999999999e-280 < x < 6.0000000000000005e127

    1. Initial program 68.7%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified68.7%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 100.0%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in eps around inf 91.4%

      \[\leadsto \frac{e^{\color{blue}{\varepsilon \cdot x}} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    6. Taylor expanded in x around 0 71.2%

      \[\leadsto \frac{e^{\varepsilon \cdot x} - \color{blue}{-1}}{2} \]

    if 6.0000000000000005e127 < x

    1. Initial program 100.0%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around 0 60.6%

      \[\leadsto \frac{\color{blue}{\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}}{2} \]
    5. Step-by-step derivation
      1. associate--r+60.6%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. associate-*r*60.6%

        \[\leadsto \frac{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - \color{blue}{\left(-1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      3. cancel-sign-sub-inv60.6%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      4. distribute-rgt1-in60.6%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right) \cdot e^{-1 \cdot x}} - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      5. distribute-rgt-out--60.6%

        \[\leadsto \frac{\color{blue}{e^{-1 \cdot x} \cdot \left(\left(x + 1\right) - -1\right)} + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      6. mul-1-neg60.6%

        \[\leadsto \frac{e^{\color{blue}{-x}} \cdot \left(\left(x + 1\right) - -1\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      7. mul-1-neg60.6%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \left(-\color{blue}{\left(-x\right)}\right) \cdot e^{-1 \cdot x}}{2} \]
      8. remove-double-neg60.6%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \color{blue}{x} \cdot e^{-1 \cdot x}}{2} \]
      9. mul-1-neg60.6%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{\color{blue}{-x}}}{2} \]
    6. Simplified60.6%

      \[\leadsto \frac{\color{blue}{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{-x}}}{2} \]
    7. Taylor expanded in x around inf 60.6%

      \[\leadsto \color{blue}{x \cdot e^{-x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification74.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-280}:\\ \;\;\;\;\frac{e^{-x} + 1}{2}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{+127}:\\ \;\;\;\;\frac{e^{x \cdot \varepsilon} + 1}{2}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{-x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 63.8% accurate, 2.0× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-32}:\\ \;\;\;\;\frac{x \cdot \frac{1 - eps\_m \cdot eps\_m}{-1 + eps\_m}}{2}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+32}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333 - 0.5\right) + 1\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{-x}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= x -3.8e-32)
   (/ (* x (/ (- 1.0 (* eps_m eps_m)) (+ -1.0 eps_m))) 2.0)
   (if (<= x 1.5e+32)
     (+ (* (* x x) (- (* x 0.3333333333333333) 0.5)) 1.0)
     (* x (exp (- x))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (x <= -3.8e-32) {
		tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0;
	} else if (x <= 1.5e+32) {
		tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
	} else {
		tmp = x * exp(-x);
	}
	return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    real(8) :: tmp
    if (x <= (-3.8d-32)) then
        tmp = (x * ((1.0d0 - (eps_m * eps_m)) / ((-1.0d0) + eps_m))) / 2.0d0
    else if (x <= 1.5d+32) then
        tmp = ((x * x) * ((x * 0.3333333333333333d0) - 0.5d0)) + 1.0d0
    else
        tmp = x * exp(-x)
    end if
    code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	double tmp;
	if (x <= -3.8e-32) {
		tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0;
	} else if (x <= 1.5e+32) {
		tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
	} else {
		tmp = x * Math.exp(-x);
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if x <= -3.8e-32:
		tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0
	elif x <= 1.5e+32:
		tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0
	else:
		tmp = x * math.exp(-x)
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (x <= -3.8e-32)
		tmp = Float64(Float64(x * Float64(Float64(1.0 - Float64(eps_m * eps_m)) / Float64(-1.0 + eps_m))) / 2.0);
	elseif (x <= 1.5e+32)
		tmp = Float64(Float64(Float64(x * x) * Float64(Float64(x * 0.3333333333333333) - 0.5)) + 1.0);
	else
		tmp = Float64(x * exp(Float64(-x)));
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (x <= -3.8e-32)
		tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0;
	elseif (x <= 1.5e+32)
		tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
	else
		tmp = x * exp(-x);
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[x, -3.8e-32], N[(N[(x * N[(N[(1.0 - N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.5e+32], N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(x * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{-32}:\\
\;\;\;\;\frac{x \cdot \frac{1 - eps\_m \cdot eps\_m}{-1 + eps\_m}}{2}\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{+32}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333 - 0.5\right) + 1\\

\mathbf{else}:\\
\;\;\;\;x \cdot e^{-x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.80000000000000008e-32

    1. Initial program 95.2%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified95.2%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 96.0%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in x around 0 48.9%

      \[\leadsto \frac{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot \color{blue}{\left(1 + -1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)\right)}}{2} \]
    6. Taylor expanded in x around inf 28.9%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    7. Step-by-step derivation
      1. mul-1-neg28.9%

        \[\leadsto \frac{\color{blue}{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
      2. distribute-rgt-neg-in28.9%

        \[\leadsto \frac{\color{blue}{x \cdot \left(-\left(1 + \varepsilon\right)\right)}}{2} \]
      3. distribute-neg-in28.9%

        \[\leadsto \frac{x \cdot \color{blue}{\left(\left(-1\right) + \left(-\varepsilon\right)\right)}}{2} \]
      4. metadata-eval28.9%

        \[\leadsto \frac{x \cdot \left(\color{blue}{-1} + \left(-\varepsilon\right)\right)}{2} \]
      5. unsub-neg28.9%

        \[\leadsto \frac{x \cdot \color{blue}{\left(-1 - \varepsilon\right)}}{2} \]
    8. Simplified28.9%

      \[\leadsto \frac{\color{blue}{x \cdot \left(-1 - \varepsilon\right)}}{2} \]
    9. Step-by-step derivation
      1. sub-neg28.9%

        \[\leadsto \frac{x \cdot \color{blue}{\left(-1 + \left(-\varepsilon\right)\right)}}{2} \]
      2. flip-+37.6%

        \[\leadsto \frac{x \cdot \color{blue}{\frac{-1 \cdot -1 - \left(-\varepsilon\right) \cdot \left(-\varepsilon\right)}{-1 - \left(-\varepsilon\right)}}}{2} \]
      3. metadata-eval37.6%

        \[\leadsto \frac{x \cdot \frac{\color{blue}{1} - \left(-\varepsilon\right) \cdot \left(-\varepsilon\right)}{-1 - \left(-\varepsilon\right)}}{2} \]
    10. Applied egg-rr37.6%

      \[\leadsto \frac{x \cdot \color{blue}{\frac{1 - \left(-\varepsilon\right) \cdot \left(-\varepsilon\right)}{-1 - \left(-\varepsilon\right)}}}{2} \]

    if -3.80000000000000008e-32 < x < 1.5e32

    1. Initial program 56.3%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified56.3%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around 0 72.9%

      \[\leadsto \frac{\color{blue}{\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}}{2} \]
    5. Step-by-step derivation
      1. associate--r+72.9%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. associate-*r*72.9%

        \[\leadsto \frac{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - \color{blue}{\left(-1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      3. cancel-sign-sub-inv72.9%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      4. distribute-rgt1-in72.9%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right) \cdot e^{-1 \cdot x}} - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      5. distribute-rgt-out--72.9%

        \[\leadsto \frac{\color{blue}{e^{-1 \cdot x} \cdot \left(\left(x + 1\right) - -1\right)} + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      6. mul-1-neg72.9%

        \[\leadsto \frac{e^{\color{blue}{-x}} \cdot \left(\left(x + 1\right) - -1\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      7. mul-1-neg72.9%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \left(-\color{blue}{\left(-x\right)}\right) \cdot e^{-1 \cdot x}}{2} \]
      8. remove-double-neg72.9%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \color{blue}{x} \cdot e^{-1 \cdot x}}{2} \]
      9. mul-1-neg72.9%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{\color{blue}{-x}}}{2} \]
    6. Simplified72.9%

      \[\leadsto \frac{\color{blue}{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{-x}}}{2} \]
    7. Taylor expanded in x around 0 73.0%

      \[\leadsto \color{blue}{1 + {x}^{2} \cdot \left(0.3333333333333333 \cdot x - 0.5\right)} \]
    8. Step-by-step derivation
      1. unpow273.0%

        \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.3333333333333333 \cdot x - 0.5\right) \]
    9. Applied egg-rr73.0%

      \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.3333333333333333 \cdot x - 0.5\right) \]

    if 1.5e32 < x

    1. Initial program 100.0%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around 0 50.8%

      \[\leadsto \frac{\color{blue}{\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}}{2} \]
    5. Step-by-step derivation
      1. associate--r+50.8%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. associate-*r*50.8%

        \[\leadsto \frac{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - \color{blue}{\left(-1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      3. cancel-sign-sub-inv50.8%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      4. distribute-rgt1-in50.8%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right) \cdot e^{-1 \cdot x}} - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      5. distribute-rgt-out--50.8%

        \[\leadsto \frac{\color{blue}{e^{-1 \cdot x} \cdot \left(\left(x + 1\right) - -1\right)} + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      6. mul-1-neg50.8%

        \[\leadsto \frac{e^{\color{blue}{-x}} \cdot \left(\left(x + 1\right) - -1\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      7. mul-1-neg50.8%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \left(-\color{blue}{\left(-x\right)}\right) \cdot e^{-1 \cdot x}}{2} \]
      8. remove-double-neg50.8%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \color{blue}{x} \cdot e^{-1 \cdot x}}{2} \]
      9. mul-1-neg50.8%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{\color{blue}{-x}}}{2} \]
    6. Simplified50.8%

      \[\leadsto \frac{\color{blue}{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{-x}}}{2} \]
    7. Taylor expanded in x around inf 50.8%

      \[\leadsto \color{blue}{x \cdot e^{-x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification61.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-32}:\\ \;\;\;\;\frac{x \cdot \frac{1 - \varepsilon \cdot \varepsilon}{-1 + \varepsilon}}{2}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+32}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333 - 0.5\right) + 1\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{-x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 68.5% accurate, 2.0× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} t_0 := e^{-x}\\ \mathbf{if}\;x \leq 1.5 \cdot 10^{+32}:\\ \;\;\;\;\frac{t\_0 + 1}{2}\\ \mathbf{else}:\\ \;\;\;\;x \cdot t\_0\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (let* ((t_0 (exp (- x)))) (if (<= x 1.5e+32) (/ (+ t_0 1.0) 2.0) (* x t_0))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double t_0 = exp(-x);
	double tmp;
	if (x <= 1.5e+32) {
		tmp = (t_0 + 1.0) / 2.0;
	} else {
		tmp = x * t_0;
	}
	return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-x)
    if (x <= 1.5d+32) then
        tmp = (t_0 + 1.0d0) / 2.0d0
    else
        tmp = x * t_0
    end if
    code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	double t_0 = Math.exp(-x);
	double tmp;
	if (x <= 1.5e+32) {
		tmp = (t_0 + 1.0) / 2.0;
	} else {
		tmp = x * t_0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	t_0 = math.exp(-x)
	tmp = 0
	if x <= 1.5e+32:
		tmp = (t_0 + 1.0) / 2.0
	else:
		tmp = x * t_0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	t_0 = exp(Float64(-x))
	tmp = 0.0
	if (x <= 1.5e+32)
		tmp = Float64(Float64(t_0 + 1.0) / 2.0);
	else
		tmp = Float64(x * t_0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	t_0 = exp(-x);
	tmp = 0.0;
	if (x <= 1.5e+32)
		tmp = (t_0 + 1.0) / 2.0;
	else
		tmp = x * t_0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, 1.5e+32], N[(N[(t$95$0 + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq 1.5 \cdot 10^{+32}:\\
\;\;\;\;\frac{t\_0 + 1}{2}\\

\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.5e32

    1. Initial program 64.6%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified64.6%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 99.1%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in eps around inf 99.1%

      \[\leadsto \frac{e^{\color{blue}{\varepsilon \cdot x}} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    6. Taylor expanded in eps around 0 76.8%

      \[\leadsto \frac{\color{blue}{1 - -1 \cdot e^{-1 \cdot x}}}{2} \]
    7. Step-by-step derivation
      1. sub-neg76.8%

        \[\leadsto \frac{\color{blue}{1 + \left(--1 \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. mul-1-neg76.8%

        \[\leadsto \frac{1 + \left(-\color{blue}{\left(-e^{-1 \cdot x}\right)}\right)}{2} \]
      3. remove-double-neg76.8%

        \[\leadsto \frac{1 + \color{blue}{e^{-1 \cdot x}}}{2} \]
      4. neg-mul-176.8%

        \[\leadsto \frac{1 + e^{\color{blue}{-x}}}{2} \]
    8. Simplified76.8%

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

    if 1.5e32 < x

    1. Initial program 100.0%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around 0 50.8%

      \[\leadsto \frac{\color{blue}{\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}}{2} \]
    5. Step-by-step derivation
      1. associate--r+50.8%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. associate-*r*50.8%

        \[\leadsto \frac{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - \color{blue}{\left(-1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      3. cancel-sign-sub-inv50.8%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      4. distribute-rgt1-in50.8%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right) \cdot e^{-1 \cdot x}} - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      5. distribute-rgt-out--50.8%

        \[\leadsto \frac{\color{blue}{e^{-1 \cdot x} \cdot \left(\left(x + 1\right) - -1\right)} + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      6. mul-1-neg50.8%

        \[\leadsto \frac{e^{\color{blue}{-x}} \cdot \left(\left(x + 1\right) - -1\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      7. mul-1-neg50.8%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \left(-\color{blue}{\left(-x\right)}\right) \cdot e^{-1 \cdot x}}{2} \]
      8. remove-double-neg50.8%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \color{blue}{x} \cdot e^{-1 \cdot x}}{2} \]
      9. mul-1-neg50.8%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{\color{blue}{-x}}}{2} \]
    6. Simplified50.8%

      \[\leadsto \frac{\color{blue}{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{-x}}}{2} \]
    7. Taylor expanded in x around inf 50.8%

      \[\leadsto \color{blue}{x \cdot e^{-x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification70.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.5 \cdot 10^{+32}:\\ \;\;\;\;\frac{e^{-x} + 1}{2}\\ \mathbf{else}:\\ \;\;\;\;x \cdot e^{-x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 61.0% accurate, 12.6× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1.02 \cdot 10^{-29}:\\ \;\;\;\;\frac{x \cdot \frac{1 - eps\_m \cdot eps\_m}{-1 + eps\_m}}{2}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333 - 0.5\right) + 1\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= x -1.02e-29)
   (/ (* x (/ (- 1.0 (* eps_m eps_m)) (+ -1.0 eps_m))) 2.0)
   (+ (* (* x x) (- (* x 0.3333333333333333) 0.5)) 1.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (x <= -1.02e-29) {
		tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0;
	} else {
		tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
	}
	return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    real(8) :: tmp
    if (x <= (-1.02d-29)) then
        tmp = (x * ((1.0d0 - (eps_m * eps_m)) / ((-1.0d0) + eps_m))) / 2.0d0
    else
        tmp = ((x * x) * ((x * 0.3333333333333333d0) - 0.5d0)) + 1.0d0
    end if
    code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	double tmp;
	if (x <= -1.02e-29) {
		tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0;
	} else {
		tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if x <= -1.02e-29:
		tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0
	else:
		tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (x <= -1.02e-29)
		tmp = Float64(Float64(x * Float64(Float64(1.0 - Float64(eps_m * eps_m)) / Float64(-1.0 + eps_m))) / 2.0);
	else
		tmp = Float64(Float64(Float64(x * x) * Float64(Float64(x * 0.3333333333333333) - 0.5)) + 1.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (x <= -1.02e-29)
		tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0;
	else
		tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[x, -1.02e-29], N[(N[(x * N[(N[(1.0 - N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.02 \cdot 10^{-29}:\\
\;\;\;\;\frac{x \cdot \frac{1 - eps\_m \cdot eps\_m}{-1 + eps\_m}}{2}\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333 - 0.5\right) + 1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.01999999999999994e-29

    1. Initial program 95.2%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified95.2%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 96.0%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in x around 0 48.9%

      \[\leadsto \frac{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot \color{blue}{\left(1 + -1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)\right)}}{2} \]
    6. Taylor expanded in x around inf 28.9%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    7. Step-by-step derivation
      1. mul-1-neg28.9%

        \[\leadsto \frac{\color{blue}{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
      2. distribute-rgt-neg-in28.9%

        \[\leadsto \frac{\color{blue}{x \cdot \left(-\left(1 + \varepsilon\right)\right)}}{2} \]
      3. distribute-neg-in28.9%

        \[\leadsto \frac{x \cdot \color{blue}{\left(\left(-1\right) + \left(-\varepsilon\right)\right)}}{2} \]
      4. metadata-eval28.9%

        \[\leadsto \frac{x \cdot \left(\color{blue}{-1} + \left(-\varepsilon\right)\right)}{2} \]
      5. unsub-neg28.9%

        \[\leadsto \frac{x \cdot \color{blue}{\left(-1 - \varepsilon\right)}}{2} \]
    8. Simplified28.9%

      \[\leadsto \frac{\color{blue}{x \cdot \left(-1 - \varepsilon\right)}}{2} \]
    9. Step-by-step derivation
      1. sub-neg28.9%

        \[\leadsto \frac{x \cdot \color{blue}{\left(-1 + \left(-\varepsilon\right)\right)}}{2} \]
      2. flip-+37.6%

        \[\leadsto \frac{x \cdot \color{blue}{\frac{-1 \cdot -1 - \left(-\varepsilon\right) \cdot \left(-\varepsilon\right)}{-1 - \left(-\varepsilon\right)}}}{2} \]
      3. metadata-eval37.6%

        \[\leadsto \frac{x \cdot \frac{\color{blue}{1} - \left(-\varepsilon\right) \cdot \left(-\varepsilon\right)}{-1 - \left(-\varepsilon\right)}}{2} \]
    10. Applied egg-rr37.6%

      \[\leadsto \frac{x \cdot \color{blue}{\frac{1 - \left(-\varepsilon\right) \cdot \left(-\varepsilon\right)}{-1 - \left(-\varepsilon\right)}}}{2} \]

    if -1.01999999999999994e-29 < x

    1. Initial program 69.3%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified69.3%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around 0 66.3%

      \[\leadsto \frac{\color{blue}{\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}}{2} \]
    5. Step-by-step derivation
      1. associate--r+66.3%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. associate-*r*66.3%

        \[\leadsto \frac{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - \color{blue}{\left(-1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      3. cancel-sign-sub-inv66.3%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      4. distribute-rgt1-in66.3%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right) \cdot e^{-1 \cdot x}} - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      5. distribute-rgt-out--66.3%

        \[\leadsto \frac{\color{blue}{e^{-1 \cdot x} \cdot \left(\left(x + 1\right) - -1\right)} + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      6. mul-1-neg66.3%

        \[\leadsto \frac{e^{\color{blue}{-x}} \cdot \left(\left(x + 1\right) - -1\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      7. mul-1-neg66.3%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \left(-\color{blue}{\left(-x\right)}\right) \cdot e^{-1 \cdot x}}{2} \]
      8. remove-double-neg66.3%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \color{blue}{x} \cdot e^{-1 \cdot x}}{2} \]
      9. mul-1-neg66.3%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{\color{blue}{-x}}}{2} \]
    6. Simplified66.3%

      \[\leadsto \frac{\color{blue}{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{-x}}}{2} \]
    7. Taylor expanded in x around 0 60.7%

      \[\leadsto \color{blue}{1 + {x}^{2} \cdot \left(0.3333333333333333 \cdot x - 0.5\right)} \]
    8. Step-by-step derivation
      1. unpow260.7%

        \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.3333333333333333 \cdot x - 0.5\right) \]
    9. Applied egg-rr60.7%

      \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.3333333333333333 \cdot x - 0.5\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification57.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.02 \cdot 10^{-29}:\\ \;\;\;\;\frac{x \cdot \frac{1 - \varepsilon \cdot \varepsilon}{-1 + \varepsilon}}{2}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333 - 0.5\right) + 1\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 59.6% accurate, 14.2× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -14500000:\\ \;\;\;\;\frac{x \cdot \left(-1 - eps\_m\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333 - 0.5\right) + 1\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= x -14500000.0)
   (/ (* x (- -1.0 eps_m)) 2.0)
   (+ (* (* x x) (- (* x 0.3333333333333333) 0.5)) 1.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (x <= -14500000.0) {
		tmp = (x * (-1.0 - eps_m)) / 2.0;
	} else {
		tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
	}
	return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    real(8) :: tmp
    if (x <= (-14500000.0d0)) then
        tmp = (x * ((-1.0d0) - eps_m)) / 2.0d0
    else
        tmp = ((x * x) * ((x * 0.3333333333333333d0) - 0.5d0)) + 1.0d0
    end if
    code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	double tmp;
	if (x <= -14500000.0) {
		tmp = (x * (-1.0 - eps_m)) / 2.0;
	} else {
		tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if x <= -14500000.0:
		tmp = (x * (-1.0 - eps_m)) / 2.0
	else:
		tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (x <= -14500000.0)
		tmp = Float64(Float64(x * Float64(-1.0 - eps_m)) / 2.0);
	else
		tmp = Float64(Float64(Float64(x * x) * Float64(Float64(x * 0.3333333333333333) - 0.5)) + 1.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (x <= -14500000.0)
		tmp = (x * (-1.0 - eps_m)) / 2.0;
	else
		tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[x, -14500000.0], N[(N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -14500000:\\
\;\;\;\;\frac{x \cdot \left(-1 - eps\_m\right)}{2}\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333 - 0.5\right) + 1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.45e7

    1. Initial program 100.0%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 100.0%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in x around 0 50.4%

      \[\leadsto \frac{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot \color{blue}{\left(1 + -1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)\right)}}{2} \]
    6. Taylor expanded in x around inf 31.6%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    7. Step-by-step derivation
      1. mul-1-neg31.6%

        \[\leadsto \frac{\color{blue}{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
      2. distribute-rgt-neg-in31.6%

        \[\leadsto \frac{\color{blue}{x \cdot \left(-\left(1 + \varepsilon\right)\right)}}{2} \]
      3. distribute-neg-in31.6%

        \[\leadsto \frac{x \cdot \color{blue}{\left(\left(-1\right) + \left(-\varepsilon\right)\right)}}{2} \]
      4. metadata-eval31.6%

        \[\leadsto \frac{x \cdot \left(\color{blue}{-1} + \left(-\varepsilon\right)\right)}{2} \]
      5. unsub-neg31.6%

        \[\leadsto \frac{x \cdot \color{blue}{\left(-1 - \varepsilon\right)}}{2} \]
    8. Simplified31.6%

      \[\leadsto \frac{\color{blue}{x \cdot \left(-1 - \varepsilon\right)}}{2} \]

    if -1.45e7 < x

    1. Initial program 69.0%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified69.0%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around 0 65.6%

      \[\leadsto \frac{\color{blue}{\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}}{2} \]
    5. Step-by-step derivation
      1. associate--r+65.6%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. associate-*r*65.6%

        \[\leadsto \frac{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - \color{blue}{\left(-1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      3. cancel-sign-sub-inv65.6%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      4. distribute-rgt1-in65.6%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right) \cdot e^{-1 \cdot x}} - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      5. distribute-rgt-out--66.0%

        \[\leadsto \frac{\color{blue}{e^{-1 \cdot x} \cdot \left(\left(x + 1\right) - -1\right)} + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      6. mul-1-neg66.0%

        \[\leadsto \frac{e^{\color{blue}{-x}} \cdot \left(\left(x + 1\right) - -1\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      7. mul-1-neg66.0%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \left(-\color{blue}{\left(-x\right)}\right) \cdot e^{-1 \cdot x}}{2} \]
      8. remove-double-neg66.0%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \color{blue}{x} \cdot e^{-1 \cdot x}}{2} \]
      9. mul-1-neg66.0%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{\color{blue}{-x}}}{2} \]
    6. Simplified66.0%

      \[\leadsto \frac{\color{blue}{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{-x}}}{2} \]
    7. Taylor expanded in x around 0 60.0%

      \[\leadsto \color{blue}{1 + {x}^{2} \cdot \left(0.3333333333333333 \cdot x - 0.5\right)} \]
    8. Step-by-step derivation
      1. unpow260.0%

        \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.3333333333333333 \cdot x - 0.5\right) \]
    9. Applied egg-rr60.0%

      \[\leadsto 1 + \color{blue}{\left(x \cdot x\right)} \cdot \left(0.3333333333333333 \cdot x - 0.5\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -14500000:\\ \;\;\;\;\frac{x \cdot \left(-1 - \varepsilon\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333 - 0.5\right) + 1\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 50.2% accurate, 22.7× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;x \cdot \left(eps\_m \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= x -1.0) (* x (* eps_m -0.5)) 1.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (x <= -1.0) {
		tmp = x * (eps_m * -0.5);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    real(8) :: tmp
    if (x <= (-1.0d0)) then
        tmp = x * (eps_m * (-0.5d0))
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	double tmp;
	if (x <= -1.0) {
		tmp = x * (eps_m * -0.5);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if x <= -1.0:
		tmp = x * (eps_m * -0.5)
	else:
		tmp = 1.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (x <= -1.0)
		tmp = Float64(x * Float64(eps_m * -0.5));
	else
		tmp = 1.0;
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (x <= -1.0)
		tmp = x * (eps_m * -0.5);
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[x, -1.0], N[(x * N[(eps$95$m * -0.5), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;x \cdot \left(eps\_m \cdot -0.5\right)\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1

    1. Initial program 97.4%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified97.4%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around inf 97.4%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot e^{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}}{2} \]
    5. Taylor expanded in x around 0 49.1%

      \[\leadsto \frac{e^{-1 \cdot \left(x \cdot \left(1 - \varepsilon\right)\right)} - -1 \cdot \color{blue}{\left(1 + -1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)\right)}}{2} \]
    6. Taylor expanded in x around inf 30.7%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(x \cdot \left(1 + \varepsilon\right)\right)}}{2} \]
    7. Step-by-step derivation
      1. mul-1-neg30.7%

        \[\leadsto \frac{\color{blue}{-x \cdot \left(1 + \varepsilon\right)}}{2} \]
      2. distribute-rgt-neg-in30.7%

        \[\leadsto \frac{\color{blue}{x \cdot \left(-\left(1 + \varepsilon\right)\right)}}{2} \]
      3. distribute-neg-in30.7%

        \[\leadsto \frac{x \cdot \color{blue}{\left(\left(-1\right) + \left(-\varepsilon\right)\right)}}{2} \]
      4. metadata-eval30.7%

        \[\leadsto \frac{x \cdot \left(\color{blue}{-1} + \left(-\varepsilon\right)\right)}{2} \]
      5. unsub-neg30.7%

        \[\leadsto \frac{x \cdot \color{blue}{\left(-1 - \varepsilon\right)}}{2} \]
    8. Simplified30.7%

      \[\leadsto \frac{\color{blue}{x \cdot \left(-1 - \varepsilon\right)}}{2} \]
    9. Taylor expanded in eps around inf 30.8%

      \[\leadsto \color{blue}{-0.5 \cdot \left(\varepsilon \cdot x\right)} \]
    10. Step-by-step derivation
      1. *-commutative30.8%

        \[\leadsto -0.5 \cdot \color{blue}{\left(x \cdot \varepsilon\right)} \]
      2. associate-*r*30.8%

        \[\leadsto \color{blue}{\left(-0.5 \cdot x\right) \cdot \varepsilon} \]
      3. *-commutative30.8%

        \[\leadsto \color{blue}{\left(x \cdot -0.5\right)} \cdot \varepsilon \]
      4. associate-*l*30.8%

        \[\leadsto \color{blue}{x \cdot \left(-0.5 \cdot \varepsilon\right)} \]
    11. Simplified30.8%

      \[\leadsto \color{blue}{x \cdot \left(-0.5 \cdot \varepsilon\right)} \]

    if -1 < x

    1. Initial program 69.3%

      \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
    2. Simplified69.3%

      \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
    3. Add Preprocessing
    4. Taylor expanded in eps around 0 65.9%

      \[\leadsto \frac{\color{blue}{\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}}{2} \]
    5. Step-by-step derivation
      1. associate--r+65.9%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)}}{2} \]
      2. associate-*r*65.9%

        \[\leadsto \frac{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - \color{blue}{\left(-1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      3. cancel-sign-sub-inv65.9%

        \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
      4. distribute-rgt1-in65.9%

        \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right) \cdot e^{-1 \cdot x}} - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      5. distribute-rgt-out--65.9%

        \[\leadsto \frac{\color{blue}{e^{-1 \cdot x} \cdot \left(\left(x + 1\right) - -1\right)} + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      6. mul-1-neg65.9%

        \[\leadsto \frac{e^{\color{blue}{-x}} \cdot \left(\left(x + 1\right) - -1\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
      7. mul-1-neg65.9%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \left(-\color{blue}{\left(-x\right)}\right) \cdot e^{-1 \cdot x}}{2} \]
      8. remove-double-neg65.9%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \color{blue}{x} \cdot e^{-1 \cdot x}}{2} \]
      9. mul-1-neg65.9%

        \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{\color{blue}{-x}}}{2} \]
    6. Simplified65.9%

      \[\leadsto \frac{\color{blue}{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{-x}}}{2} \]
    7. Taylor expanded in x around 0 51.7%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;x \cdot \left(\varepsilon \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 42.9% accurate, 227.0× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ 1 \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m) :precision binary64 1.0)
eps_m = fabs(eps);
double code(double x, double eps_m) {
	return 1.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps_m
    code = 1.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
	return 1.0;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	return 1.0
eps_m = abs(eps)
function code(x, eps_m)
	return 1.0
end
eps_m = abs(eps);
function tmp = code(x, eps_m)
	tmp = 1.0;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := 1.0
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
1
\end{array}
Derivation
  1. Initial program 73.5%

    \[\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2} \]
  2. Simplified73.5%

    \[\leadsto \color{blue}{\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{\left(1 - \varepsilon\right) \cdot \left(-x\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{\left(1 + \varepsilon\right) \cdot \left(-x\right)}}{2}} \]
  3. Add Preprocessing
  4. Taylor expanded in eps around 0 56.1%

    \[\leadsto \frac{\color{blue}{\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - \left(-1 \cdot e^{-1 \cdot x} + -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)\right)}}{2} \]
  5. Step-by-step derivation
    1. associate--r+56.1%

      \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - -1 \cdot \left(x \cdot e^{-1 \cdot x}\right)}}{2} \]
    2. associate-*r*56.1%

      \[\leadsto \frac{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) - \color{blue}{\left(-1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
    3. cancel-sign-sub-inv56.1%

      \[\leadsto \frac{\color{blue}{\left(\left(e^{-1 \cdot x} + x \cdot e^{-1 \cdot x}\right) - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}}{2} \]
    4. distribute-rgt1-in56.1%

      \[\leadsto \frac{\left(\color{blue}{\left(x + 1\right) \cdot e^{-1 \cdot x}} - -1 \cdot e^{-1 \cdot x}\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
    5. distribute-rgt-out--56.5%

      \[\leadsto \frac{\color{blue}{e^{-1 \cdot x} \cdot \left(\left(x + 1\right) - -1\right)} + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
    6. mul-1-neg56.5%

      \[\leadsto \frac{e^{\color{blue}{-x}} \cdot \left(\left(x + 1\right) - -1\right) + \left(--1 \cdot x\right) \cdot e^{-1 \cdot x}}{2} \]
    7. mul-1-neg56.5%

      \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \left(-\color{blue}{\left(-x\right)}\right) \cdot e^{-1 \cdot x}}{2} \]
    8. remove-double-neg56.5%

      \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + \color{blue}{x} \cdot e^{-1 \cdot x}}{2} \]
    9. mul-1-neg56.5%

      \[\leadsto \frac{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{\color{blue}{-x}}}{2} \]
  6. Simplified56.5%

    \[\leadsto \frac{\color{blue}{e^{-x} \cdot \left(\left(x + 1\right) - -1\right) + x \cdot e^{-x}}}{2} \]
  7. Taylor expanded in x around 0 44.5%

    \[\leadsto \color{blue}{1} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2024181 
(FPCore (x eps)
  :name "NMSE Section 6.1 mentioned, A"
  :precision binary64
  (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))