
(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 14 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}
(FPCore (x eps)
:precision binary64
(let* ((t_0
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps)))))
(t_1 (exp (- x)))
(t_2 (+ t_1 (* x t_1))))
(if (<= t_0 0.0) (/ (+ t_2 t_2) 2.0) (/ t_0 2.0))))
double code(double x, double eps) {
double t_0 = ((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)));
double t_1 = exp(-x);
double t_2 = t_1 + (x * t_1);
double tmp;
if (t_0 <= 0.0) {
tmp = (t_2 + t_2) / 2.0;
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((1.0d0 + (1.0d0 / eps)) * exp((x * (eps + (-1.0d0))))) + (exp((x * ((-1.0d0) - eps))) * (1.0d0 + ((-1.0d0) / eps)))
t_1 = exp(-x)
t_2 = t_1 + (x * t_1)
if (t_0 <= 0.0d0) then
tmp = (t_2 + t_2) / 2.0d0
else
tmp = t_0 / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = ((1.0 + (1.0 / eps)) * Math.exp((x * (eps + -1.0)))) + (Math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)));
double t_1 = Math.exp(-x);
double t_2 = t_1 + (x * t_1);
double tmp;
if (t_0 <= 0.0) {
tmp = (t_2 + t_2) / 2.0;
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = ((1.0 + (1.0 / eps)) * math.exp((x * (eps + -1.0)))) + (math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps))) t_1 = math.exp(-x) t_2 = t_1 + (x * t_1) tmp = 0 if t_0 <= 0.0: tmp = (t_2 + t_2) / 2.0 else: tmp = t_0 / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) t_1 = exp(Float64(-x)) t_2 = Float64(t_1 + Float64(x * t_1)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(t_2 + t_2) / 2.0); else tmp = Float64(t_0 / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = ((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps))); t_1 = exp(-x); t_2 = t_1 + (x * t_1); tmp = 0.0; if (t_0 <= 0.0) tmp = (t_2 + t_2) / 2.0; else tmp = t_0 / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-x)], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + N[(x * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(t$95$2 + t$95$2), $MachinePrecision] / 2.0), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right)\\
t_1 := e^{-x}\\
t_2 := t_1 + x \cdot t_1\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\frac{t_2 + t_2}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2}\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))))
(if (<= t_0 0.0)
(/ (+ (/ (+ 1.0 x) (exp x)) (* (exp (- x)) (+ 1.0 x))) 2.0)
(/ t_0 2.0))))
double code(double x, double eps) {
double t_0 = ((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)));
double tmp;
if (t_0 <= 0.0) {
tmp = (((1.0 + x) / exp(x)) + (exp(-x) * (1.0 + x))) / 2.0;
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 + (1.0d0 / eps)) * exp((x * (eps + (-1.0d0))))) + (exp((x * ((-1.0d0) - eps))) * (1.0d0 + ((-1.0d0) / eps)))
if (t_0 <= 0.0d0) then
tmp = (((1.0d0 + x) / exp(x)) + (exp(-x) * (1.0d0 + x))) / 2.0d0
else
tmp = t_0 / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = ((1.0 + (1.0 / eps)) * Math.exp((x * (eps + -1.0)))) + (Math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)));
double tmp;
if (t_0 <= 0.0) {
tmp = (((1.0 + x) / Math.exp(x)) + (Math.exp(-x) * (1.0 + x))) / 2.0;
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = ((1.0 + (1.0 / eps)) * math.exp((x * (eps + -1.0)))) + (math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps))) tmp = 0 if t_0 <= 0.0: tmp = (((1.0 + x) / math.exp(x)) + (math.exp(-x) * (1.0 + x))) / 2.0 else: tmp = t_0 / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(Float64(Float64(1.0 + x) / exp(x)) + Float64(exp(Float64(-x)) * Float64(1.0 + x))) / 2.0); else tmp = Float64(t_0 / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = ((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps))); tmp = 0.0; if (t_0 <= 0.0) tmp = (((1.0 + x) / exp(x)) + (exp(-x) * (1.0 + x))) / 2.0; else tmp = t_0 / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[(-x)], $MachinePrecision] * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right)\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\frac{\frac{1 + x}{e^{x}} + e^{-x} \cdot \left(1 + x\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (<= eps 5e-31) (/ (+ (/ (+ 1.0 x) (exp x)) (* (exp (- x)) (+ 1.0 x))) 2.0) (/ (+ (exp (* x (+ eps -1.0))) (exp (* eps (- x)))) 2.0)))
double code(double x, double eps) {
double tmp;
if (eps <= 5e-31) {
tmp = (((1.0 + x) / exp(x)) + (exp(-x) * (1.0 + x))) / 2.0;
} else {
tmp = (exp((x * (eps + -1.0))) + exp((eps * -x))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= 5d-31) then
tmp = (((1.0d0 + x) / exp(x)) + (exp(-x) * (1.0d0 + x))) / 2.0d0
else
tmp = (exp((x * (eps + (-1.0d0)))) + exp((eps * -x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= 5e-31) {
tmp = (((1.0 + x) / Math.exp(x)) + (Math.exp(-x) * (1.0 + x))) / 2.0;
} else {
tmp = (Math.exp((x * (eps + -1.0))) + Math.exp((eps * -x))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= 5e-31: tmp = (((1.0 + x) / math.exp(x)) + (math.exp(-x) * (1.0 + x))) / 2.0 else: tmp = (math.exp((x * (eps + -1.0))) + math.exp((eps * -x))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (eps <= 5e-31) tmp = Float64(Float64(Float64(Float64(1.0 + x) / exp(x)) + Float64(exp(Float64(-x)) * Float64(1.0 + x))) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + exp(Float64(eps * Float64(-x)))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 5e-31) tmp = (((1.0 + x) / exp(x)) + (exp(-x) * (1.0 + x))) / 2.0; else tmp = (exp((x * (eps + -1.0))) + exp((eps * -x))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, 5e-31], N[(N[(N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[(-x)], $MachinePrecision] * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 5 \cdot 10^{-31}:\\
\;\;\;\;\frac{\frac{1 + x}{e^{x}} + e^{-x} \cdot \left(1 + x\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(\varepsilon + -1\right)} + e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (<= eps 3e-37) (/ (/ 2.0 (exp x)) 2.0) (/ (+ (exp (* x (+ eps -1.0))) (exp (* eps (- x)))) 2.0)))
double code(double x, double eps) {
double tmp;
if (eps <= 3e-37) {
tmp = (2.0 / exp(x)) / 2.0;
} else {
tmp = (exp((x * (eps + -1.0))) + exp((eps * -x))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (eps <= 3d-37) then
tmp = (2.0d0 / exp(x)) / 2.0d0
else
tmp = (exp((x * (eps + (-1.0d0)))) + exp((eps * -x))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (eps <= 3e-37) {
tmp = (2.0 / Math.exp(x)) / 2.0;
} else {
tmp = (Math.exp((x * (eps + -1.0))) + Math.exp((eps * -x))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if eps <= 3e-37: tmp = (2.0 / math.exp(x)) / 2.0 else: tmp = (math.exp((x * (eps + -1.0))) + math.exp((eps * -x))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (eps <= 3e-37) tmp = Float64(Float64(2.0 / exp(x)) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + exp(Float64(eps * Float64(-x)))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 3e-37) tmp = (2.0 / exp(x)) / 2.0; else tmp = (exp((x * (eps + -1.0))) + exp((eps * -x))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[eps, 3e-37], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 3 \cdot 10^{-37}:\\
\;\;\;\;\frac{\frac{2}{e^{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(\varepsilon + -1\right)} + e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (/ (+ (exp (* x (- -1.0 eps))) (exp (* x (+ eps -1.0)))) 2.0))
double code(double x, double eps) {
return (exp((x * (-1.0 - eps))) + exp((x * (eps + -1.0)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (exp((x * ((-1.0d0) - eps))) + exp((x * (eps + (-1.0d0))))) / 2.0d0
end function
public static double code(double x, double eps) {
return (Math.exp((x * (-1.0 - eps))) + Math.exp((x * (eps + -1.0)))) / 2.0;
}
def code(x, eps): return (math.exp((x * (-1.0 - eps))) + math.exp((x * (eps + -1.0)))) / 2.0
function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(-1.0 - eps))) + exp(Float64(x * Float64(eps + -1.0)))) / 2.0) end
function tmp = code(x, eps) tmp = (exp((x * (-1.0 - eps))) + exp((x * (eps + -1.0)))) / 2.0; end
code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x \cdot \left(-1 - \varepsilon\right)} + e^{x \cdot \left(\varepsilon + -1\right)}}{2}
\end{array}
(FPCore (x eps)
:precision binary64
(if (<= x -1.1e-286)
(/ (+ 1.0 (exp (* eps (- x)))) 2.0)
(if (<= x 155000000000.0)
(/ (+ (exp (* x (+ eps -1.0))) (- 1.0 (* eps x))) 2.0)
(/ (/ 2.0 (exp x)) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -1.1e-286) {
tmp = (1.0 + exp((eps * -x))) / 2.0;
} else if (x <= 155000000000.0) {
tmp = (exp((x * (eps + -1.0))) + (1.0 - (eps * x))) / 2.0;
} else {
tmp = (2.0 / exp(x)) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1.1d-286)) then
tmp = (1.0d0 + exp((eps * -x))) / 2.0d0
else if (x <= 155000000000.0d0) then
tmp = (exp((x * (eps + (-1.0d0)))) + (1.0d0 - (eps * x))) / 2.0d0
else
tmp = (2.0d0 / exp(x)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1.1e-286) {
tmp = (1.0 + Math.exp((eps * -x))) / 2.0;
} else if (x <= 155000000000.0) {
tmp = (Math.exp((x * (eps + -1.0))) + (1.0 - (eps * x))) / 2.0;
} else {
tmp = (2.0 / Math.exp(x)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1.1e-286: tmp = (1.0 + math.exp((eps * -x))) / 2.0 elif x <= 155000000000.0: tmp = (math.exp((x * (eps + -1.0))) + (1.0 - (eps * x))) / 2.0 else: tmp = (2.0 / math.exp(x)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -1.1e-286) tmp = Float64(Float64(1.0 + exp(Float64(eps * Float64(-x)))) / 2.0); elseif (x <= 155000000000.0) tmp = Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + Float64(1.0 - Float64(eps * x))) / 2.0); else tmp = Float64(Float64(2.0 / exp(x)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.1e-286) tmp = (1.0 + exp((eps * -x))) / 2.0; elseif (x <= 155000000000.0) tmp = (exp((x * (eps + -1.0))) + (1.0 - (eps * x))) / 2.0; else tmp = (2.0 / exp(x)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1.1e-286], N[(N[(1.0 + N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 155000000000.0], N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(1.0 - N[(eps * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{-286}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\mathbf{elif}\;x \leq 155000000000:\\
\;\;\;\;\frac{e^{x \cdot \left(\varepsilon + -1\right)} + \left(1 - \varepsilon \cdot x\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{e^{x}}}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (or (<= x -1e-296) (not (<= x 132000000000.0))) (/ (/ 2.0 (exp x)) 2.0) (/ (+ 1.0 (exp (* x (+ eps -1.0)))) 2.0)))
double code(double x, double eps) {
double tmp;
if ((x <= -1e-296) || !(x <= 132000000000.0)) {
tmp = (2.0 / exp(x)) / 2.0;
} else {
tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-1d-296)) .or. (.not. (x <= 132000000000.0d0))) then
tmp = (2.0d0 / exp(x)) / 2.0d0
else
tmp = (1.0d0 + exp((x * (eps + (-1.0d0))))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -1e-296) || !(x <= 132000000000.0)) {
tmp = (2.0 / Math.exp(x)) / 2.0;
} else {
tmp = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -1e-296) or not (x <= 132000000000.0): tmp = (2.0 / math.exp(x)) / 2.0 else: tmp = (1.0 + math.exp((x * (eps + -1.0)))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if ((x <= -1e-296) || !(x <= 132000000000.0)) tmp = Float64(Float64(2.0 / exp(x)) / 2.0); else tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -1e-296) || ~((x <= 132000000000.0))) tmp = (2.0 / exp(x)) / 2.0; else tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -1e-296], N[Not[LessEqual[x, 132000000000.0]], $MachinePrecision]], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-296} \lor \neg \left(x \leq 132000000000\right):\\
\;\;\;\;\frac{\frac{2}{e^{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(if (<= x -1e-296)
(/ (+ 1.0 (exp (* eps (- x)))) 2.0)
(if (<= x 235000000000.0)
(/ (+ 1.0 (exp (* x (+ eps -1.0)))) 2.0)
(/ (/ 2.0 (exp x)) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -1e-296) {
tmp = (1.0 + exp((eps * -x))) / 2.0;
} else if (x <= 235000000000.0) {
tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0;
} else {
tmp = (2.0 / exp(x)) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1d-296)) then
tmp = (1.0d0 + exp((eps * -x))) / 2.0d0
else if (x <= 235000000000.0d0) then
tmp = (1.0d0 + exp((x * (eps + (-1.0d0))))) / 2.0d0
else
tmp = (2.0d0 / exp(x)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -1e-296) {
tmp = (1.0 + Math.exp((eps * -x))) / 2.0;
} else if (x <= 235000000000.0) {
tmp = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
} else {
tmp = (2.0 / Math.exp(x)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -1e-296: tmp = (1.0 + math.exp((eps * -x))) / 2.0 elif x <= 235000000000.0: tmp = (1.0 + math.exp((x * (eps + -1.0)))) / 2.0 else: tmp = (2.0 / math.exp(x)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -1e-296) tmp = Float64(Float64(1.0 + exp(Float64(eps * Float64(-x)))) / 2.0); elseif (x <= 235000000000.0) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) / 2.0); else tmp = Float64(Float64(2.0 / exp(x)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1e-296) tmp = (1.0 + exp((eps * -x))) / 2.0; elseif (x <= 235000000000.0) tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0; else tmp = (2.0 / exp(x)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -1e-296], N[(N[(1.0 + N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 235000000000.0], N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-296}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\mathbf{elif}\;x \leq 235000000000:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{e^{x}}}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (/ (/ 2.0 (exp x)) 2.0))
double code(double x, double eps) {
return (2.0 / exp(x)) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (2.0d0 / exp(x)) / 2.0d0
end function
public static double code(double x, double eps) {
return (2.0 / Math.exp(x)) / 2.0;
}
def code(x, eps): return (2.0 / math.exp(x)) / 2.0
function code(x, eps) return Float64(Float64(2.0 / exp(x)) / 2.0) end
function tmp = code(x, eps) tmp = (2.0 / exp(x)) / 2.0; end
code[x_, eps_] := N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{e^{x}}}{2}
\end{array}
(FPCore (x eps) :precision binary64 (if (<= x 2.0) (/ (+ (* x (- -1.0 eps)) 2.0) 2.0) (/ (+ (+ 1.0 (/ 1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 2.0) {
tmp = ((x * (-1.0 - eps)) + 2.0) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 2.0d0) then
tmp = ((x * ((-1.0d0) - eps)) + 2.0d0) / 2.0d0
else
tmp = ((1.0d0 + (1.0d0 / eps)) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 2.0) {
tmp = ((x * (-1.0 - eps)) + 2.0) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 2.0: tmp = ((x * (-1.0 - eps)) + 2.0) / 2.0 else: tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 2.0) tmp = Float64(Float64(Float64(x * Float64(-1.0 - eps)) + 2.0) / 2.0); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 2.0) tmp = ((x * (-1.0 - eps)) + 2.0) / 2.0; else tmp = ((1.0 + (1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 2.0], N[(N[(N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\frac{x \cdot \left(-1 - \varepsilon\right) + 2}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (<= x -0.064) (/ (+ (* x (- -1.0 eps)) 2.0) 2.0) (/ (+ 2.0 (* eps x)) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -0.064) {
tmp = ((x * (-1.0 - eps)) + 2.0) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-0.064d0)) then
tmp = ((x * ((-1.0d0) - eps)) + 2.0d0) / 2.0d0
else
tmp = (2.0d0 + (eps * x)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -0.064) {
tmp = ((x * (-1.0 - eps)) + 2.0) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -0.064: tmp = ((x * (-1.0 - eps)) + 2.0) / 2.0 else: tmp = (2.0 + (eps * x)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -0.064) tmp = Float64(Float64(Float64(x * Float64(-1.0 - eps)) + 2.0) / 2.0); else tmp = Float64(Float64(2.0 + Float64(eps * x)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -0.064) tmp = ((x * (-1.0 - eps)) + 2.0) / 2.0; else tmp = (2.0 + (eps * x)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -0.064], N[(N[(N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.064:\\
\;\;\;\;\frac{x \cdot \left(-1 - \varepsilon\right) + 2}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (<= x 35.0) 1.0 (/ (* eps x) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 35.0) {
tmp = 1.0;
} else {
tmp = (eps * x) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 35.0d0) then
tmp = 1.0d0
else
tmp = (eps * x) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 35.0) {
tmp = 1.0;
} else {
tmp = (eps * x) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 35.0: tmp = 1.0 else: tmp = (eps * x) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 35.0) tmp = 1.0; else tmp = Float64(Float64(eps * x) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 35.0) tmp = 1.0; else tmp = (eps * x) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 35.0], 1.0, N[(N[(eps * x), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 35:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\varepsilon \cdot x}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (/ (+ 2.0 (* eps x)) 2.0))
double code(double x, double eps) {
return (2.0 + (eps * x)) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (2.0d0 + (eps * x)) / 2.0d0
end function
public static double code(double x, double eps) {
return (2.0 + (eps * x)) / 2.0;
}
def code(x, eps): return (2.0 + (eps * x)) / 2.0
function code(x, eps) return Float64(Float64(2.0 + Float64(eps * x)) / 2.0) end
function tmp = code(x, eps) tmp = (2.0 + (eps * x)) / 2.0; end
code[x_, eps_] := N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 + \varepsilon \cdot x}{2}
\end{array}
(FPCore (x eps) :precision binary64 1.0)
double code(double x, double eps) {
return 1.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0
end function
public static double code(double x, double eps) {
return 1.0;
}
def code(x, eps): return 1.0
function code(x, eps) return 1.0 end
function tmp = code(x, eps) tmp = 1.0; end
code[x_, eps_] := 1.0
\begin{array}{l}
\\
1
\end{array}
herbie shell --seed 2024006
(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))