NMSE Section 6.1 mentioned, A

Percentage Accurate: 73.4% → 98.8%
Time: 18.4s
Alternatives: 18
Speedup: 2.0×

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 18 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: 73.4% 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: 98.8% accurate, 0.7× speedup?

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

\\
\frac{e^{x \cdot \left(eps_m + -1\right)} + \frac{1}{e^{\mathsf{fma}\left(eps_m, x, x\right)}}}{2}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 2: 98.8% accurate, 1.1× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \frac{e^{x \cdot \left(eps_m + -1\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 (+ eps_m -1.0))) (exp (* x (- -1.0 eps_m)))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	return (exp((x * (eps_m + -1.0))) + 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 * (eps_m + (-1.0d0)))) + 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 * (eps_m + -1.0))) + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	return (math.exp((x * (eps_m + -1.0))) + 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(eps_m + -1.0))) + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0)
end
eps_m = abs(eps);
function tmp = code(x, eps_m)
	tmp = (exp((x * (eps_m + -1.0))) + 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[(eps$95$m + -1.0), $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(eps_m + -1\right)} + e^{x \cdot \left(-1 - eps_m\right)}}{2}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 3: 98.2% accurate, 1.1× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} t_0 := e^{x \cdot \left(eps_m + -1\right)}\\ \mathbf{if}\;x \leq -3.7 \cdot 10^{-255}:\\ \;\;\;\;\frac{1 + \frac{1}{e^{\mathsf{fma}\left(eps_m, x, x\right)}}}{2}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-5}:\\ \;\;\;\;\frac{t_0 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (let* ((t_0 (exp (* x (+ eps_m -1.0)))))
   (if (<= x -3.7e-255)
     (/ (+ 1.0 (/ 1.0 (exp (fma eps_m x x)))) 2.0)
     (if (<= x 6.2e-5)
       (/ (+ t_0 (+ 1.0 (* x (- -1.0 eps_m)))) 2.0)
       (/ t_0 2.0)))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double t_0 = exp((x * (eps_m + -1.0)));
	double tmp;
	if (x <= -3.7e-255) {
		tmp = (1.0 + (1.0 / exp(fma(eps_m, x, x)))) / 2.0;
	} else if (x <= 6.2e-5) {
		tmp = (t_0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
	} else {
		tmp = t_0 / 2.0;
	}
	return tmp;
}
eps_m = abs(eps)
function code(x, eps_m)
	t_0 = exp(Float64(x * Float64(eps_m + -1.0)))
	tmp = 0.0
	if (x <= -3.7e-255)
		tmp = Float64(Float64(1.0 + Float64(1.0 / exp(fma(eps_m, x, x)))) / 2.0);
	elseif (x <= 6.2e-5)
		tmp = Float64(Float64(t_0 + Float64(1.0 + Float64(x * Float64(-1.0 - eps_m)))) / 2.0);
	else
		tmp = Float64(t_0 / 2.0);
	end
	return tmp
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3.7e-255], N[(N[(1.0 + N[(1.0 / N[Exp[N[(eps$95$m * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.2e-5], N[(N[(t$95$0 + N[(1.0 + N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
t_0 := e^{x \cdot \left(eps_m + -1\right)}\\
\mathbf{if}\;x \leq -3.7 \cdot 10^{-255}:\\
\;\;\;\;\frac{1 + \frac{1}{e^{\mathsf{fma}\left(eps_m, x, x\right)}}}{2}\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{t_0 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 4: 91.8% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_0 := e^{x \cdot \left(eps_m + -1\right)}\\
\mathbf{if}\;x \leq -27000:\\
\;\;\;\;\frac{\frac{e^{-x}}{eps_m}}{2}\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{t_0 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 5: 98.2% accurate, 1.9× speedup?

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

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

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

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{1 + t_0}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 6: 91.3% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
t_0 := e^{x \cdot \left(eps_m + -1\right)}\\
\mathbf{if}\;x \leq -59000000:\\
\;\;\;\;\frac{\frac{e^{-x}}{eps_m}}{2}\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{1 + t_0}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 7: 84.8% accurate, 2.0× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -59000000:\\ \;\;\;\;\frac{\frac{e^{-x}}{eps_m}}{2}\\ \mathbf{elif}\;x \leq 1.12 \cdot 10^{-99}:\\ \;\;\;\;\frac{\left(x + 1\right) - \left(x + -1\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x \cdot \left(eps_m + -1\right)}}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= x -59000000.0)
   (/ (/ (exp (- x)) eps_m) 2.0)
   (if (<= x 1.12e-99)
     (/ (- (+ x 1.0) (+ x -1.0)) 2.0)
     (/ (exp (* x (+ eps_m -1.0))) 2.0))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (x <= -59000000.0) {
		tmp = (exp(-x) / eps_m) / 2.0;
	} else if (x <= 1.12e-99) {
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	} else {
		tmp = exp((x * (eps_m + -1.0))) / 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) :: tmp
    if (x <= (-59000000.0d0)) then
        tmp = (exp(-x) / eps_m) / 2.0d0
    else if (x <= 1.12d-99) then
        tmp = ((x + 1.0d0) - (x + (-1.0d0))) / 2.0d0
    else
        tmp = exp((x * (eps_m + (-1.0d0)))) / 2.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 <= -59000000.0) {
		tmp = (Math.exp(-x) / eps_m) / 2.0;
	} else if (x <= 1.12e-99) {
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	} else {
		tmp = Math.exp((x * (eps_m + -1.0))) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if x <= -59000000.0:
		tmp = (math.exp(-x) / eps_m) / 2.0
	elif x <= 1.12e-99:
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0
	else:
		tmp = math.exp((x * (eps_m + -1.0))) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (x <= -59000000.0)
		tmp = Float64(Float64(exp(Float64(-x)) / eps_m) / 2.0);
	elseif (x <= 1.12e-99)
		tmp = Float64(Float64(Float64(x + 1.0) - Float64(x + -1.0)) / 2.0);
	else
		tmp = Float64(exp(Float64(x * Float64(eps_m + -1.0))) / 2.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (x <= -59000000.0)
		tmp = (exp(-x) / eps_m) / 2.0;
	elseif (x <= 1.12e-99)
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	else
		tmp = exp((x * (eps_m + -1.0))) / 2.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[x, -59000000.0], N[(N[(N[Exp[(-x)], $MachinePrecision] / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.12e-99], N[(N[(N[(x + 1.0), $MachinePrecision] - N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -59000000:\\
\;\;\;\;\frac{\frac{e^{-x}}{eps_m}}{2}\\

\mathbf{elif}\;x \leq 1.12 \cdot 10^{-99}:\\
\;\;\;\;\frac{\left(x + 1\right) - \left(x + -1\right)}{2}\\

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


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 8: 70.4% accurate, 2.1× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} t_0 := 1 + \frac{-1}{eps_m}\\ t_1 := 1 + \frac{1}{eps_m}\\ t_2 := 1 - x \cdot \left(1 - eps_m\right)\\ t_3 := \frac{t_1 \cdot t_2 + t_2 \cdot t_0}{2}\\ t_4 := \frac{\left(x + 1\right) - \left(x + -1\right)}{2}\\ \mathbf{if}\;x \leq -59000000:\\ \;\;\;\;\frac{\frac{e^{-x}}{eps_m}}{2}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-5}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq 9 \cdot 10^{+144}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{+200}:\\ \;\;\;\;\frac{t_1 + t_0}{2}\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{+241}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{+277}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot eps_m}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (let* ((t_0 (+ 1.0 (/ -1.0 eps_m)))
        (t_1 (+ 1.0 (/ 1.0 eps_m)))
        (t_2 (- 1.0 (* x (- 1.0 eps_m))))
        (t_3 (/ (+ (* t_1 t_2) (* t_2 t_0)) 2.0))
        (t_4 (/ (- (+ x 1.0) (+ x -1.0)) 2.0)))
   (if (<= x -59000000.0)
     (/ (/ (exp (- x)) eps_m) 2.0)
     (if (<= x 6.2e-5)
       t_4
       (if (<= x 9e+144)
         t_3
         (if (<= x 3.6e+200)
           (/ (+ t_1 t_0) 2.0)
           (if (<= x 8.2e+241)
             t_3
             (if (<= x 6.2e+277) t_4 (/ (* x eps_m) 2.0)))))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double t_0 = 1.0 + (-1.0 / eps_m);
	double t_1 = 1.0 + (1.0 / eps_m);
	double t_2 = 1.0 - (x * (1.0 - eps_m));
	double t_3 = ((t_1 * t_2) + (t_2 * t_0)) / 2.0;
	double t_4 = ((x + 1.0) - (x + -1.0)) / 2.0;
	double tmp;
	if (x <= -59000000.0) {
		tmp = (exp(-x) / eps_m) / 2.0;
	} else if (x <= 6.2e-5) {
		tmp = t_4;
	} else if (x <= 9e+144) {
		tmp = t_3;
	} else if (x <= 3.6e+200) {
		tmp = (t_1 + t_0) / 2.0;
	} else if (x <= 8.2e+241) {
		tmp = t_3;
	} else if (x <= 6.2e+277) {
		tmp = t_4;
	} else {
		tmp = (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) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: t_4
    real(8) :: tmp
    t_0 = 1.0d0 + ((-1.0d0) / eps_m)
    t_1 = 1.0d0 + (1.0d0 / eps_m)
    t_2 = 1.0d0 - (x * (1.0d0 - eps_m))
    t_3 = ((t_1 * t_2) + (t_2 * t_0)) / 2.0d0
    t_4 = ((x + 1.0d0) - (x + (-1.0d0))) / 2.0d0
    if (x <= (-59000000.0d0)) then
        tmp = (exp(-x) / eps_m) / 2.0d0
    else if (x <= 6.2d-5) then
        tmp = t_4
    else if (x <= 9d+144) then
        tmp = t_3
    else if (x <= 3.6d+200) then
        tmp = (t_1 + t_0) / 2.0d0
    else if (x <= 8.2d+241) then
        tmp = t_3
    else if (x <= 6.2d+277) then
        tmp = t_4
    else
        tmp = (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 = 1.0 + (-1.0 / eps_m);
	double t_1 = 1.0 + (1.0 / eps_m);
	double t_2 = 1.0 - (x * (1.0 - eps_m));
	double t_3 = ((t_1 * t_2) + (t_2 * t_0)) / 2.0;
	double t_4 = ((x + 1.0) - (x + -1.0)) / 2.0;
	double tmp;
	if (x <= -59000000.0) {
		tmp = (Math.exp(-x) / eps_m) / 2.0;
	} else if (x <= 6.2e-5) {
		tmp = t_4;
	} else if (x <= 9e+144) {
		tmp = t_3;
	} else if (x <= 3.6e+200) {
		tmp = (t_1 + t_0) / 2.0;
	} else if (x <= 8.2e+241) {
		tmp = t_3;
	} else if (x <= 6.2e+277) {
		tmp = t_4;
	} else {
		tmp = (x * eps_m) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	t_0 = 1.0 + (-1.0 / eps_m)
	t_1 = 1.0 + (1.0 / eps_m)
	t_2 = 1.0 - (x * (1.0 - eps_m))
	t_3 = ((t_1 * t_2) + (t_2 * t_0)) / 2.0
	t_4 = ((x + 1.0) - (x + -1.0)) / 2.0
	tmp = 0
	if x <= -59000000.0:
		tmp = (math.exp(-x) / eps_m) / 2.0
	elif x <= 6.2e-5:
		tmp = t_4
	elif x <= 9e+144:
		tmp = t_3
	elif x <= 3.6e+200:
		tmp = (t_1 + t_0) / 2.0
	elif x <= 8.2e+241:
		tmp = t_3
	elif x <= 6.2e+277:
		tmp = t_4
	else:
		tmp = (x * eps_m) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	t_0 = Float64(1.0 + Float64(-1.0 / eps_m))
	t_1 = Float64(1.0 + Float64(1.0 / eps_m))
	t_2 = Float64(1.0 - Float64(x * Float64(1.0 - eps_m)))
	t_3 = Float64(Float64(Float64(t_1 * t_2) + Float64(t_2 * t_0)) / 2.0)
	t_4 = Float64(Float64(Float64(x + 1.0) - Float64(x + -1.0)) / 2.0)
	tmp = 0.0
	if (x <= -59000000.0)
		tmp = Float64(Float64(exp(Float64(-x)) / eps_m) / 2.0);
	elseif (x <= 6.2e-5)
		tmp = t_4;
	elseif (x <= 9e+144)
		tmp = t_3;
	elseif (x <= 3.6e+200)
		tmp = Float64(Float64(t_1 + t_0) / 2.0);
	elseif (x <= 8.2e+241)
		tmp = t_3;
	elseif (x <= 6.2e+277)
		tmp = t_4;
	else
		tmp = Float64(Float64(x * eps_m) / 2.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	t_0 = 1.0 + (-1.0 / eps_m);
	t_1 = 1.0 + (1.0 / eps_m);
	t_2 = 1.0 - (x * (1.0 - eps_m));
	t_3 = ((t_1 * t_2) + (t_2 * t_0)) / 2.0;
	t_4 = ((x + 1.0) - (x + -1.0)) / 2.0;
	tmp = 0.0;
	if (x <= -59000000.0)
		tmp = (exp(-x) / eps_m) / 2.0;
	elseif (x <= 6.2e-5)
		tmp = t_4;
	elseif (x <= 9e+144)
		tmp = t_3;
	elseif (x <= 3.6e+200)
		tmp = (t_1 + t_0) / 2.0;
	elseif (x <= 8.2e+241)
		tmp = t_3;
	elseif (x <= 6.2e+277)
		tmp = t_4;
	else
		tmp = (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[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(t$95$1 * t$95$2), $MachinePrecision] + N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(x + 1.0), $MachinePrecision] - N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, -59000000.0], N[(N[(N[Exp[(-x)], $MachinePrecision] / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.2e-5], t$95$4, If[LessEqual[x, 9e+144], t$95$3, If[LessEqual[x, 3.6e+200], N[(N[(t$95$1 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 8.2e+241], t$95$3, If[LessEqual[x, 6.2e+277], t$95$4, N[(N[(x * eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
t_0 := 1 + \frac{-1}{eps_m}\\
t_1 := 1 + \frac{1}{eps_m}\\
t_2 := 1 - x \cdot \left(1 - eps_m\right)\\
t_3 := \frac{t_1 \cdot t_2 + t_2 \cdot t_0}{2}\\
t_4 := \frac{\left(x + 1\right) - \left(x + -1\right)}{2}\\
\mathbf{if}\;x \leq -59000000:\\
\;\;\;\;\frac{\frac{e^{-x}}{eps_m}}{2}\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;t_4\\

\mathbf{elif}\;x \leq 9 \cdot 10^{+144}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;x \leq 3.6 \cdot 10^{+200}:\\
\;\;\;\;\frac{t_1 + t_0}{2}\\

\mathbf{elif}\;x \leq 8.2 \cdot 10^{+241}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{+277}:\\
\;\;\;\;t_4\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps_m}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 9: 63.2% accurate, 6.9× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} t_0 := 1 - x \cdot \left(1 - eps_m\right)\\ \mathbf{if}\;eps_m \leq 1.76 \cdot 10^{-6}:\\ \;\;\;\;\frac{\left(x + 1\right) - \left(x + -1\right)}{2}\\ \mathbf{elif}\;eps_m \leq 4.8 \cdot 10^{+205}:\\ \;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) \cdot t_0 + t_0 \cdot \left(1 + \frac{-1}{eps_m}\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (let* ((t_0 (- 1.0 (* x (- 1.0 eps_m)))))
   (if (<= eps_m 1.76e-6)
     (/ (- (+ x 1.0) (+ x -1.0)) 2.0)
     (if (<= eps_m 4.8e+205)
       (/ (+ (* (+ 1.0 (/ 1.0 eps_m)) t_0) (* t_0 (+ 1.0 (/ -1.0 eps_m)))) 2.0)
       (/ (+ 1.0 (+ 1.0 (* x (- -1.0 eps_m)))) 2.0)))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double t_0 = 1.0 - (x * (1.0 - eps_m));
	double tmp;
	if (eps_m <= 1.76e-6) {
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	} else if (eps_m <= 4.8e+205) {
		tmp = (((1.0 + (1.0 / eps_m)) * t_0) + (t_0 * (1.0 + (-1.0 / eps_m)))) / 2.0;
	} else {
		tmp = (1.0 + (1.0 + (x * (-1.0 - 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 = 1.0d0 - (x * (1.0d0 - eps_m))
    if (eps_m <= 1.76d-6) then
        tmp = ((x + 1.0d0) - (x + (-1.0d0))) / 2.0d0
    else if (eps_m <= 4.8d+205) then
        tmp = (((1.0d0 + (1.0d0 / eps_m)) * t_0) + (t_0 * (1.0d0 + ((-1.0d0) / eps_m)))) / 2.0d0
    else
        tmp = (1.0d0 + (1.0d0 + (x * ((-1.0d0) - 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 = 1.0 - (x * (1.0 - eps_m));
	double tmp;
	if (eps_m <= 1.76e-6) {
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	} else if (eps_m <= 4.8e+205) {
		tmp = (((1.0 + (1.0 / eps_m)) * t_0) + (t_0 * (1.0 + (-1.0 / eps_m)))) / 2.0;
	} else {
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	t_0 = 1.0 - (x * (1.0 - eps_m))
	tmp = 0
	if eps_m <= 1.76e-6:
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0
	elif eps_m <= 4.8e+205:
		tmp = (((1.0 + (1.0 / eps_m)) * t_0) + (t_0 * (1.0 + (-1.0 / eps_m)))) / 2.0
	else:
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	t_0 = Float64(1.0 - Float64(x * Float64(1.0 - eps_m)))
	tmp = 0.0
	if (eps_m <= 1.76e-6)
		tmp = Float64(Float64(Float64(x + 1.0) - Float64(x + -1.0)) / 2.0);
	elseif (eps_m <= 4.8e+205)
		tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * t_0) + Float64(t_0 * Float64(1.0 + Float64(-1.0 / eps_m)))) / 2.0);
	else
		tmp = Float64(Float64(1.0 + Float64(1.0 + Float64(x * Float64(-1.0 - eps_m)))) / 2.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	t_0 = 1.0 - (x * (1.0 - eps_m));
	tmp = 0.0;
	if (eps_m <= 1.76e-6)
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	elseif (eps_m <= 4.8e+205)
		tmp = (((1.0 + (1.0 / eps_m)) * t_0) + (t_0 * (1.0 + (-1.0 / eps_m)))) / 2.0;
	else
		tmp = (1.0 + (1.0 + (x * (-1.0 - 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[(1.0 - N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps$95$m, 1.76e-6], N[(N[(N[(x + 1.0), $MachinePrecision] - N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps$95$m, 4.8e+205], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(t$95$0 * N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[(1.0 + N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
t_0 := 1 - x \cdot \left(1 - eps_m\right)\\
\mathbf{if}\;eps_m \leq 1.76 \cdot 10^{-6}:\\
\;\;\;\;\frac{\left(x + 1\right) - \left(x + -1\right)}{2}\\

\mathbf{elif}\;eps_m \leq 4.8 \cdot 10^{+205}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) \cdot t_0 + t_0 \cdot \left(1 + \frac{-1}{eps_m}\right)}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 10: 63.3% accurate, 7.8× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;eps_m \leq 510000000000:\\ \;\;\;\;\frac{\left(x + 1\right) - \left(x + -1\right)}{2}\\ \mathbf{elif}\;eps_m \leq 4.5 \cdot 10^{+205}:\\ \;\;\;\;\frac{\left(x \cdot \left(eps_m + -1\right) + \left(x + 1\right)\right) + \left(-1 + \frac{1}{eps_m}\right) \cdot \left(-1 - \left(x + x \cdot eps_m\right)\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= eps_m 510000000000.0)
   (/ (- (+ x 1.0) (+ x -1.0)) 2.0)
   (if (<= eps_m 4.5e+205)
     (/
      (+
       (+ (* x (+ eps_m -1.0)) (+ x 1.0))
       (* (+ -1.0 (/ 1.0 eps_m)) (- -1.0 (+ x (* x eps_m)))))
      2.0)
     (/ (+ 1.0 (+ 1.0 (* x (- -1.0 eps_m)))) 2.0))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (eps_m <= 510000000000.0) {
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	} else if (eps_m <= 4.5e+205) {
		tmp = (((x * (eps_m + -1.0)) + (x + 1.0)) + ((-1.0 + (1.0 / eps_m)) * (-1.0 - (x + (x * eps_m))))) / 2.0;
	} else {
		tmp = (1.0 + (1.0 + (x * (-1.0 - 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) :: tmp
    if (eps_m <= 510000000000.0d0) then
        tmp = ((x + 1.0d0) - (x + (-1.0d0))) / 2.0d0
    else if (eps_m <= 4.5d+205) then
        tmp = (((x * (eps_m + (-1.0d0))) + (x + 1.0d0)) + (((-1.0d0) + (1.0d0 / eps_m)) * ((-1.0d0) - (x + (x * eps_m))))) / 2.0d0
    else
        tmp = (1.0d0 + (1.0d0 + (x * ((-1.0d0) - 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 tmp;
	if (eps_m <= 510000000000.0) {
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	} else if (eps_m <= 4.5e+205) {
		tmp = (((x * (eps_m + -1.0)) + (x + 1.0)) + ((-1.0 + (1.0 / eps_m)) * (-1.0 - (x + (x * eps_m))))) / 2.0;
	} else {
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if eps_m <= 510000000000.0:
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0
	elif eps_m <= 4.5e+205:
		tmp = (((x * (eps_m + -1.0)) + (x + 1.0)) + ((-1.0 + (1.0 / eps_m)) * (-1.0 - (x + (x * eps_m))))) / 2.0
	else:
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (eps_m <= 510000000000.0)
		tmp = Float64(Float64(Float64(x + 1.0) - Float64(x + -1.0)) / 2.0);
	elseif (eps_m <= 4.5e+205)
		tmp = Float64(Float64(Float64(Float64(x * Float64(eps_m + -1.0)) + Float64(x + 1.0)) + Float64(Float64(-1.0 + Float64(1.0 / eps_m)) * Float64(-1.0 - Float64(x + Float64(x * eps_m))))) / 2.0);
	else
		tmp = Float64(Float64(1.0 + Float64(1.0 + Float64(x * Float64(-1.0 - eps_m)))) / 2.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (eps_m <= 510000000000.0)
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	elseif (eps_m <= 4.5e+205)
		tmp = (((x * (eps_m + -1.0)) + (x + 1.0)) + ((-1.0 + (1.0 / eps_m)) * (-1.0 - (x + (x * eps_m))))) / 2.0;
	else
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 510000000000.0], N[(N[(N[(x + 1.0), $MachinePrecision] - N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps$95$m, 4.5e+205], N[(N[(N[(N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision] + N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[(-1.0 - N[(x + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[(1.0 + N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;eps_m \leq 510000000000:\\
\;\;\;\;\frac{\left(x + 1\right) - \left(x + -1\right)}{2}\\

\mathbf{elif}\;eps_m \leq 4.5 \cdot 10^{+205}:\\
\;\;\;\;\frac{\left(x \cdot \left(eps_m + -1\right) + \left(x + 1\right)\right) + \left(-1 + \frac{1}{eps_m}\right) \cdot \left(-1 - \left(x + x \cdot eps_m\right)\right)}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 11: 63.4% accurate, 9.8× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;eps_m \leq 1.76 \cdot 10^{-6}:\\ \;\;\;\;\frac{\left(x + 1\right) - \left(x + -1\right)}{2}\\ \mathbf{elif}\;eps_m \leq 2.7 \cdot 10^{+205}:\\ \;\;\;\;\frac{\left(1 - x \cdot \left(1 - eps_m\right)\right) + \frac{1}{1 + x \cdot \left(eps_m + 1\right)}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= eps_m 1.76e-6)
   (/ (- (+ x 1.0) (+ x -1.0)) 2.0)
   (if (<= eps_m 2.7e+205)
     (/
      (+ (- 1.0 (* x (- 1.0 eps_m))) (/ 1.0 (+ 1.0 (* x (+ eps_m 1.0)))))
      2.0)
     (/ (+ 1.0 (+ 1.0 (* x (- -1.0 eps_m)))) 2.0))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (eps_m <= 1.76e-6) {
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	} else if (eps_m <= 2.7e+205) {
		tmp = ((1.0 - (x * (1.0 - eps_m))) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0;
	} else {
		tmp = (1.0 + (1.0 + (x * (-1.0 - 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) :: tmp
    if (eps_m <= 1.76d-6) then
        tmp = ((x + 1.0d0) - (x + (-1.0d0))) / 2.0d0
    else if (eps_m <= 2.7d+205) then
        tmp = ((1.0d0 - (x * (1.0d0 - eps_m))) + (1.0d0 / (1.0d0 + (x * (eps_m + 1.0d0))))) / 2.0d0
    else
        tmp = (1.0d0 + (1.0d0 + (x * ((-1.0d0) - 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 tmp;
	if (eps_m <= 1.76e-6) {
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	} else if (eps_m <= 2.7e+205) {
		tmp = ((1.0 - (x * (1.0 - eps_m))) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0;
	} else {
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if eps_m <= 1.76e-6:
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0
	elif eps_m <= 2.7e+205:
		tmp = ((1.0 - (x * (1.0 - eps_m))) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0
	else:
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (eps_m <= 1.76e-6)
		tmp = Float64(Float64(Float64(x + 1.0) - Float64(x + -1.0)) / 2.0);
	elseif (eps_m <= 2.7e+205)
		tmp = Float64(Float64(Float64(1.0 - Float64(x * Float64(1.0 - eps_m))) + Float64(1.0 / Float64(1.0 + Float64(x * Float64(eps_m + 1.0))))) / 2.0);
	else
		tmp = Float64(Float64(1.0 + Float64(1.0 + Float64(x * Float64(-1.0 - eps_m)))) / 2.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (eps_m <= 1.76e-6)
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	elseif (eps_m <= 2.7e+205)
		tmp = ((1.0 - (x * (1.0 - eps_m))) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0;
	else
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.76e-6], N[(N[(N[(x + 1.0), $MachinePrecision] - N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps$95$m, 2.7e+205], N[(N[(N[(1.0 - N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(1.0 + N[(x * N[(eps$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[(1.0 + N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;eps_m \leq 1.76 \cdot 10^{-6}:\\
\;\;\;\;\frac{\left(x + 1\right) - \left(x + -1\right)}{2}\\

\mathbf{elif}\;eps_m \leq 2.7 \cdot 10^{+205}:\\
\;\;\;\;\frac{\left(1 - x \cdot \left(1 - eps_m\right)\right) + \frac{1}{1 + x \cdot \left(eps_m + 1\right)}}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 12: 58.6% accurate, 15.1× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{x \cdot \left(\left(eps_m + 1\right) \cdot \left(-1 + \frac{1}{eps_m}\right)\right)}{2}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-5}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{eps_m \cdot \left(x \cdot 2\right)}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= x -1.0)
   (/ (* x (* (+ eps_m 1.0) (+ -1.0 (/ 1.0 eps_m)))) 2.0)
   (if (<= x 6.2e-5) 1.0 (/ (* eps_m (* x 2.0)) 2.0))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (x <= -1.0) {
		tmp = (x * ((eps_m + 1.0) * (-1.0 + (1.0 / eps_m)))) / 2.0;
	} else if (x <= 6.2e-5) {
		tmp = 1.0;
	} else {
		tmp = (eps_m * (x * 2.0)) / 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) :: tmp
    if (x <= (-1.0d0)) then
        tmp = (x * ((eps_m + 1.0d0) * ((-1.0d0) + (1.0d0 / eps_m)))) / 2.0d0
    else if (x <= 6.2d-5) then
        tmp = 1.0d0
    else
        tmp = (eps_m * (x * 2.0d0)) / 2.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 + 1.0) * (-1.0 + (1.0 / eps_m)))) / 2.0;
	} else if (x <= 6.2e-5) {
		tmp = 1.0;
	} else {
		tmp = (eps_m * (x * 2.0)) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if x <= -1.0:
		tmp = (x * ((eps_m + 1.0) * (-1.0 + (1.0 / eps_m)))) / 2.0
	elif x <= 6.2e-5:
		tmp = 1.0
	else:
		tmp = (eps_m * (x * 2.0)) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (x <= -1.0)
		tmp = Float64(Float64(x * Float64(Float64(eps_m + 1.0) * Float64(-1.0 + Float64(1.0 / eps_m)))) / 2.0);
	elseif (x <= 6.2e-5)
		tmp = 1.0;
	else
		tmp = Float64(Float64(eps_m * Float64(x * 2.0)) / 2.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 + 1.0) * (-1.0 + (1.0 / eps_m)))) / 2.0;
	elseif (x <= 6.2e-5)
		tmp = 1.0;
	else
		tmp = (eps_m * (x * 2.0)) / 2.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[x, -1.0], N[(N[(x * N[(N[(eps$95$m + 1.0), $MachinePrecision] * N[(-1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.2e-5], 1.0, N[(N[(eps$95$m * N[(x * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

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

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;\frac{eps_m \cdot \left(x \cdot 2\right)}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 13: 57.9% accurate, 17.4× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 6.2 \cdot 10^{-5}:\\ \;\;\;\;\frac{1 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{eps_m \cdot \left(x \cdot 2\right)}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= x 6.2e-5)
   (/ (+ 1.0 (+ 1.0 (* x (- -1.0 eps_m)))) 2.0)
   (/ (* eps_m (* x 2.0)) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (x <= 6.2e-5) {
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
	} else {
		tmp = (eps_m * (x * 2.0)) / 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) :: tmp
    if (x <= 6.2d-5) then
        tmp = (1.0d0 + (1.0d0 + (x * ((-1.0d0) - eps_m)))) / 2.0d0
    else
        tmp = (eps_m * (x * 2.0d0)) / 2.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 <= 6.2e-5) {
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
	} else {
		tmp = (eps_m * (x * 2.0)) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if x <= 6.2e-5:
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0
	else:
		tmp = (eps_m * (x * 2.0)) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (x <= 6.2e-5)
		tmp = Float64(Float64(1.0 + Float64(1.0 + Float64(x * Float64(-1.0 - eps_m)))) / 2.0);
	else
		tmp = Float64(Float64(eps_m * Float64(x * 2.0)) / 2.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (x <= 6.2e-5)
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
	else
		tmp = (eps_m * (x * 2.0)) / 2.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[x, 6.2e-5], N[(N[(1.0 + N[(1.0 + N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(eps$95$m * N[(x * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{1 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{eps_m \cdot \left(x \cdot 2\right)}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 14: 63.0% accurate, 17.4× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;eps_m \leq 4.5 \cdot 10^{+17}:\\ \;\;\;\;\frac{\left(x + 1\right) - \left(x + -1\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= eps_m 4.5e+17)
   (/ (- (+ x 1.0) (+ x -1.0)) 2.0)
   (/ (+ 1.0 (+ 1.0 (* x (- -1.0 eps_m)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (eps_m <= 4.5e+17) {
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	} else {
		tmp = (1.0 + (1.0 + (x * (-1.0 - 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) :: tmp
    if (eps_m <= 4.5d+17) then
        tmp = ((x + 1.0d0) - (x + (-1.0d0))) / 2.0d0
    else
        tmp = (1.0d0 + (1.0d0 + (x * ((-1.0d0) - 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 tmp;
	if (eps_m <= 4.5e+17) {
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	} else {
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if eps_m <= 4.5e+17:
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0
	else:
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (eps_m <= 4.5e+17)
		tmp = Float64(Float64(Float64(x + 1.0) - Float64(x + -1.0)) / 2.0);
	else
		tmp = Float64(Float64(1.0 + Float64(1.0 + Float64(x * Float64(-1.0 - eps_m)))) / 2.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (eps_m <= 4.5e+17)
		tmp = ((x + 1.0) - (x + -1.0)) / 2.0;
	else
		tmp = (1.0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 4.5e+17], N[(N[(N[(x + 1.0), $MachinePrecision] - N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[(1.0 + N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;eps_m \leq 4.5 \cdot 10^{+17}:\\
\;\;\;\;\frac{\left(x + 1\right) - \left(x + -1\right)}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(1 + x \cdot \left(-1 - eps_m\right)\right)}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 15: 58.5% accurate, 20.4× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;-\frac{x \cdot eps_m}{2}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-5}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{eps_m \cdot \left(x \cdot 2\right)}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= x -1.0)
   (- (/ (* x eps_m) 2.0))
   (if (<= x 6.2e-5) 1.0 (/ (* eps_m (* x 2.0)) 2.0))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (x <= -1.0) {
		tmp = -((x * eps_m) / 2.0);
	} else if (x <= 6.2e-5) {
		tmp = 1.0;
	} else {
		tmp = (eps_m * (x * 2.0)) / 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) :: tmp
    if (x <= (-1.0d0)) then
        tmp = -((x * eps_m) / 2.0d0)
    else if (x <= 6.2d-5) then
        tmp = 1.0d0
    else
        tmp = (eps_m * (x * 2.0d0)) / 2.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) / 2.0);
	} else if (x <= 6.2e-5) {
		tmp = 1.0;
	} else {
		tmp = (eps_m * (x * 2.0)) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if x <= -1.0:
		tmp = -((x * eps_m) / 2.0)
	elif x <= 6.2e-5:
		tmp = 1.0
	else:
		tmp = (eps_m * (x * 2.0)) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (x <= -1.0)
		tmp = Float64(-Float64(Float64(x * eps_m) / 2.0));
	elseif (x <= 6.2e-5)
		tmp = 1.0;
	else
		tmp = Float64(Float64(eps_m * Float64(x * 2.0)) / 2.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) / 2.0);
	elseif (x <= 6.2e-5)
		tmp = 1.0;
	else
		tmp = (eps_m * (x * 2.0)) / 2.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[x, -1.0], (-N[(N[(x * eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]), If[LessEqual[x, 6.2e-5], 1.0, N[(N[(eps$95$m * N[(x * 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;-\frac{x \cdot eps_m}{2}\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;\frac{eps_m \cdot \left(x \cdot 2\right)}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 16: 58.5% accurate, 24.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x \cdot eps_m}{2}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;-t_0\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 17: 51.3% accurate, 32.1× speedup?

\[\begin{array}{l} eps_m = \left|\varepsilon\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 6.2 \cdot 10^{-5}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot eps_m}{2}\\ \end{array} \end{array} \]
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
 :precision binary64
 (if (<= x 6.2e-5) 1.0 (/ (* x eps_m) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
	double tmp;
	if (x <= 6.2e-5) {
		tmp = 1.0;
	} else {
		tmp = (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) :: tmp
    if (x <= 6.2d-5) then
        tmp = 1.0d0
    else
        tmp = (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 tmp;
	if (x <= 6.2e-5) {
		tmp = 1.0;
	} else {
		tmp = (x * eps_m) / 2.0;
	}
	return tmp;
}
eps_m = math.fabs(eps)
def code(x, eps_m):
	tmp = 0
	if x <= 6.2e-5:
		tmp = 1.0
	else:
		tmp = (x * eps_m) / 2.0
	return tmp
eps_m = abs(eps)
function code(x, eps_m)
	tmp = 0.0
	if (x <= 6.2e-5)
		tmp = 1.0;
	else
		tmp = Float64(Float64(x * eps_m) / 2.0);
	end
	return tmp
end
eps_m = abs(eps);
function tmp_2 = code(x, eps_m)
	tmp = 0.0;
	if (x <= 6.2e-5)
		tmp = 1.0;
	else
		tmp = (x * eps_m) / 2.0;
	end
	tmp_2 = tmp;
end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := If[LessEqual[x, 6.2e-5], 1.0, N[(N[(x * eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps_m}{2}\\


\end{array}
\end{array}
Derivation
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Alternative 18: 43.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
    &prev;&pcontext;&pcontext2;&ctx;
  1. Add Preprocessing

Reproduce

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