
(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 11 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 0.55) (/ (* 2.0 (exp (- x))) 2.0) (/ (+ (exp (* x eps_m)) (exp (* x (- eps_m)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.55) {
tmp = (2.0 * exp(-x)) / 2.0;
} else {
tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 0.55d0) then
tmp = (2.0d0 * exp(-x)) / 2.0d0
else
tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.55) {
tmp = (2.0 * Math.exp(-x)) / 2.0;
} else {
tmp = (Math.exp((x * eps_m)) + Math.exp((x * -eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 0.55: tmp = (2.0 * math.exp(-x)) / 2.0 else: tmp = (math.exp((x * eps_m)) + math.exp((x * -eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 0.55) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0); else tmp = Float64(Float64(exp(Float64(x * eps_m)) + exp(Float64(x * Float64(-eps_m)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 0.55) tmp = (2.0 * exp(-x)) / 2.0; else tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 0.55], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps_m \leq 0.55:\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot eps_m} + e^{x \cdot \left(-eps_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 0.55000000000000004Initial program 62.2%
fma-neg62.3%
/-rgt-identity62.3%
fma-neg62.2%
/-rgt-identity62.2%
distribute-rgt-neg-in62.2%
sub-neg62.2%
metadata-eval62.2%
distribute-rgt-neg-in62.2%
Simplified62.2%
Taylor expanded in eps around inf 98.3%
Taylor expanded in eps around 0 82.0%
cancel-sign-sub-inv82.0%
metadata-eval82.0%
distribute-rgt1-in82.0%
metadata-eval82.0%
mul-1-neg82.0%
Simplified82.0%
if 0.55000000000000004 < eps Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in eps around inf 99.9%
Taylor expanded in eps around -inf 99.9%
mul-1-neg99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-rgt-neg-in99.9%
mul-1-neg99.9%
associate-*r*99.9%
mul-1-neg99.9%
neg-mul-199.9%
Simplified99.9%
Taylor expanded in eps around inf 99.9%
mul-1-neg99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification87.6%
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}
Initial program 73.9%
fma-neg73.9%
/-rgt-identity73.9%
fma-neg73.9%
/-rgt-identity73.9%
distribute-rgt-neg-in73.9%
sub-neg73.9%
metadata-eval73.9%
distribute-rgt-neg-in73.9%
Simplified73.9%
Taylor expanded in eps around inf 98.8%
Taylor expanded in eps around -inf 98.8%
mul-1-neg98.8%
neg-mul-198.8%
sub-neg98.8%
distribute-rgt-neg-in98.8%
mul-1-neg98.8%
associate-*r*98.8%
mul-1-neg98.8%
neg-mul-198.8%
Simplified98.8%
Final simplification98.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 26000.0)
(/ (+ 1.0 (exp (* x (- -1.0 eps_m)))) 2.0)
(if (<= x 9e+185)
(/
(+
(+ 1.0 (/ 1.0 eps_m))
(* (exp (+ x (* x eps_m))) (- (/ -1.0 eps_m) -1.0)))
2.0)
(/ (/ 2.0 (exp x)) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 26000.0) {
tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0;
} else if (x <= 9e+185) {
tmp = ((1.0 + (1.0 / eps_m)) + (exp((x + (x * eps_m))) * ((-1.0 / eps_m) - -1.0))) / 2.0;
} else {
tmp = (2.0 / exp(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 <= 26000.0d0) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps_m)))) / 2.0d0
else if (x <= 9d+185) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (exp((x + (x * eps_m))) * (((-1.0d0) / eps_m) - (-1.0d0)))) / 2.0d0
else
tmp = (2.0d0 / exp(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 <= 26000.0) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
} else if (x <= 9e+185) {
tmp = ((1.0 + (1.0 / eps_m)) + (Math.exp((x + (x * eps_m))) * ((-1.0 / eps_m) - -1.0))) / 2.0;
} else {
tmp = (2.0 / Math.exp(x)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 26000.0: tmp = (1.0 + math.exp((x * (-1.0 - eps_m)))) / 2.0 elif x <= 9e+185: tmp = ((1.0 + (1.0 / eps_m)) + (math.exp((x + (x * eps_m))) * ((-1.0 / eps_m) - -1.0))) / 2.0 else: tmp = (2.0 / math.exp(x)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 26000.0) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0); elseif (x <= 9e+185) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(exp(Float64(x + Float64(x * eps_m))) * Float64(Float64(-1.0 / eps_m) - -1.0))) / 2.0); else tmp = Float64(Float64(2.0 / exp(x)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 26000.0) tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0; elseif (x <= 9e+185) tmp = ((1.0 + (1.0 / eps_m)) + (exp((x + (x * eps_m))) * ((-1.0 / eps_m) - -1.0))) / 2.0; else tmp = (2.0 / exp(x)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 26000.0], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 9e+185], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 26000:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - eps_m\right)}}{2}\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+185}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + e^{x + x \cdot eps_m} \cdot \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{e^{x}}}{2}\\
\end{array}
\end{array}
if x < 26000Initial program 64.2%
fma-neg64.3%
/-rgt-identity64.3%
fma-neg64.2%
/-rgt-identity64.2%
distribute-rgt-neg-in64.2%
sub-neg64.2%
metadata-eval64.2%
distribute-rgt-neg-in64.2%
Simplified64.2%
Taylor expanded in x around 0 45.1%
Taylor expanded in eps around inf 79.2%
mul-1-neg79.2%
neg-mul-179.2%
distribute-rgt-neg-in79.2%
+-commutative79.2%
Simplified79.2%
Taylor expanded in x around inf 79.2%
associate-*r*79.2%
mul-1-neg79.2%
+-commutative79.2%
Simplified79.2%
if 26000 < x < 9.0000000000000004e185Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 30.1%
add-sqr-sqrt0.0%
+-commutative0.0%
sqrt-unprod38.4%
sqr-neg38.4%
sqrt-unprod38.4%
add-sqr-sqrt38.4%
distribute-lft1-in38.4%
Applied egg-rr38.4%
if 9.0000000000000004e185 < x Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around -inf 100.0%
mul-1-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-rgt-neg-in100.0%
mul-1-neg100.0%
associate-*r*100.0%
mul-1-neg100.0%
neg-mul-1100.0%
Simplified100.0%
Taylor expanded in eps around 0 61.5%
neg-mul-161.5%
exp-neg61.5%
associate-*r/61.5%
metadata-eval61.5%
Simplified61.5%
Final simplification70.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (* x (- -1.0 eps_m)))))
(if (<= eps_m 1.1e+164)
(/ (* 2.0 (exp (- x))) 2.0)
(if (<= eps_m 1.05e+271)
(/ (+ 1.0 (+ t_0 (* x eps_m))) 2.0)
(/ (+ 1.0 t_0) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp((x * (-1.0 - eps_m)));
double tmp;
if (eps_m <= 1.1e+164) {
tmp = (2.0 * exp(-x)) / 2.0;
} else if (eps_m <= 1.05e+271) {
tmp = (1.0 + (t_0 + (x * eps_m))) / 2.0;
} else {
tmp = (1.0 + 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 * ((-1.0d0) - eps_m)))
if (eps_m <= 1.1d+164) then
tmp = (2.0d0 * exp(-x)) / 2.0d0
else if (eps_m <= 1.05d+271) then
tmp = (1.0d0 + (t_0 + (x * eps_m))) / 2.0d0
else
tmp = (1.0d0 + 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 * (-1.0 - eps_m)));
double tmp;
if (eps_m <= 1.1e+164) {
tmp = (2.0 * Math.exp(-x)) / 2.0;
} else if (eps_m <= 1.05e+271) {
tmp = (1.0 + (t_0 + (x * eps_m))) / 2.0;
} else {
tmp = (1.0 + t_0) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp((x * (-1.0 - eps_m))) tmp = 0 if eps_m <= 1.1e+164: tmp = (2.0 * math.exp(-x)) / 2.0 elif eps_m <= 1.05e+271: tmp = (1.0 + (t_0 + (x * eps_m))) / 2.0 else: tmp = (1.0 + t_0) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(x * Float64(-1.0 - eps_m))) tmp = 0.0 if (eps_m <= 1.1e+164) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0); elseif (eps_m <= 1.05e+271) tmp = Float64(Float64(1.0 + Float64(t_0 + Float64(x * eps_m))) / 2.0); else tmp = Float64(Float64(1.0 + t_0) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp((x * (-1.0 - eps_m))); tmp = 0.0; if (eps_m <= 1.1e+164) tmp = (2.0 * exp(-x)) / 2.0; elseif (eps_m <= 1.05e+271) tmp = (1.0 + (t_0 + (x * eps_m))) / 2.0; else tmp = (1.0 + 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[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eps$95$m, 1.1e+164], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps$95$m, 1.05e+271], N[(N[(1.0 + N[(t$95$0 + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(-1 - eps_m\right)}\\
\mathbf{if}\;eps_m \leq 1.1 \cdot 10^{+164}:\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{elif}\;eps_m \leq 1.05 \cdot 10^{+271}:\\
\;\;\;\;\frac{1 + \left(t_0 + x \cdot eps_m\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + t_0}{2}\\
\end{array}
\end{array}
if eps < 1.10000000000000003e164Initial program 68.6%
fma-neg68.6%
/-rgt-identity68.6%
fma-neg68.6%
/-rgt-identity68.6%
distribute-rgt-neg-in68.6%
sub-neg68.6%
metadata-eval68.6%
distribute-rgt-neg-in68.6%
Simplified68.6%
Taylor expanded in eps around inf 98.6%
Taylor expanded in eps around 0 79.5%
cancel-sign-sub-inv79.5%
metadata-eval79.5%
distribute-rgt1-in79.5%
metadata-eval79.5%
mul-1-neg79.5%
Simplified79.5%
if 1.10000000000000003e164 < eps < 1.05e271Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 69.9%
Taylor expanded in eps around inf 69.9%
associate-*r*69.9%
remove-double-neg69.9%
neg-mul-169.9%
sub-neg69.9%
associate-*r*69.9%
associate--l+69.9%
*-commutative69.9%
mul-1-neg69.9%
mul-1-neg69.9%
distribute-rgt-neg-in69.9%
sub-neg69.9%
neg-mul-169.9%
remove-double-neg69.9%
+-commutative69.9%
Simplified69.9%
Taylor expanded in x around inf 69.9%
neg-mul-169.9%
distribute-rgt-neg-in69.9%
*-commutative69.9%
Simplified69.9%
if 1.05e271 < eps Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 73.6%
Taylor expanded in eps around inf 73.6%
mul-1-neg73.6%
neg-mul-173.6%
distribute-rgt-neg-in73.6%
+-commutative73.6%
Simplified73.6%
Taylor expanded in x around inf 73.6%
associate-*r*73.6%
mul-1-neg73.6%
+-commutative73.6%
Simplified73.6%
Final simplification78.0%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 0.55) (/ (* 2.0 (exp (- x))) 2.0) (/ (+ 1.0 (exp (* x (- -1.0 eps_m)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.55) {
tmp = (2.0 * exp(-x)) / 2.0;
} else {
tmp = (1.0 + exp((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 <= 0.55d0) then
tmp = (2.0d0 * exp(-x)) / 2.0d0
else
tmp = (1.0d0 + exp((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 <= 0.55) {
tmp = (2.0 * Math.exp(-x)) / 2.0;
} else {
tmp = (1.0 + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 0.55: tmp = (2.0 * math.exp(-x)) / 2.0 else: tmp = (1.0 + math.exp((x * (-1.0 - eps_m)))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 0.55) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0); else tmp = Float64(Float64(1.0 + exp(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 <= 0.55) tmp = (2.0 * exp(-x)) / 2.0; else tmp = (1.0 + exp((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, 0.55], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + 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|
\\
\begin{array}{l}
\mathbf{if}\;eps_m \leq 0.55:\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - eps_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 0.55000000000000004Initial program 62.2%
fma-neg62.3%
/-rgt-identity62.3%
fma-neg62.2%
/-rgt-identity62.2%
distribute-rgt-neg-in62.2%
sub-neg62.2%
metadata-eval62.2%
distribute-rgt-neg-in62.2%
Simplified62.2%
Taylor expanded in eps around inf 98.3%
Taylor expanded in eps around 0 82.0%
cancel-sign-sub-inv82.0%
metadata-eval82.0%
distribute-rgt1-in82.0%
metadata-eval82.0%
mul-1-neg82.0%
Simplified82.0%
if 0.55000000000000004 < eps Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 63.1%
Taylor expanded in eps around inf 63.1%
mul-1-neg63.1%
neg-mul-163.1%
distribute-rgt-neg-in63.1%
+-commutative63.1%
Simplified63.1%
Taylor expanded in x around inf 63.1%
associate-*r*63.1%
mul-1-neg63.1%
+-commutative63.1%
Simplified63.1%
Final simplification76.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (* 2.0 (exp (- x))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (2.0 * exp(-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 * exp(-x)) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (2.0 * Math.exp(-x)) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (2.0 * math.exp(-x)) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(2.0 * exp(Float64(-x))) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (2.0 * exp(-x)) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{2 \cdot e^{-x}}{2}
\end{array}
Initial program 73.9%
fma-neg73.9%
/-rgt-identity73.9%
fma-neg73.9%
/-rgt-identity73.9%
distribute-rgt-neg-in73.9%
sub-neg73.9%
metadata-eval73.9%
distribute-rgt-neg-in73.9%
Simplified73.9%
Taylor expanded in eps around inf 98.8%
Taylor expanded in eps around 0 71.9%
cancel-sign-sub-inv71.9%
metadata-eval71.9%
distribute-rgt1-in71.9%
metadata-eval71.9%
mul-1-neg71.9%
Simplified71.9%
Final simplification71.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (/ 2.0 (exp x)) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (2.0 / exp(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 / exp(x)) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (2.0 / Math.exp(x)) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (2.0 / math.exp(x)) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(2.0 / exp(x)) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (2.0 / exp(x)) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{\frac{2}{e^{x}}}{2}
\end{array}
Initial program 73.9%
fma-neg73.9%
/-rgt-identity73.9%
fma-neg73.9%
/-rgt-identity73.9%
distribute-rgt-neg-in73.9%
sub-neg73.9%
metadata-eval73.9%
distribute-rgt-neg-in73.9%
Simplified73.9%
Taylor expanded in eps around inf 98.8%
Taylor expanded in eps around -inf 98.8%
mul-1-neg98.8%
neg-mul-198.8%
sub-neg98.8%
distribute-rgt-neg-in98.8%
mul-1-neg98.8%
associate-*r*98.8%
mul-1-neg98.8%
neg-mul-198.8%
Simplified98.8%
Taylor expanded in eps around 0 71.9%
neg-mul-171.9%
exp-neg71.9%
associate-*r/71.9%
metadata-eval71.9%
Simplified71.9%
Final simplification71.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 330.0) (/ (- 2.0 (* x eps_m)) 2.0) (/ (/ 0.0 eps_m) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 330.0) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else {
tmp = (0.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 (x <= 330.0d0) then
tmp = (2.0d0 - (x * eps_m)) / 2.0d0
else
tmp = (0.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 (x <= 330.0) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else {
tmp = (0.0 / eps_m) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 330.0: tmp = (2.0 - (x * eps_m)) / 2.0 else: tmp = (0.0 / eps_m) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 330.0) tmp = Float64(Float64(2.0 - Float64(x * eps_m)) / 2.0); else tmp = Float64(Float64(0.0 / eps_m) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 330.0) tmp = (2.0 - (x * eps_m)) / 2.0; else tmp = (0.0 / eps_m) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 330.0], N[(N[(2.0 - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.0 / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 330:\\
\;\;\;\;\frac{2 - x \cdot eps_m}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0}{eps_m}}{2}\\
\end{array}
\end{array}
if x < 330Initial program 64.1%
fma-neg64.1%
/-rgt-identity64.1%
fma-neg64.1%
/-rgt-identity64.1%
distribute-rgt-neg-in64.1%
sub-neg64.1%
metadata-eval64.1%
distribute-rgt-neg-in64.1%
Simplified64.1%
Taylor expanded in x around 0 45.4%
Taylor expanded in x around 0 33.5%
Taylor expanded in eps around inf 68.0%
mul-1-neg68.0%
*-commutative68.0%
unsub-neg68.0%
Simplified68.0%
if 330 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 45.2%
Taylor expanded in x around 0 45.2%
Final simplification61.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 54.0) 1.0 (/ (* x eps_m) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 54.0) {
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 <= 54.0d0) 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 <= 54.0) {
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 <= 54.0: 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 <= 54.0) 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 <= 54.0) 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, 54.0], 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 54:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps_m}{2}\\
\end{array}
\end{array}
if x < 54Initial program 64.4%
fma-neg64.4%
/-rgt-identity64.4%
fma-neg64.4%
/-rgt-identity64.4%
distribute-rgt-neg-in64.4%
sub-neg64.4%
metadata-eval64.4%
distribute-rgt-neg-in64.4%
Simplified64.4%
Taylor expanded in x around 0 62.6%
if 54 < x Initial program 98.7%
fma-neg98.6%
/-rgt-identity98.6%
fma-neg98.7%
/-rgt-identity98.7%
distribute-rgt-neg-in98.7%
sub-neg98.7%
metadata-eval98.7%
distribute-rgt-neg-in98.7%
Simplified98.7%
Taylor expanded in x around 0 32.6%
Taylor expanded in x around inf 18.6%
mul-1-neg18.6%
associate-*r*18.6%
*-commutative18.6%
distribute-rgt-neg-in18.6%
distribute-rgt-neg-in18.6%
distribute-neg-in18.6%
metadata-eval18.6%
distribute-neg-frac18.6%
metadata-eval18.6%
Simplified18.6%
Taylor expanded in eps around inf 19.4%
*-commutative19.4%
Simplified19.4%
Final simplification50.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 520.0) 1.0 (/ (/ 0.0 eps_m) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 520.0) {
tmp = 1.0;
} else {
tmp = (0.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 (x <= 520.0d0) then
tmp = 1.0d0
else
tmp = (0.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 (x <= 520.0) {
tmp = 1.0;
} else {
tmp = (0.0 / eps_m) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 520.0: tmp = 1.0 else: tmp = (0.0 / eps_m) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 520.0) tmp = 1.0; else tmp = Float64(Float64(0.0 / eps_m) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 520.0) tmp = 1.0; else tmp = (0.0 / eps_m) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 520.0], 1.0, N[(N[(0.0 / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 520:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0}{eps_m}}{2}\\
\end{array}
\end{array}
if x < 520Initial program 64.1%
fma-neg64.1%
/-rgt-identity64.1%
fma-neg64.1%
/-rgt-identity64.1%
distribute-rgt-neg-in64.1%
sub-neg64.1%
metadata-eval64.1%
distribute-rgt-neg-in64.1%
Simplified64.1%
Taylor expanded in x around 0 62.3%
if 520 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 45.2%
Taylor expanded in x around 0 45.2%
Final simplification57.6%
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}
Initial program 73.9%
fma-neg73.9%
/-rgt-identity73.9%
fma-neg73.9%
/-rgt-identity73.9%
distribute-rgt-neg-in73.9%
sub-neg73.9%
metadata-eval73.9%
distribute-rgt-neg-in73.9%
Simplified73.9%
Taylor expanded in x around 0 46.1%
Final simplification46.1%
herbie shell --seed 2024017
(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))