
(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:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 1e-13)
(/ (+ (/ (+ x 1.0) (exp x)) (* (+ x 1.0) (exp (- x)))) 2.0)
(/
(+
(* (+ 1.0 (/ 1.0 eps_m)) (exp (* x (+ eps_m -1.0))))
(* (exp (* x (- -1.0 eps_m))) (+ 1.0 (/ -1.0 eps_m))))
2.0)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1e-13) {
tmp = (((x + 1.0) / exp(x)) + ((x + 1.0) * exp(-x))) / 2.0;
} else {
tmp = (((1.0 + (1.0 / eps_m)) * exp((x * (eps_m + -1.0)))) + (exp((x * (-1.0 - eps_m))) * (1.0 + (-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 <= 1d-13) then
tmp = (((x + 1.0d0) / exp(x)) + ((x + 1.0d0) * exp(-x))) / 2.0d0
else
tmp = (((1.0d0 + (1.0d0 / eps_m)) * exp((x * (eps_m + (-1.0d0))))) + (exp((x * ((-1.0d0) - eps_m))) * (1.0d0 + ((-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 <= 1e-13) {
tmp = (((x + 1.0) / Math.exp(x)) + ((x + 1.0) * Math.exp(-x))) / 2.0;
} else {
tmp = (((1.0 + (1.0 / eps_m)) * Math.exp((x * (eps_m + -1.0)))) + (Math.exp((x * (-1.0 - eps_m))) * (1.0 + (-1.0 / eps_m)))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1e-13: tmp = (((x + 1.0) / math.exp(x)) + ((x + 1.0) * math.exp(-x))) / 2.0 else: tmp = (((1.0 + (1.0 / eps_m)) * math.exp((x * (eps_m + -1.0)))) + (math.exp((x * (-1.0 - eps_m))) * (1.0 + (-1.0 / eps_m)))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1e-13) tmp = Float64(Float64(Float64(Float64(x + 1.0) / exp(x)) + Float64(Float64(x + 1.0) * exp(Float64(-x)))) / 2.0); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * exp(Float64(x * Float64(eps_m + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps_m))) * Float64(1.0 + 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 <= 1e-13) tmp = (((x + 1.0) / exp(x)) + ((x + 1.0) * exp(-x))) / 2.0; else tmp = (((1.0 + (1.0 / eps_m)) * exp((x * (eps_m + -1.0)))) + (exp((x * (-1.0 - eps_m))) * (1.0 + (-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, 1e-13], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + 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 10^{-13}:\\
\;\;\;\;\frac{\frac{x + 1}{e^{x}} + \left(x + 1\right) \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) \cdot e^{x \cdot \left(eps_m + -1\right)} + e^{x \cdot \left(-1 - eps_m\right)} \cdot \left(1 + \frac{-1}{eps_m}\right)}{2}\\
\end{array}
\end{array}
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -2e-271)
(/ (+ 1.0 (exp (* eps_m (- x)))) 2.0)
(if (<= x 3.6e+41)
(/ (+ 1.0 (exp (+ x (* eps_m x)))) 2.0)
(/ (+ (* x (+ eps_m -1.0)) (+ x 2.0)) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -2e-271) {
tmp = (1.0 + exp((eps_m * -x))) / 2.0;
} else if (x <= 3.6e+41) {
tmp = (1.0 + exp((x + (eps_m * x)))) / 2.0;
} else {
tmp = ((x * (eps_m + -1.0)) + (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 <= (-2d-271)) then
tmp = (1.0d0 + exp((eps_m * -x))) / 2.0d0
else if (x <= 3.6d+41) then
tmp = (1.0d0 + exp((x + (eps_m * x)))) / 2.0d0
else
tmp = ((x * (eps_m + (-1.0d0))) + (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 <= -2e-271) {
tmp = (1.0 + Math.exp((eps_m * -x))) / 2.0;
} else if (x <= 3.6e+41) {
tmp = (1.0 + Math.exp((x + (eps_m * x)))) / 2.0;
} else {
tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -2e-271: tmp = (1.0 + math.exp((eps_m * -x))) / 2.0 elif x <= 3.6e+41: tmp = (1.0 + math.exp((x + (eps_m * x)))) / 2.0 else: tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -2e-271) tmp = Float64(Float64(1.0 + exp(Float64(eps_m * Float64(-x)))) / 2.0); elseif (x <= 3.6e+41) tmp = Float64(Float64(1.0 + exp(Float64(x + Float64(eps_m * x)))) / 2.0); else tmp = Float64(Float64(Float64(x * Float64(eps_m + -1.0)) + 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 <= -2e-271) tmp = (1.0 + exp((eps_m * -x))) / 2.0; elseif (x <= 3.6e+41) tmp = (1.0 + exp((x + (eps_m * x)))) / 2.0; else tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -2e-271], N[(N[(1.0 + N[Exp[N[(eps$95$m * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 3.6e+41], N[(N[(1.0 + N[Exp[N[(x + N[(eps$95$m * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision] + N[(x + 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-271}:\\
\;\;\;\;\frac{1 + e^{eps_m \cdot \left(-x\right)}}{2}\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{+41}:\\
\;\;\;\;\frac{1 + e^{x + eps_m \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(eps_m + -1\right) + \left(x + 2\right)}{2}\\
\end{array}
\end{array}
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* x (+ -1.0 (- 1.0 eps_m)))))
(if (<= x -1e-282)
(/ (+ 1.0 (exp (* eps_m (- x)))) 2.0)
(if (<= x 8e+26)
(/ (/ (- 4.0 (* t_0 t_0)) (+ 2.0 t_0)) 2.0)
(/ (+ (* x (+ eps_m -1.0)) (+ x 2.0)) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = x * (-1.0 + (1.0 - eps_m));
double tmp;
if (x <= -1e-282) {
tmp = (1.0 + exp((eps_m * -x))) / 2.0;
} else if (x <= 8e+26) {
tmp = ((4.0 - (t_0 * t_0)) / (2.0 + t_0)) / 2.0;
} else {
tmp = ((x * (eps_m + -1.0)) + (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) :: t_0
real(8) :: tmp
t_0 = x * ((-1.0d0) + (1.0d0 - eps_m))
if (x <= (-1d-282)) then
tmp = (1.0d0 + exp((eps_m * -x))) / 2.0d0
else if (x <= 8d+26) then
tmp = ((4.0d0 - (t_0 * t_0)) / (2.0d0 + t_0)) / 2.0d0
else
tmp = ((x * (eps_m + (-1.0d0))) + (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 t_0 = x * (-1.0 + (1.0 - eps_m));
double tmp;
if (x <= -1e-282) {
tmp = (1.0 + Math.exp((eps_m * -x))) / 2.0;
} else if (x <= 8e+26) {
tmp = ((4.0 - (t_0 * t_0)) / (2.0 + t_0)) / 2.0;
} else {
tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = x * (-1.0 + (1.0 - eps_m)) tmp = 0 if x <= -1e-282: tmp = (1.0 + math.exp((eps_m * -x))) / 2.0 elif x <= 8e+26: tmp = ((4.0 - (t_0 * t_0)) / (2.0 + t_0)) / 2.0 else: tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(x * Float64(-1.0 + Float64(1.0 - eps_m))) tmp = 0.0 if (x <= -1e-282) tmp = Float64(Float64(1.0 + exp(Float64(eps_m * Float64(-x)))) / 2.0); elseif (x <= 8e+26) tmp = Float64(Float64(Float64(4.0 - Float64(t_0 * t_0)) / Float64(2.0 + t_0)) / 2.0); else tmp = Float64(Float64(Float64(x * Float64(eps_m + -1.0)) + Float64(x + 2.0)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = x * (-1.0 + (1.0 - eps_m)); tmp = 0.0; if (x <= -1e-282) tmp = (1.0 + exp((eps_m * -x))) / 2.0; elseif (x <= 8e+26) tmp = ((4.0 - (t_0 * t_0)) / (2.0 + t_0)) / 2.0; else tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(x * N[(-1.0 + N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1e-282], N[(N[(1.0 + N[Exp[N[(eps$95$m * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 8e+26], N[(N[(N[(4.0 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(2.0 + t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision] + N[(x + 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := x \cdot \left(-1 + \left(1 - eps_m\right)\right)\\
\mathbf{if}\;x \leq -1 \cdot 10^{-282}:\\
\;\;\;\;\frac{1 + e^{eps_m \cdot \left(-x\right)}}{2}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+26}:\\
\;\;\;\;\frac{\frac{4 - t_0 \cdot t_0}{2 + t_0}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(eps_m + -1\right) + \left(x + 2\right)}{2}\\
\end{array}
\end{array}
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* x (+ -1.0 (- 1.0 eps_m)))))
(if (<= x 4.8e-143)
(/ (+ 1.0 (exp (- x))) 2.0)
(if (<= x 6.6e+26)
(/ (/ (- 4.0 (* t_0 t_0)) (+ 2.0 t_0)) 2.0)
(/ (+ (* x (+ eps_m -1.0)) (+ x 2.0)) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = x * (-1.0 + (1.0 - eps_m));
double tmp;
if (x <= 4.8e-143) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if (x <= 6.6e+26) {
tmp = ((4.0 - (t_0 * t_0)) / (2.0 + t_0)) / 2.0;
} else {
tmp = ((x * (eps_m + -1.0)) + (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) :: t_0
real(8) :: tmp
t_0 = x * ((-1.0d0) + (1.0d0 - eps_m))
if (x <= 4.8d-143) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else if (x <= 6.6d+26) then
tmp = ((4.0d0 - (t_0 * t_0)) / (2.0d0 + t_0)) / 2.0d0
else
tmp = ((x * (eps_m + (-1.0d0))) + (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 t_0 = x * (-1.0 + (1.0 - eps_m));
double tmp;
if (x <= 4.8e-143) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if (x <= 6.6e+26) {
tmp = ((4.0 - (t_0 * t_0)) / (2.0 + t_0)) / 2.0;
} else {
tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = x * (-1.0 + (1.0 - eps_m)) tmp = 0 if x <= 4.8e-143: tmp = (1.0 + math.exp(-x)) / 2.0 elif x <= 6.6e+26: tmp = ((4.0 - (t_0 * t_0)) / (2.0 + t_0)) / 2.0 else: tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(x * Float64(-1.0 + Float64(1.0 - eps_m))) tmp = 0.0 if (x <= 4.8e-143) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif (x <= 6.6e+26) tmp = Float64(Float64(Float64(4.0 - Float64(t_0 * t_0)) / Float64(2.0 + t_0)) / 2.0); else tmp = Float64(Float64(Float64(x * Float64(eps_m + -1.0)) + Float64(x + 2.0)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = x * (-1.0 + (1.0 - eps_m)); tmp = 0.0; if (x <= 4.8e-143) tmp = (1.0 + exp(-x)) / 2.0; elseif (x <= 6.6e+26) tmp = ((4.0 - (t_0 * t_0)) / (2.0 + t_0)) / 2.0; else tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(x * N[(-1.0 + N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 4.8e-143], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.6e+26], N[(N[(N[(4.0 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(2.0 + t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision] + N[(x + 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := x \cdot \left(-1 + \left(1 - eps_m\right)\right)\\
\mathbf{if}\;x \leq 4.8 \cdot 10^{-143}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{+26}:\\
\;\;\;\;\frac{\frac{4 - t_0 \cdot t_0}{2 + t_0}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(eps_m + -1\right) + \left(x + 2\right)}{2}\\
\end{array}
\end{array}
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* x (+ -1.0 (- 1.0 eps_m)))))
(if (<= x -2e-271)
(/ (- 2.0 (* eps_m x)) 2.0)
(if (<= x 3.2e+27)
(/ (/ (- 4.0 (* t_0 t_0)) (+ 2.0 t_0)) 2.0)
(/ (+ (* x (+ eps_m -1.0)) (+ x 2.0)) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = x * (-1.0 + (1.0 - eps_m));
double tmp;
if (x <= -2e-271) {
tmp = (2.0 - (eps_m * x)) / 2.0;
} else if (x <= 3.2e+27) {
tmp = ((4.0 - (t_0 * t_0)) / (2.0 + t_0)) / 2.0;
} else {
tmp = ((x * (eps_m + -1.0)) + (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) :: t_0
real(8) :: tmp
t_0 = x * ((-1.0d0) + (1.0d0 - eps_m))
if (x <= (-2d-271)) then
tmp = (2.0d0 - (eps_m * x)) / 2.0d0
else if (x <= 3.2d+27) then
tmp = ((4.0d0 - (t_0 * t_0)) / (2.0d0 + t_0)) / 2.0d0
else
tmp = ((x * (eps_m + (-1.0d0))) + (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 t_0 = x * (-1.0 + (1.0 - eps_m));
double tmp;
if (x <= -2e-271) {
tmp = (2.0 - (eps_m * x)) / 2.0;
} else if (x <= 3.2e+27) {
tmp = ((4.0 - (t_0 * t_0)) / (2.0 + t_0)) / 2.0;
} else {
tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = x * (-1.0 + (1.0 - eps_m)) tmp = 0 if x <= -2e-271: tmp = (2.0 - (eps_m * x)) / 2.0 elif x <= 3.2e+27: tmp = ((4.0 - (t_0 * t_0)) / (2.0 + t_0)) / 2.0 else: tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(x * Float64(-1.0 + Float64(1.0 - eps_m))) tmp = 0.0 if (x <= -2e-271) tmp = Float64(Float64(2.0 - Float64(eps_m * x)) / 2.0); elseif (x <= 3.2e+27) tmp = Float64(Float64(Float64(4.0 - Float64(t_0 * t_0)) / Float64(2.0 + t_0)) / 2.0); else tmp = Float64(Float64(Float64(x * Float64(eps_m + -1.0)) + Float64(x + 2.0)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = x * (-1.0 + (1.0 - eps_m)); tmp = 0.0; if (x <= -2e-271) tmp = (2.0 - (eps_m * x)) / 2.0; elseif (x <= 3.2e+27) tmp = ((4.0 - (t_0 * t_0)) / (2.0 + t_0)) / 2.0; else tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(x * N[(-1.0 + N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2e-271], N[(N[(2.0 - N[(eps$95$m * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 3.2e+27], N[(N[(N[(4.0 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(2.0 + t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision] + N[(x + 2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := x \cdot \left(-1 + \left(1 - eps_m\right)\right)\\
\mathbf{if}\;x \leq -2 \cdot 10^{-271}:\\
\;\;\;\;\frac{2 - eps_m \cdot x}{2}\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{+27}:\\
\;\;\;\;\frac{\frac{4 - t_0 \cdot t_0}{2 + t_0}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(eps_m + -1\right) + \left(x + 2\right)}{2}\\
\end{array}
\end{array}
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -1e-282) (/ (- 2.0 (* eps_m x)) 2.0) (/ (+ (* x (+ eps_m -1.0)) (+ x 2.0)) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1e-282) {
tmp = (2.0 - (eps_m * x)) / 2.0;
} else {
tmp = ((x * (eps_m + -1.0)) + (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 <= (-1d-282)) then
tmp = (2.0d0 - (eps_m * x)) / 2.0d0
else
tmp = ((x * (eps_m + (-1.0d0))) + (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 <= -1e-282) {
tmp = (2.0 - (eps_m * x)) / 2.0;
} else {
tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1e-282: tmp = (2.0 - (eps_m * x)) / 2.0 else: tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1e-282) tmp = Float64(Float64(2.0 - Float64(eps_m * x)) / 2.0); else tmp = Float64(Float64(Float64(x * Float64(eps_m + -1.0)) + 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 <= -1e-282) tmp = (2.0 - (eps_m * x)) / 2.0; else tmp = ((x * (eps_m + -1.0)) + (x + 2.0)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1e-282], N[(N[(2.0 - N[(eps$95$m * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision] + 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 \cdot 10^{-282}:\\
\;\;\;\;\frac{2 - eps_m \cdot x}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(eps_m + -1\right) + \left(x + 2\right)}{2}\\
\end{array}
\end{array}
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -2e-283) (/ (- 2.0 (* eps_m x)) 2.0) (/ (+ 2.0 (* eps_m x)) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -2e-283) {
tmp = (2.0 - (eps_m * x)) / 2.0;
} else {
tmp = (2.0 + (eps_m * x)) / 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 <= (-2d-283)) then
tmp = (2.0d0 - (eps_m * x)) / 2.0d0
else
tmp = (2.0d0 + (eps_m * x)) / 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 <= -2e-283) {
tmp = (2.0 - (eps_m * x)) / 2.0;
} else {
tmp = (2.0 + (eps_m * x)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -2e-283: tmp = (2.0 - (eps_m * x)) / 2.0 else: tmp = (2.0 + (eps_m * x)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -2e-283) tmp = Float64(Float64(2.0 - Float64(eps_m * x)) / 2.0); else tmp = Float64(Float64(2.0 + Float64(eps_m * x)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -2e-283) tmp = (2.0 - (eps_m * x)) / 2.0; else tmp = (2.0 + (eps_m * x)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -2e-283], N[(N[(2.0 - N[(eps$95$m * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(eps$95$m * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-283}:\\
\;\;\;\;\frac{2 - eps_m \cdot x}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + eps_m \cdot x}{2}\\
\end{array}
\end{array}
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 1.7) 1.0 (/ (* eps_m x) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 1.7) {
tmp = 1.0;
} else {
tmp = (eps_m * x) / 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.7d0) then
tmp = 1.0d0
else
tmp = (eps_m * x) / 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.7) {
tmp = 1.0;
} else {
tmp = (eps_m * x) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 1.7: tmp = 1.0 else: tmp = (eps_m * x) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 1.7) tmp = 1.0; else tmp = Float64(Float64(eps_m * x) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 1.7) tmp = 1.0; else tmp = (eps_m * x) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 1.7], 1.0, N[(N[(eps$95$m * x), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{eps_m \cdot x}{2}\\
\end{array}
\end{array}
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ 2.0 (* eps_m x)) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (2.0 + (eps_m * x)) / 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 = (2.0d0 + (eps_m * x)) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (2.0 + (eps_m * x)) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (2.0 + (eps_m * x)) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(2.0 + Float64(eps_m * x)) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (2.0 + (eps_m * x)) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(2.0 + N[(eps$95$m * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{2 + eps_m \cdot x}{2}
\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}
herbie shell --seed 2023350
(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))