
(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 (/ (+ (pow (exp -1.0) (* x (- 1.0 eps))) (exp (* x (- -1.0 eps)))) 2.0))
double code(double x, double eps) {
return (pow(exp(-1.0), (x * (1.0 - eps))) + exp((x * (-1.0 - eps)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((exp((-1.0d0)) ** (x * (1.0d0 - eps))) + exp((x * ((-1.0d0) - eps)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (Math.pow(Math.exp(-1.0), (x * (1.0 - eps))) + Math.exp((x * (-1.0 - eps)))) / 2.0;
}
def code(x, eps): return (math.pow(math.exp(-1.0), (x * (1.0 - eps))) + math.exp((x * (-1.0 - eps)))) / 2.0
function code(x, eps) return Float64(Float64((exp(-1.0) ^ Float64(x * Float64(1.0 - eps))) + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0) end
function tmp = code(x, eps) tmp = ((exp(-1.0) ^ (x * (1.0 - eps))) + exp((x * (-1.0 - eps)))) / 2.0; end
code[x_, eps_] := N[(N[(N[Power[N[Exp[-1.0], $MachinePrecision], N[(x * N[(1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(e^{-1}\right)}^{\left(x \cdot \left(1 - \varepsilon\right)\right)} + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}
\end{array}
(FPCore (x eps) :precision binary64 (/ (+ (exp (* x (+ -1.0 eps))) (exp (* x (- -1.0 eps)))) 2.0))
double code(double x, double eps) {
return (exp((x * (-1.0 + eps))) + exp((x * (-1.0 - eps)))) / 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 * ((-1.0d0) - eps)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (Math.exp((x * (-1.0 + eps))) + Math.exp((x * (-1.0 - eps)))) / 2.0;
}
def code(x, eps): return (math.exp((x * (-1.0 + eps))) + math.exp((x * (-1.0 - eps)))) / 2.0
function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(-1.0 + eps))) + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0) end
function tmp = code(x, eps) tmp = (exp((x * (-1.0 + eps))) + exp((x * (-1.0 - eps)))) / 2.0; end
code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{x \cdot \left(-1 + \varepsilon\right)} + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}
\end{array}
(FPCore (x eps) :precision binary64 (if (<= x -3.2e-232) (/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0) (/ (+ (exp (* x (+ -1.0 eps))) (exp (- x))) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -3.2e-232) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps))) + 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 <= (-3.2d-232)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else
tmp = (exp((x * ((-1.0d0) + eps))) + exp(-x)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -3.2e-232) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else {
tmp = (Math.exp((x * (-1.0 + eps))) + Math.exp(-x)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -3.2e-232: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 else: tmp = (math.exp((x * (-1.0 + eps))) + math.exp(-x)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -3.2e-232) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps))) + exp(Float64(-x))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -3.2e-232) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; else tmp = (exp((x * (-1.0 + eps))) + exp(-x)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -3.2e-232], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{-232}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + \varepsilon\right)} + e^{-x}}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (<= x -3.2e-232) (/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0) (/ (+ 1.0 (pow E (* x (+ -1.0 eps)))) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -3.2e-232) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else {
tmp = (1.0 + pow(((double) M_E), (x * (-1.0 + eps)))) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if (x <= -3.2e-232) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else {
tmp = (1.0 + Math.pow(Math.E, (x * (-1.0 + eps)))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -3.2e-232: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 else: tmp = (1.0 + math.pow(math.e, (x * (-1.0 + eps)))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -3.2e-232) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); else tmp = Float64(Float64(1.0 + (exp(1) ^ Float64(x * Float64(-1.0 + eps)))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -3.2e-232) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; else tmp = (1.0 + (2.71828182845904523536 ^ (x * (-1.0 + eps)))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -3.2e-232], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Power[E, N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{-232}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + {e}^{\left(x \cdot \left(-1 + \varepsilon\right)\right)}}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (<= x -3.2e-232) (/ (+ 1.0 (exp (- x))) 2.0) (/ (+ 1.0 (exp (* x (+ -1.0 eps)))) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -3.2e-232) {
tmp = (1.0 + exp(-x)) / 2.0;
} else {
tmp = (1.0 + exp((x * (-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 <= (-3.2d-232)) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else
tmp = (1.0d0 + exp((x * ((-1.0d0) + eps)))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -3.2e-232) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else {
tmp = (1.0 + Math.exp((x * (-1.0 + eps)))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -3.2e-232: tmp = (1.0 + math.exp(-x)) / 2.0 else: tmp = (1.0 + math.exp((x * (-1.0 + eps)))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -3.2e-232) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); else tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 + eps)))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -3.2e-232) tmp = (1.0 + exp(-x)) / 2.0; else tmp = (1.0 + exp((x * (-1.0 + eps)))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -3.2e-232], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{-232}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 + \varepsilon\right)}}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (<= x -3.2e-232) (/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0) (/ (+ 1.0 (exp (* x (+ -1.0 eps)))) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= -3.2e-232) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else {
tmp = (1.0 + exp((x * (-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 <= (-3.2d-232)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else
tmp = (1.0d0 + exp((x * ((-1.0d0) + eps)))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -3.2e-232) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else {
tmp = (1.0 + Math.exp((x * (-1.0 + eps)))) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -3.2e-232: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 else: tmp = (1.0 + math.exp((x * (-1.0 + eps)))) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -3.2e-232) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); else tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 + eps)))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -3.2e-232) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; else tmp = (1.0 + exp((x * (-1.0 + eps)))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -3.2e-232], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{-232}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 + \varepsilon\right)}}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (<= x -16500000.0) (/ (/ (expm1 (- x)) eps) 2.0) (if (<= x 30000000000.0) 1.0 (/ (/ (expm1 x) eps) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -16500000.0) {
tmp = (expm1(-x) / eps) / 2.0;
} else if (x <= 30000000000.0) {
tmp = 1.0;
} else {
tmp = (expm1(x) / eps) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if (x <= -16500000.0) {
tmp = (Math.expm1(-x) / eps) / 2.0;
} else if (x <= 30000000000.0) {
tmp = 1.0;
} else {
tmp = (Math.expm1(x) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -16500000.0: tmp = (math.expm1(-x) / eps) / 2.0 elif x <= 30000000000.0: tmp = 1.0 else: tmp = (math.expm1(x) / eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -16500000.0) tmp = Float64(Float64(expm1(Float64(-x)) / eps) / 2.0); elseif (x <= 30000000000.0) tmp = 1.0; else tmp = Float64(Float64(expm1(x) / eps) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -16500000.0], N[(N[(N[(Exp[(-x)] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 30000000000.0], 1.0, N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -16500000:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(-x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 30000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (if (<= x 30000000000.0) (/ (+ 1.0 (exp (- x))) 2.0) (/ (/ (expm1 x) eps) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 30000000000.0) {
tmp = (1.0 + exp(-x)) / 2.0;
} else {
tmp = (expm1(x) / eps) / 2.0;
}
return tmp;
}
public static double code(double x, double eps) {
double tmp;
if (x <= 30000000000.0) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else {
tmp = (Math.expm1(x) / eps) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 30000000000.0: tmp = (1.0 + math.exp(-x)) / 2.0 else: tmp = (math.expm1(x) / eps) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 30000000000.0) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); else tmp = Float64(Float64(expm1(x) / eps) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 30000000000.0], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 30000000000:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* x (- 1.0 eps))))
(if (<= eps 9500.0)
1.0
(/ (+ (+ (- 1.0 t_0) (* 0.5 (* t_0 t_0))) (+ 1.0 (/ -1.0 eps))) 2.0))))
double code(double x, double eps) {
double t_0 = x * (1.0 - eps);
double tmp;
if (eps <= 9500.0) {
tmp = 1.0;
} else {
tmp = (((1.0 - t_0) + (0.5 * (t_0 * t_0))) + (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) :: t_0
real(8) :: tmp
t_0 = x * (1.0d0 - eps)
if (eps <= 9500.0d0) then
tmp = 1.0d0
else
tmp = (((1.0d0 - t_0) + (0.5d0 * (t_0 * t_0))) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = x * (1.0 - eps);
double tmp;
if (eps <= 9500.0) {
tmp = 1.0;
} else {
tmp = (((1.0 - t_0) + (0.5 * (t_0 * t_0))) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = x * (1.0 - eps) tmp = 0 if eps <= 9500.0: tmp = 1.0 else: tmp = (((1.0 - t_0) + (0.5 * (t_0 * t_0))) + (1.0 + (-1.0 / eps))) / 2.0 return tmp
function code(x, eps) t_0 = Float64(x * Float64(1.0 - eps)) tmp = 0.0 if (eps <= 9500.0) tmp = 1.0; else tmp = Float64(Float64(Float64(Float64(1.0 - t_0) + Float64(0.5 * Float64(t_0 * t_0))) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = x * (1.0 - eps); tmp = 0.0; if (eps <= 9500.0) tmp = 1.0; else tmp = (((1.0 - t_0) + (0.5 * (t_0 * t_0))) + (1.0 + (-1.0 / eps))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(x * N[(1.0 - eps), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, 9500.0], 1.0, N[(N[(N[(N[(1.0 - t$95$0), $MachinePrecision] + N[(0.5 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \varepsilon\right)\\
\mathbf{if}\;\varepsilon \leq 9500:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(1 - t_0\right) + 0.5 \cdot \left(t_0 \cdot t_0\right)\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* x (- 1.0 eps))))
(if (<= eps 9000.0)
1.0
(/
(+
(+ (- 1.0 t_0) (* 0.5 (* x (* (- 1.0 eps) t_0))))
(+ 1.0 (/ -1.0 eps)))
2.0))))
double code(double x, double eps) {
double t_0 = x * (1.0 - eps);
double tmp;
if (eps <= 9000.0) {
tmp = 1.0;
} else {
tmp = (((1.0 - t_0) + (0.5 * (x * ((1.0 - eps) * t_0)))) + (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) :: t_0
real(8) :: tmp
t_0 = x * (1.0d0 - eps)
if (eps <= 9000.0d0) then
tmp = 1.0d0
else
tmp = (((1.0d0 - t_0) + (0.5d0 * (x * ((1.0d0 - eps) * t_0)))) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = x * (1.0 - eps);
double tmp;
if (eps <= 9000.0) {
tmp = 1.0;
} else {
tmp = (((1.0 - t_0) + (0.5 * (x * ((1.0 - eps) * t_0)))) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = x * (1.0 - eps) tmp = 0 if eps <= 9000.0: tmp = 1.0 else: tmp = (((1.0 - t_0) + (0.5 * (x * ((1.0 - eps) * t_0)))) + (1.0 + (-1.0 / eps))) / 2.0 return tmp
function code(x, eps) t_0 = Float64(x * Float64(1.0 - eps)) tmp = 0.0 if (eps <= 9000.0) tmp = 1.0; else tmp = Float64(Float64(Float64(Float64(1.0 - t_0) + Float64(0.5 * Float64(x * Float64(Float64(1.0 - eps) * t_0)))) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = x * (1.0 - eps); tmp = 0.0; if (eps <= 9000.0) tmp = 1.0; else tmp = (((1.0 - t_0) + (0.5 * (x * ((1.0 - eps) * t_0)))) + (1.0 + (-1.0 / eps))) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(x * N[(1.0 - eps), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, 9000.0], 1.0, N[(N[(N[(N[(1.0 - t$95$0), $MachinePrecision] + N[(0.5 * N[(x * N[(N[(1.0 - eps), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \varepsilon\right)\\
\mathbf{if}\;\varepsilon \leq 9000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(1 - t_0\right) + 0.5 \cdot \left(x \cdot \left(\left(1 - \varepsilon\right) \cdot t_0\right)\right)\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (/ -1.0 eps))))
(if (<= x -0.0012)
(/ (- 2.0 (* x (* (+ 1.0 eps) t_0))) 2.0)
(if (<= x 1.6e-11)
1.0
(if (<= x 1.45e+83)
(/ (+ (- 1.0 (/ -1.0 eps)) t_0) 2.0)
(/ (+ 2.0 (* x eps)) 2.0))))))
double code(double x, double eps) {
double t_0 = 1.0 + (-1.0 / eps);
double tmp;
if (x <= -0.0012) {
tmp = (2.0 - (x * ((1.0 + eps) * t_0))) / 2.0;
} else if (x <= 1.6e-11) {
tmp = 1.0;
} else if (x <= 1.45e+83) {
tmp = ((1.0 - (-1.0 / eps)) + t_0) / 2.0;
} else {
tmp = (2.0 + (x * eps)) / 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)
if (x <= (-0.0012d0)) then
tmp = (2.0d0 - (x * ((1.0d0 + eps) * t_0))) / 2.0d0
else if (x <= 1.6d-11) then
tmp = 1.0d0
else if (x <= 1.45d+83) then
tmp = ((1.0d0 - ((-1.0d0) / eps)) + t_0) / 2.0d0
else
tmp = (2.0d0 + (x * eps)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 + (-1.0 / eps);
double tmp;
if (x <= -0.0012) {
tmp = (2.0 - (x * ((1.0 + eps) * t_0))) / 2.0;
} else if (x <= 1.6e-11) {
tmp = 1.0;
} else if (x <= 1.45e+83) {
tmp = ((1.0 - (-1.0 / eps)) + t_0) / 2.0;
} else {
tmp = (2.0 + (x * eps)) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = 1.0 + (-1.0 / eps) tmp = 0 if x <= -0.0012: tmp = (2.0 - (x * ((1.0 + eps) * t_0))) / 2.0 elif x <= 1.6e-11: tmp = 1.0 elif x <= 1.45e+83: tmp = ((1.0 - (-1.0 / eps)) + t_0) / 2.0 else: tmp = (2.0 + (x * eps)) / 2.0 return tmp
function code(x, eps) t_0 = Float64(1.0 + Float64(-1.0 / eps)) tmp = 0.0 if (x <= -0.0012) tmp = Float64(Float64(2.0 - Float64(x * Float64(Float64(1.0 + eps) * t_0))) / 2.0); elseif (x <= 1.6e-11) tmp = 1.0; elseif (x <= 1.45e+83) tmp = Float64(Float64(Float64(1.0 - Float64(-1.0 / eps)) + t_0) / 2.0); else tmp = Float64(Float64(2.0 + Float64(x * eps)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 + (-1.0 / eps); tmp = 0.0; if (x <= -0.0012) tmp = (2.0 - (x * ((1.0 + eps) * t_0))) / 2.0; elseif (x <= 1.6e-11) tmp = 1.0; elseif (x <= 1.45e+83) tmp = ((1.0 - (-1.0 / eps)) + t_0) / 2.0; else tmp = (2.0 + (x * eps)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.0012], N[(N[(2.0 - N[(x * N[(N[(1.0 + eps), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.6e-11], 1.0, If[LessEqual[x, 1.45e+83], N[(N[(N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{-1}{\varepsilon}\\
\mathbf{if}\;x \leq -0.0012:\\
\;\;\;\;\frac{2 - x \cdot \left(\left(1 + \varepsilon\right) \cdot t_0\right)}{2}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{-11}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{+83}:\\
\;\;\;\;\frac{\left(1 - \frac{-1}{\varepsilon}\right) + t_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + x \cdot \varepsilon}{2}\\
\end{array}
\end{array}
(FPCore (x eps)
:precision binary64
(if (<= x 1.6e-11)
1.0
(if (<= x 1e+85)
(/ (+ (- 1.0 (/ -1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)
(/ (+ 2.0 (* x eps)) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= 1.6e-11) {
tmp = 1.0;
} else if (x <= 1e+85) {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (2.0 + (x * 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 <= 1.6d-11) then
tmp = 1.0d0
else if (x <= 1d+85) then
tmp = ((1.0d0 - ((-1.0d0) / eps)) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
else
tmp = (2.0d0 + (x * eps)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 1.6e-11) {
tmp = 1.0;
} else if (x <= 1e+85) {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = (2.0 + (x * eps)) / 2.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 1.6e-11: tmp = 1.0 elif x <= 1e+85: tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 else: tmp = (2.0 + (x * eps)) / 2.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 1.6e-11) tmp = 1.0; elseif (x <= 1e+85) tmp = Float64(Float64(Float64(1.0 - Float64(-1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); else tmp = Float64(Float64(2.0 + Float64(x * eps)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 1.6e-11) tmp = 1.0; elseif (x <= 1e+85) tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0; else tmp = (2.0 + (x * eps)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 1.6e-11], 1.0, If[LessEqual[x, 1e+85], N[(N[(N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6 \cdot 10^{-11}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 10^{+85}:\\
\;\;\;\;\frac{\left(1 - \frac{-1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + x \cdot \varepsilon}{2}\\
\end{array}
\end{array}
(FPCore (x eps) :precision binary64 (/ (+ 2.0 (* x eps)) 2.0))
double code(double x, double eps) {
return (2.0 + (x * eps)) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (2.0d0 + (x * eps)) / 2.0d0
end function
public static double code(double x, double eps) {
return (2.0 + (x * eps)) / 2.0;
}
def code(x, eps): return (2.0 + (x * eps)) / 2.0
function code(x, eps) return Float64(Float64(2.0 + Float64(x * eps)) / 2.0) end
function tmp = code(x, eps) tmp = (2.0 + (x * eps)) / 2.0; end
code[x_, eps_] := N[(N[(2.0 + N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 + x \cdot \varepsilon}{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 2023347
(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))