
(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 12 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
(let* ((t_0 (* (+ x 1.0) (exp (- x)))))
(if (<= eps_m 0.001)
(/ (+ t_0 t_0) 2.0)
(/
(-
(* (+ 1.0 (/ 1.0 eps_m)) (exp (* x (+ eps_m -1.0))))
(* (+ -1.0 (/ 1.0 eps_m)) (exp (* x (- -1.0 eps_m)))))
2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (x + 1.0) * exp(-x);
double tmp;
if (eps_m <= 0.001) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (((1.0 + (1.0 / eps_m)) * exp((x * (eps_m + -1.0)))) - ((-1.0 + (1.0 / eps_m)) * 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) :: t_0
real(8) :: tmp
t_0 = (x + 1.0d0) * exp(-x)
if (eps_m <= 0.001d0) then
tmp = (t_0 + t_0) / 2.0d0
else
tmp = (((1.0d0 + (1.0d0 / eps_m)) * exp((x * (eps_m + (-1.0d0))))) - (((-1.0d0) + (1.0d0 / eps_m)) * 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 t_0 = (x + 1.0) * Math.exp(-x);
double tmp;
if (eps_m <= 0.001) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (((1.0 + (1.0 / eps_m)) * Math.exp((x * (eps_m + -1.0)))) - ((-1.0 + (1.0 / eps_m)) * Math.exp((x * (-1.0 - eps_m))))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = (x + 1.0) * math.exp(-x) tmp = 0 if eps_m <= 0.001: tmp = (t_0 + t_0) / 2.0 else: tmp = (((1.0 + (1.0 / eps_m)) * math.exp((x * (eps_m + -1.0)))) - ((-1.0 + (1.0 / eps_m)) * math.exp((x * (-1.0 - eps_m))))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(x + 1.0) * exp(Float64(-x))) tmp = 0.0 if (eps_m <= 0.001) tmp = Float64(Float64(t_0 + t_0) / 2.0); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * exp(Float64(x * Float64(eps_m + -1.0)))) - Float64(Float64(-1.0 + Float64(1.0 / eps_m)) * 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) t_0 = (x + 1.0) * exp(-x); tmp = 0.0; if (eps_m <= 0.001) tmp = (t_0 + t_0) / 2.0; else tmp = (((1.0 + (1.0 / eps_m)) * exp((x * (eps_m + -1.0)))) - ((-1.0 + (1.0 / eps_m)) * exp((x * (-1.0 - eps_m))))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps$95$m, 0.001], N[(N[(t$95$0 + t$95$0), $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[(-1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \left(x + 1\right) \cdot e^{-x}\\
\mathbf{if}\;eps\_m \leq 0.001:\\
\;\;\;\;\frac{t\_0 + t\_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot e^{x \cdot \left(eps\_m + -1\right)} - \left(-1 + \frac{1}{eps\_m}\right) \cdot e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 1e-3Initial program 63.0%
fma-neg63.0%
/-rgt-identity63.0%
fma-neg63.0%
/-rgt-identity63.0%
distribute-rgt-neg-in63.0%
sub-neg63.0%
metadata-eval63.0%
distribute-rgt-neg-in63.0%
Simplified63.0%
Taylor expanded in eps around 0 69.5%
Simplified70.1%
if 1e-3 < eps Initial program 100.0%
Final simplification78.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* (+ x 1.0) (exp (- x)))))
(if (<= x -2e-262)
(/ (+ 1.0 (exp (* x (- 1.0 eps_m)))) 2.0)
(if (<= x 1.4e+42)
(/ (+ 1.0 (exp (* eps_m x))) 2.0)
(if (<= x 4.5e+74)
(/ (+ t_0 t_0) 2.0)
(if (or (<= x 3.5e+249) (not (<= x 1.66e+289)))
(/ (+ 1.0 (exp (* x (+ eps_m -1.0)))) 2.0)
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (+ 1.0 (/ -1.0 eps_m))) 2.0)))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (x + 1.0) * exp(-x);
double tmp;
if (x <= -2e-262) {
tmp = (1.0 + exp((x * (1.0 - eps_m)))) / 2.0;
} else if (x <= 1.4e+42) {
tmp = (1.0 + exp((eps_m * x))) / 2.0;
} else if (x <= 4.5e+74) {
tmp = (t_0 + t_0) / 2.0;
} else if ((x <= 3.5e+249) || !(x <= 1.66e+289)) {
tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0;
} else {
tmp = ((1.0 + (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) :: t_0
real(8) :: tmp
t_0 = (x + 1.0d0) * exp(-x)
if (x <= (-2d-262)) then
tmp = (1.0d0 + exp((x * (1.0d0 - eps_m)))) / 2.0d0
else if (x <= 1.4d+42) then
tmp = (1.0d0 + exp((eps_m * x))) / 2.0d0
else if (x <= 4.5d+74) then
tmp = (t_0 + t_0) / 2.0d0
else if ((x <= 3.5d+249) .or. (.not. (x <= 1.66d+289))) then
tmp = (1.0d0 + exp((x * (eps_m + (-1.0d0))))) / 2.0d0
else
tmp = ((1.0d0 + (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 t_0 = (x + 1.0) * Math.exp(-x);
double tmp;
if (x <= -2e-262) {
tmp = (1.0 + Math.exp((x * (1.0 - eps_m)))) / 2.0;
} else if (x <= 1.4e+42) {
tmp = (1.0 + Math.exp((eps_m * x))) / 2.0;
} else if (x <= 4.5e+74) {
tmp = (t_0 + t_0) / 2.0;
} else if ((x <= 3.5e+249) || !(x <= 1.66e+289)) {
tmp = (1.0 + Math.exp((x * (eps_m + -1.0)))) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = (x + 1.0) * math.exp(-x) tmp = 0 if x <= -2e-262: tmp = (1.0 + math.exp((x * (1.0 - eps_m)))) / 2.0 elif x <= 1.4e+42: tmp = (1.0 + math.exp((eps_m * x))) / 2.0 elif x <= 4.5e+74: tmp = (t_0 + t_0) / 2.0 elif (x <= 3.5e+249) or not (x <= 1.66e+289): tmp = (1.0 + math.exp((x * (eps_m + -1.0)))) / 2.0 else: tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(x + 1.0) * exp(Float64(-x))) tmp = 0.0 if (x <= -2e-262) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(1.0 - eps_m)))) / 2.0); elseif (x <= 1.4e+42) tmp = Float64(Float64(1.0 + exp(Float64(eps_m * x))) / 2.0); elseif (x <= 4.5e+74) tmp = Float64(Float64(t_0 + t_0) / 2.0); elseif ((x <= 3.5e+249) || !(x <= 1.66e+289)) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps_m + -1.0)))) / 2.0); else tmp = Float64(Float64(Float64(1.0 + 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) t_0 = (x + 1.0) * exp(-x); tmp = 0.0; if (x <= -2e-262) tmp = (1.0 + exp((x * (1.0 - eps_m)))) / 2.0; elseif (x <= 1.4e+42) tmp = (1.0 + exp((eps_m * x))) / 2.0; elseif (x <= 4.5e+74) tmp = (t_0 + t_0) / 2.0; elseif ((x <= 3.5e+249) || ~((x <= 1.66e+289))) tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0; else tmp = ((1.0 + (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_] := Block[{t$95$0 = N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2e-262], N[(N[(1.0 + N[Exp[N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.4e+42], N[(N[(1.0 + N[Exp[N[(eps$95$m * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 4.5e+74], N[(N[(t$95$0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 3.5e+249], N[Not[LessEqual[x, 1.66e+289]], $MachinePrecision]], N[(N[(1.0 + N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \left(x + 1\right) \cdot e^{-x}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-262}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(1 - eps\_m\right)}}{2}\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+42}:\\
\;\;\;\;\frac{1 + e^{eps\_m \cdot x}}{2}\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{+74}:\\
\;\;\;\;\frac{t\_0 + t\_0}{2}\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+249} \lor \neg \left(x \leq 1.66 \cdot 10^{+289}\right):\\
\;\;\;\;\frac{1 + e^{x \cdot \left(eps\_m + -1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\end{array}
\end{array}
if x < -2.00000000000000002e-262Initial program 71.5%
fma-neg71.4%
/-rgt-identity71.4%
fma-neg71.5%
/-rgt-identity71.5%
distribute-rgt-neg-in71.5%
sub-neg71.5%
metadata-eval71.5%
distribute-rgt-neg-in71.5%
Simplified71.5%
Taylor expanded in x around 0 46.0%
add-log-exp46.0%
*-un-lft-identity46.0%
log-prod46.0%
metadata-eval46.0%
add-log-exp46.0%
add-sqr-sqrt46.0%
sqrt-unprod44.1%
sqr-neg44.1%
sqrt-prod0.0%
add-sqr-sqrt41.4%
Applied egg-rr41.4%
+-lft-identity41.4%
*-commutative41.4%
Simplified41.4%
Taylor expanded in eps around inf 68.0%
if -2.00000000000000002e-262 < x < 1.4e42Initial program 56.3%
fma-neg56.4%
/-rgt-identity56.4%
fma-neg56.3%
/-rgt-identity56.3%
distribute-rgt-neg-in56.3%
sub-neg56.3%
metadata-eval56.3%
distribute-rgt-neg-in56.3%
Simplified56.3%
Taylor expanded in x around 0 40.9%
Taylor expanded in eps around inf 83.8%
exp-prod83.8%
*-commutative83.8%
sub-neg83.8%
mul-1-neg83.8%
*-commutative83.8%
exp-prod83.8%
associate-*r*83.8%
mul-1-neg83.8%
mul-1-neg83.8%
sub-neg83.8%
Simplified83.8%
Taylor expanded in eps around inf 84.6%
*-commutative84.6%
Simplified84.6%
if 1.4e42 < x < 4.5e74Initial 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 0 89.1%
Simplified89.1%
if 4.5e74 < x < 3.50000000000000012e249 or 1.6600000000000001e289 < 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 x around 0 40.5%
Taylor expanded in eps around inf 40.7%
exp-prod40.7%
*-commutative40.7%
sub-neg40.7%
mul-1-neg40.7%
*-commutative40.7%
exp-prod40.7%
associate-*r*40.7%
mul-1-neg40.7%
mul-1-neg40.7%
sub-neg40.7%
Simplified40.7%
if 3.50000000000000012e249 < x < 1.6600000000000001e289Initial 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 15.5%
Taylor expanded in x around 0 74.2%
Final simplification70.2%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -2.7e-263)
(/ (+ 1.0 (exp (* x (- 1.0 eps_m)))) 2.0)
(if (<= x 3.5e+41)
(/ (+ 1.0 (exp (* eps_m x))) 2.0)
(if (<= x 3.8e+74)
(/ (/ (- t_0 t_0) eps_m) 2.0)
(if (or (<= x 3.6e+249) (not (<= x 1.15e+286)))
(/ (+ 1.0 (exp (* x (+ eps_m -1.0)))) 2.0)
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (+ 1.0 (/ -1.0 eps_m))) 2.0)))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (x <= -2.7e-263) {
tmp = (1.0 + exp((x * (1.0 - eps_m)))) / 2.0;
} else if (x <= 3.5e+41) {
tmp = (1.0 + exp((eps_m * x))) / 2.0;
} else if (x <= 3.8e+74) {
tmp = ((t_0 - t_0) / eps_m) / 2.0;
} else if ((x <= 3.6e+249) || !(x <= 1.15e+286)) {
tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0;
} else {
tmp = ((1.0 + (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) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (x <= (-2.7d-263)) then
tmp = (1.0d0 + exp((x * (1.0d0 - eps_m)))) / 2.0d0
else if (x <= 3.5d+41) then
tmp = (1.0d0 + exp((eps_m * x))) / 2.0d0
else if (x <= 3.8d+74) then
tmp = ((t_0 - t_0) / eps_m) / 2.0d0
else if ((x <= 3.6d+249) .or. (.not. (x <= 1.15d+286))) then
tmp = (1.0d0 + exp((x * (eps_m + (-1.0d0))))) / 2.0d0
else
tmp = ((1.0d0 + (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 t_0 = Math.exp(-x);
double tmp;
if (x <= -2.7e-263) {
tmp = (1.0 + Math.exp((x * (1.0 - eps_m)))) / 2.0;
} else if (x <= 3.5e+41) {
tmp = (1.0 + Math.exp((eps_m * x))) / 2.0;
} else if (x <= 3.8e+74) {
tmp = ((t_0 - t_0) / eps_m) / 2.0;
} else if ((x <= 3.6e+249) || !(x <= 1.15e+286)) {
tmp = (1.0 + Math.exp((x * (eps_m + -1.0)))) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp(-x) tmp = 0 if x <= -2.7e-263: tmp = (1.0 + math.exp((x * (1.0 - eps_m)))) / 2.0 elif x <= 3.5e+41: tmp = (1.0 + math.exp((eps_m * x))) / 2.0 elif x <= 3.8e+74: tmp = ((t_0 - t_0) / eps_m) / 2.0 elif (x <= 3.6e+249) or not (x <= 1.15e+286): tmp = (1.0 + math.exp((x * (eps_m + -1.0)))) / 2.0 else: tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -2.7e-263) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(1.0 - eps_m)))) / 2.0); elseif (x <= 3.5e+41) tmp = Float64(Float64(1.0 + exp(Float64(eps_m * x))) / 2.0); elseif (x <= 3.8e+74) tmp = Float64(Float64(Float64(t_0 - t_0) / eps_m) / 2.0); elseif ((x <= 3.6e+249) || !(x <= 1.15e+286)) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps_m + -1.0)))) / 2.0); else tmp = Float64(Float64(Float64(1.0 + 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) t_0 = exp(-x); tmp = 0.0; if (x <= -2.7e-263) tmp = (1.0 + exp((x * (1.0 - eps_m)))) / 2.0; elseif (x <= 3.5e+41) tmp = (1.0 + exp((eps_m * x))) / 2.0; elseif (x <= 3.8e+74) tmp = ((t_0 - t_0) / eps_m) / 2.0; elseif ((x <= 3.6e+249) || ~((x <= 1.15e+286))) tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0; else tmp = ((1.0 + (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_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -2.7e-263], N[(N[(1.0 + N[Exp[N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 3.5e+41], N[(N[(1.0 + N[Exp[N[(eps$95$m * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 3.8e+74], N[(N[(N[(t$95$0 - t$95$0), $MachinePrecision] / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 3.6e+249], N[Not[LessEqual[x, 1.15e+286]], $MachinePrecision]], N[(N[(1.0 + N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -2.7 \cdot 10^{-263}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(1 - eps\_m\right)}}{2}\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+41}:\\
\;\;\;\;\frac{1 + e^{eps\_m \cdot x}}{2}\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+74}:\\
\;\;\;\;\frac{\frac{t\_0 - t\_0}{eps\_m}}{2}\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{+249} \lor \neg \left(x \leq 1.15 \cdot 10^{+286}\right):\\
\;\;\;\;\frac{1 + e^{x \cdot \left(eps\_m + -1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\end{array}
\end{array}
if x < -2.70000000000000003e-263Initial program 71.5%
fma-neg71.4%
/-rgt-identity71.4%
fma-neg71.5%
/-rgt-identity71.5%
distribute-rgt-neg-in71.5%
sub-neg71.5%
metadata-eval71.5%
distribute-rgt-neg-in71.5%
Simplified71.5%
Taylor expanded in x around 0 46.0%
add-log-exp46.0%
*-un-lft-identity46.0%
log-prod46.0%
metadata-eval46.0%
add-log-exp46.0%
add-sqr-sqrt46.0%
sqrt-unprod44.1%
sqr-neg44.1%
sqrt-prod0.0%
add-sqr-sqrt41.4%
Applied egg-rr41.4%
+-lft-identity41.4%
*-commutative41.4%
Simplified41.4%
Taylor expanded in eps around inf 68.0%
if -2.70000000000000003e-263 < x < 3.4999999999999999e41Initial program 56.3%
fma-neg56.4%
/-rgt-identity56.4%
fma-neg56.3%
/-rgt-identity56.3%
distribute-rgt-neg-in56.3%
sub-neg56.3%
metadata-eval56.3%
distribute-rgt-neg-in56.3%
Simplified56.3%
Taylor expanded in x around 0 40.9%
Taylor expanded in eps around inf 83.8%
exp-prod83.8%
*-commutative83.8%
sub-neg83.8%
mul-1-neg83.8%
*-commutative83.8%
exp-prod83.8%
associate-*r*83.8%
mul-1-neg83.8%
mul-1-neg83.8%
sub-neg83.8%
Simplified83.8%
Taylor expanded in eps around inf 84.6%
*-commutative84.6%
Simplified84.6%
if 3.4999999999999999e41 < x < 3.7999999999999998e74Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 89.1%
inv-pow89.1%
Applied egg-rr89.1%
unpow-189.1%
rec-exp89.1%
Simplified89.1%
if 3.7999999999999998e74 < x < 3.5999999999999997e249 or 1.1500000000000001e286 < 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 x around 0 40.5%
Taylor expanded in eps around inf 40.7%
exp-prod40.7%
*-commutative40.7%
sub-neg40.7%
mul-1-neg40.7%
*-commutative40.7%
exp-prod40.7%
associate-*r*40.7%
mul-1-neg40.7%
mul-1-neg40.7%
sub-neg40.7%
Simplified40.7%
if 3.5999999999999997e249 < x < 1.1500000000000001e286Initial 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 15.5%
Taylor expanded in x around 0 74.2%
Final simplification70.2%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -2.7e-263)
(/ (+ 1.0 (exp (* x (- 1.0 eps_m)))) 2.0)
(if (<= x 1.2e+42)
(/ (+ 1.0 (exp (* eps_m x))) 2.0)
(if (or (<= x 3.9e+74) (and (not (<= x 3.1e+249)) (<= x 7.5e+287)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (+ 1.0 (/ -1.0 eps_m))) 2.0)
(/ (+ 1.0 (exp (* x (+ eps_m -1.0)))) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -2.7e-263) {
tmp = (1.0 + exp((x * (1.0 - eps_m)))) / 2.0;
} else if (x <= 1.2e+42) {
tmp = (1.0 + exp((eps_m * x))) / 2.0;
} else if ((x <= 3.9e+74) || (!(x <= 3.1e+249) && (x <= 7.5e+287))) {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
} else {
tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-2.7d-263)) then
tmp = (1.0d0 + exp((x * (1.0d0 - eps_m)))) / 2.0d0
else if (x <= 1.2d+42) then
tmp = (1.0d0 + exp((eps_m * x))) / 2.0d0
else if ((x <= 3.9d+74) .or. (.not. (x <= 3.1d+249)) .and. (x <= 7.5d+287)) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (1.0d0 + ((-1.0d0) / eps_m))) / 2.0d0
else
tmp = (1.0d0 + exp((x * (eps_m + (-1.0d0))))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -2.7e-263) {
tmp = (1.0 + Math.exp((x * (1.0 - eps_m)))) / 2.0;
} else if (x <= 1.2e+42) {
tmp = (1.0 + Math.exp((eps_m * x))) / 2.0;
} else if ((x <= 3.9e+74) || (!(x <= 3.1e+249) && (x <= 7.5e+287))) {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
} else {
tmp = (1.0 + Math.exp((x * (eps_m + -1.0)))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -2.7e-263: tmp = (1.0 + math.exp((x * (1.0 - eps_m)))) / 2.0 elif x <= 1.2e+42: tmp = (1.0 + math.exp((eps_m * x))) / 2.0 elif (x <= 3.9e+74) or (not (x <= 3.1e+249) and (x <= 7.5e+287)): tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0 else: tmp = (1.0 + math.exp((x * (eps_m + -1.0)))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -2.7e-263) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(1.0 - eps_m)))) / 2.0); elseif (x <= 1.2e+42) tmp = Float64(Float64(1.0 + exp(Float64(eps_m * x))) / 2.0); elseif ((x <= 3.9e+74) || (!(x <= 3.1e+249) && (x <= 7.5e+287))) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(1.0 + Float64(-1.0 / eps_m))) / 2.0); else tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps_m + -1.0)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -2.7e-263) tmp = (1.0 + exp((x * (1.0 - eps_m)))) / 2.0; elseif (x <= 1.2e+42) tmp = (1.0 + exp((eps_m * x))) / 2.0; elseif ((x <= 3.9e+74) || (~((x <= 3.1e+249)) && (x <= 7.5e+287))) tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0; else tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -2.7e-263], N[(N[(1.0 + N[Exp[N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.2e+42], N[(N[(1.0 + N[Exp[N[(eps$95$m * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 3.9e+74], And[N[Not[LessEqual[x, 3.1e+249]], $MachinePrecision], LessEqual[x, 7.5e+287]]], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-263}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(1 - eps\_m\right)}}{2}\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+42}:\\
\;\;\;\;\frac{1 + e^{eps\_m \cdot x}}{2}\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{+74} \lor \neg \left(x \leq 3.1 \cdot 10^{+249}\right) \land x \leq 7.5 \cdot 10^{+287}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(eps\_m + -1\right)}}{2}\\
\end{array}
\end{array}
if x < -2.70000000000000003e-263Initial program 71.5%
fma-neg71.4%
/-rgt-identity71.4%
fma-neg71.5%
/-rgt-identity71.5%
distribute-rgt-neg-in71.5%
sub-neg71.5%
metadata-eval71.5%
distribute-rgt-neg-in71.5%
Simplified71.5%
Taylor expanded in x around 0 46.0%
add-log-exp46.0%
*-un-lft-identity46.0%
log-prod46.0%
metadata-eval46.0%
add-log-exp46.0%
add-sqr-sqrt46.0%
sqrt-unprod44.1%
sqr-neg44.1%
sqrt-prod0.0%
add-sqr-sqrt41.4%
Applied egg-rr41.4%
+-lft-identity41.4%
*-commutative41.4%
Simplified41.4%
Taylor expanded in eps around inf 68.0%
if -2.70000000000000003e-263 < x < 1.1999999999999999e42Initial program 56.3%
fma-neg56.4%
/-rgt-identity56.4%
fma-neg56.3%
/-rgt-identity56.3%
distribute-rgt-neg-in56.3%
sub-neg56.3%
metadata-eval56.3%
distribute-rgt-neg-in56.3%
Simplified56.3%
Taylor expanded in x around 0 40.9%
Taylor expanded in eps around inf 83.8%
exp-prod83.8%
*-commutative83.8%
sub-neg83.8%
mul-1-neg83.8%
*-commutative83.8%
exp-prod83.8%
associate-*r*83.8%
mul-1-neg83.8%
mul-1-neg83.8%
sub-neg83.8%
Simplified83.8%
Taylor expanded in eps around inf 84.6%
*-commutative84.6%
Simplified84.6%
if 1.1999999999999999e42 < x < 3.90000000000000008e74 or 3.10000000000000015e249 < x < 7.4999999999999994e287Initial 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 14.6%
Taylor expanded in x around 0 75.8%
if 3.90000000000000008e74 < x < 3.10000000000000015e249 or 7.4999999999999994e287 < 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 x around 0 40.5%
Taylor expanded in eps around inf 40.7%
exp-prod40.7%
*-commutative40.7%
sub-neg40.7%
mul-1-neg40.7%
*-commutative40.7%
exp-prod40.7%
associate-*r*40.7%
mul-1-neg40.7%
mul-1-neg40.7%
sub-neg40.7%
Simplified40.7%
Final simplification69.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -2.7e-263)
(/ (+ 1.0 (exp (- x))) 2.0)
(if (or (<= x 8e+41)
(and (not (<= x 4.2e+74))
(or (<= x 1.3e+249) (not (<= x 6.5e+286)))))
(/ (+ 1.0 (exp (* eps_m x))) 2.0)
(/ (+ (+ 1.0 (/ 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 (x <= -2.7e-263) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if ((x <= 8e+41) || (!(x <= 4.2e+74) && ((x <= 1.3e+249) || !(x <= 6.5e+286)))) {
tmp = (1.0 + exp((eps_m * x))) / 2.0;
} else {
tmp = ((1.0 + (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 (x <= (-2.7d-263)) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else if ((x <= 8d+41) .or. (.not. (x <= 4.2d+74)) .and. (x <= 1.3d+249) .or. (.not. (x <= 6.5d+286))) then
tmp = (1.0d0 + exp((eps_m * x))) / 2.0d0
else
tmp = ((1.0d0 + (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 (x <= -2.7e-263) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if ((x <= 8e+41) || (!(x <= 4.2e+74) && ((x <= 1.3e+249) || !(x <= 6.5e+286)))) {
tmp = (1.0 + Math.exp((eps_m * x))) / 2.0;
} else {
tmp = ((1.0 + (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 x <= -2.7e-263: tmp = (1.0 + math.exp(-x)) / 2.0 elif (x <= 8e+41) or (not (x <= 4.2e+74) and ((x <= 1.3e+249) or not (x <= 6.5e+286))): tmp = (1.0 + math.exp((eps_m * x))) / 2.0 else: tmp = ((1.0 + (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 (x <= -2.7e-263) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif ((x <= 8e+41) || (!(x <= 4.2e+74) && ((x <= 1.3e+249) || !(x <= 6.5e+286)))) tmp = Float64(Float64(1.0 + exp(Float64(eps_m * x))) / 2.0); else tmp = Float64(Float64(Float64(1.0 + 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 (x <= -2.7e-263) tmp = (1.0 + exp(-x)) / 2.0; elseif ((x <= 8e+41) || (~((x <= 4.2e+74)) && ((x <= 1.3e+249) || ~((x <= 6.5e+286))))) tmp = (1.0 + exp((eps_m * x))) / 2.0; else tmp = ((1.0 + (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[x, -2.7e-263], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 8e+41], And[N[Not[LessEqual[x, 4.2e+74]], $MachinePrecision], Or[LessEqual[x, 1.3e+249], N[Not[LessEqual[x, 6.5e+286]], $MachinePrecision]]]], N[(N[(1.0 + N[Exp[N[(eps$95$m * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-263}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+41} \lor \neg \left(x \leq 4.2 \cdot 10^{+74}\right) \land \left(x \leq 1.3 \cdot 10^{+249} \lor \neg \left(x \leq 6.5 \cdot 10^{+286}\right)\right):\\
\;\;\;\;\frac{1 + e^{eps\_m \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\end{array}
\end{array}
if x < -2.70000000000000003e-263Initial program 71.5%
fma-neg71.4%
/-rgt-identity71.4%
fma-neg71.5%
/-rgt-identity71.5%
distribute-rgt-neg-in71.5%
sub-neg71.5%
metadata-eval71.5%
distribute-rgt-neg-in71.5%
Simplified71.5%
Taylor expanded in x around 0 46.0%
Taylor expanded in eps around inf 71.4%
exp-prod71.4%
*-commutative71.4%
sub-neg71.4%
mul-1-neg71.4%
*-commutative71.4%
exp-prod71.4%
associate-*r*71.4%
mul-1-neg71.4%
mul-1-neg71.4%
sub-neg71.4%
Simplified71.4%
Taylor expanded in eps around 0 75.2%
neg-mul-175.2%
Simplified75.2%
if -2.70000000000000003e-263 < x < 8.00000000000000005e41 or 4.1999999999999998e74 < x < 1.3000000000000001e249 or 6.5000000000000003e286 < x Initial program 70.9%
fma-neg70.9%
/-rgt-identity70.9%
fma-neg70.9%
/-rgt-identity70.9%
distribute-rgt-neg-in70.9%
sub-neg70.9%
metadata-eval70.9%
distribute-rgt-neg-in70.9%
Simplified70.9%
Taylor expanded in x around 0 40.8%
Taylor expanded in eps around inf 69.4%
exp-prod69.4%
*-commutative69.4%
sub-neg69.4%
mul-1-neg69.4%
*-commutative69.4%
exp-prod69.4%
associate-*r*69.4%
mul-1-neg69.4%
mul-1-neg69.4%
sub-neg69.4%
Simplified69.4%
Taylor expanded in eps around inf 69.9%
*-commutative69.9%
Simplified69.9%
if 8.00000000000000005e41 < x < 4.1999999999999998e74 or 1.3000000000000001e249 < x < 6.5000000000000003e286Initial 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 14.6%
Taylor expanded in x around 0 75.8%
Final simplification72.2%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -2e-256)
(/ (+ 1.0 (exp (* x (- 1.0 eps_m)))) 2.0)
(if (or (<= x 7.2e+41)
(and (not (<= x 3.9e+74))
(or (<= x 1.9e+249) (not (<= x 1.15e+286)))))
(/ (+ 1.0 (exp (* eps_m x))) 2.0)
(/ (+ (+ 1.0 (/ 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 (x <= -2e-256) {
tmp = (1.0 + exp((x * (1.0 - eps_m)))) / 2.0;
} else if ((x <= 7.2e+41) || (!(x <= 3.9e+74) && ((x <= 1.9e+249) || !(x <= 1.15e+286)))) {
tmp = (1.0 + exp((eps_m * x))) / 2.0;
} else {
tmp = ((1.0 + (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 (x <= (-2d-256)) then
tmp = (1.0d0 + exp((x * (1.0d0 - eps_m)))) / 2.0d0
else if ((x <= 7.2d+41) .or. (.not. (x <= 3.9d+74)) .and. (x <= 1.9d+249) .or. (.not. (x <= 1.15d+286))) then
tmp = (1.0d0 + exp((eps_m * x))) / 2.0d0
else
tmp = ((1.0d0 + (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 (x <= -2e-256) {
tmp = (1.0 + Math.exp((x * (1.0 - eps_m)))) / 2.0;
} else if ((x <= 7.2e+41) || (!(x <= 3.9e+74) && ((x <= 1.9e+249) || !(x <= 1.15e+286)))) {
tmp = (1.0 + Math.exp((eps_m * x))) / 2.0;
} else {
tmp = ((1.0 + (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 x <= -2e-256: tmp = (1.0 + math.exp((x * (1.0 - eps_m)))) / 2.0 elif (x <= 7.2e+41) or (not (x <= 3.9e+74) and ((x <= 1.9e+249) or not (x <= 1.15e+286))): tmp = (1.0 + math.exp((eps_m * x))) / 2.0 else: tmp = ((1.0 + (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 (x <= -2e-256) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(1.0 - eps_m)))) / 2.0); elseif ((x <= 7.2e+41) || (!(x <= 3.9e+74) && ((x <= 1.9e+249) || !(x <= 1.15e+286)))) tmp = Float64(Float64(1.0 + exp(Float64(eps_m * x))) / 2.0); else tmp = Float64(Float64(Float64(1.0 + 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 (x <= -2e-256) tmp = (1.0 + exp((x * (1.0 - eps_m)))) / 2.0; elseif ((x <= 7.2e+41) || (~((x <= 3.9e+74)) && ((x <= 1.9e+249) || ~((x <= 1.15e+286))))) tmp = (1.0 + exp((eps_m * x))) / 2.0; else tmp = ((1.0 + (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[x, -2e-256], N[(N[(1.0 + N[Exp[N[(x * N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 7.2e+41], And[N[Not[LessEqual[x, 3.9e+74]], $MachinePrecision], Or[LessEqual[x, 1.9e+249], N[Not[LessEqual[x, 1.15e+286]], $MachinePrecision]]]], N[(N[(1.0 + N[Exp[N[(eps$95$m * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-256}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(1 - eps\_m\right)}}{2}\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+41} \lor \neg \left(x \leq 3.9 \cdot 10^{+74}\right) \land \left(x \leq 1.9 \cdot 10^{+249} \lor \neg \left(x \leq 1.15 \cdot 10^{+286}\right)\right):\\
\;\;\;\;\frac{1 + e^{eps\_m \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\end{array}
\end{array}
if x < -1.99999999999999995e-256Initial program 71.5%
fma-neg71.4%
/-rgt-identity71.4%
fma-neg71.5%
/-rgt-identity71.5%
distribute-rgt-neg-in71.5%
sub-neg71.5%
metadata-eval71.5%
distribute-rgt-neg-in71.5%
Simplified71.5%
Taylor expanded in x around 0 46.0%
add-log-exp46.0%
*-un-lft-identity46.0%
log-prod46.0%
metadata-eval46.0%
add-log-exp46.0%
add-sqr-sqrt46.0%
sqrt-unprod44.1%
sqr-neg44.1%
sqrt-prod0.0%
add-sqr-sqrt41.4%
Applied egg-rr41.4%
+-lft-identity41.4%
*-commutative41.4%
Simplified41.4%
Taylor expanded in eps around inf 68.0%
if -1.99999999999999995e-256 < x < 7.20000000000000051e41 or 3.90000000000000008e74 < x < 1.8999999999999999e249 or 1.1500000000000001e286 < x Initial program 70.9%
fma-neg70.9%
/-rgt-identity70.9%
fma-neg70.9%
/-rgt-identity70.9%
distribute-rgt-neg-in70.9%
sub-neg70.9%
metadata-eval70.9%
distribute-rgt-neg-in70.9%
Simplified70.9%
Taylor expanded in x around 0 40.8%
Taylor expanded in eps around inf 69.4%
exp-prod69.4%
*-commutative69.4%
sub-neg69.4%
mul-1-neg69.4%
*-commutative69.4%
exp-prod69.4%
associate-*r*69.4%
mul-1-neg69.4%
mul-1-neg69.4%
sub-neg69.4%
Simplified69.4%
Taylor expanded in eps around inf 69.9%
*-commutative69.9%
Simplified69.9%
if 7.20000000000000051e41 < x < 3.90000000000000008e74 or 1.8999999999999999e249 < x < 1.1500000000000001e286Initial 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 14.6%
Taylor expanded in x around 0 75.8%
Final simplification69.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 8.5e-6)
(/ (- 2.0 (* eps_m x)) 2.0)
(if (or (<= x 1.65e+42)
(not
(or (<= x 1e+90) (and (not (<= x 1.65e+249)) (<= x 6.7e+286)))))
(/ (/ (expm1 x) eps_m) 2.0)
(/ (+ (+ 1.0 (/ 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 (x <= 8.5e-6) {
tmp = (2.0 - (eps_m * x)) / 2.0;
} else if ((x <= 1.65e+42) || !((x <= 1e+90) || (!(x <= 1.65e+249) && (x <= 6.7e+286)))) {
tmp = (expm1(x) / eps_m) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
}
return tmp;
}
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 8.5e-6) {
tmp = (2.0 - (eps_m * x)) / 2.0;
} else if ((x <= 1.65e+42) || !((x <= 1e+90) || (!(x <= 1.65e+249) && (x <= 6.7e+286)))) {
tmp = (Math.expm1(x) / eps_m) / 2.0;
} else {
tmp = ((1.0 + (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 x <= 8.5e-6: tmp = (2.0 - (eps_m * x)) / 2.0 elif (x <= 1.65e+42) or not ((x <= 1e+90) or (not (x <= 1.65e+249) and (x <= 6.7e+286))): tmp = (math.expm1(x) / eps_m) / 2.0 else: tmp = ((1.0 + (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 (x <= 8.5e-6) tmp = Float64(Float64(2.0 - Float64(eps_m * x)) / 2.0); elseif ((x <= 1.65e+42) || !((x <= 1e+90) || (!(x <= 1.65e+249) && (x <= 6.7e+286)))) tmp = Float64(Float64(expm1(x) / eps_m) / 2.0); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(1.0 + Float64(-1.0 / eps_m))) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 8.5e-6], N[(N[(2.0 - N[(eps$95$m * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 1.65e+42], N[Not[Or[LessEqual[x, 1e+90], And[N[Not[LessEqual[x, 1.65e+249]], $MachinePrecision], LessEqual[x, 6.7e+286]]]], $MachinePrecision]], N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{-6}:\\
\;\;\;\;\frac{2 - eps\_m \cdot x}{2}\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+42} \lor \neg \left(x \leq 10^{+90} \lor \neg \left(x \leq 1.65 \cdot 10^{+249}\right) \land x \leq 6.7 \cdot 10^{+286}\right):\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\end{array}
\end{array}
if x < 8.4999999999999999e-6Initial program 60.1%
fma-neg60.1%
/-rgt-identity60.1%
fma-neg60.1%
/-rgt-identity60.1%
distribute-rgt-neg-in60.1%
sub-neg60.1%
metadata-eval60.1%
distribute-rgt-neg-in60.1%
Simplified60.1%
Taylor expanded in x around 0 42.3%
add-log-exp42.3%
*-un-lft-identity42.3%
log-prod42.3%
metadata-eval42.3%
add-log-exp42.3%
add-sqr-sqrt26.9%
sqrt-unprod37.9%
sqr-neg37.9%
sqrt-prod14.3%
add-sqr-sqrt38.9%
Applied egg-rr38.9%
+-lft-identity38.9%
*-commutative38.9%
Simplified38.9%
Taylor expanded in x around 0 47.8%
*-commutative47.8%
Simplified47.8%
Taylor expanded in eps around inf 64.7%
associate-*r*64.7%
neg-mul-164.7%
Simplified64.7%
if 8.4999999999999999e-6 < x < 1.6499999999999999e42 or 9.99999999999999966e89 < x < 1.65000000000000007e249 or 6.70000000000000037e286 < 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 x around 0 46.5%
add-log-exp46.5%
*-un-lft-identity46.5%
log-prod46.5%
metadata-eval46.5%
add-log-exp46.5%
add-sqr-sqrt0.0%
sqrt-unprod30.2%
sqr-neg30.2%
sqrt-prod30.2%
add-sqr-sqrt30.2%
Applied egg-rr30.2%
+-lft-identity30.2%
*-commutative30.2%
Simplified30.2%
Taylor expanded in eps around 0 40.5%
expm1-def40.5%
Simplified40.5%
if 1.6499999999999999e42 < x < 9.99999999999999966e89 or 1.65000000000000007e249 < x < 6.70000000000000037e286Initial 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 12.9%
Taylor expanded in x around 0 72.3%
Final simplification59.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 7100.0)
(/ (+ 1.0 (exp (- x))) 2.0)
(if (or (<= x 1.02e+42)
(and (not (<= x 5.2e+89))
(or (<= x 4.2e+249) (not (<= x 2.8e+285)))))
(/ (/ (expm1 x) eps_m) 2.0)
(/ (+ (+ 1.0 (/ 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 (x <= 7100.0) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if ((x <= 1.02e+42) || (!(x <= 5.2e+89) && ((x <= 4.2e+249) || !(x <= 2.8e+285)))) {
tmp = (expm1(x) / eps_m) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
}
return tmp;
}
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 7100.0) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if ((x <= 1.02e+42) || (!(x <= 5.2e+89) && ((x <= 4.2e+249) || !(x <= 2.8e+285)))) {
tmp = (Math.expm1(x) / eps_m) / 2.0;
} else {
tmp = ((1.0 + (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 x <= 7100.0: tmp = (1.0 + math.exp(-x)) / 2.0 elif (x <= 1.02e+42) or (not (x <= 5.2e+89) and ((x <= 4.2e+249) or not (x <= 2.8e+285))): tmp = (math.expm1(x) / eps_m) / 2.0 else: tmp = ((1.0 + (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 (x <= 7100.0) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif ((x <= 1.02e+42) || (!(x <= 5.2e+89) && ((x <= 4.2e+249) || !(x <= 2.8e+285)))) tmp = Float64(Float64(expm1(x) / eps_m) / 2.0); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(1.0 + Float64(-1.0 / eps_m))) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 7100.0], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 1.02e+42], And[N[Not[LessEqual[x, 5.2e+89]], $MachinePrecision], Or[LessEqual[x, 4.2e+249], N[Not[LessEqual[x, 2.8e+285]], $MachinePrecision]]]], N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7100:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{+42} \lor \neg \left(x \leq 5.2 \cdot 10^{+89}\right) \land \left(x \leq 4.2 \cdot 10^{+249} \lor \neg \left(x \leq 2.8 \cdot 10^{+285}\right)\right):\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\end{array}
\end{array}
if x < 7100Initial program 61.0%
fma-neg61.0%
/-rgt-identity61.0%
fma-neg61.0%
/-rgt-identity61.0%
distribute-rgt-neg-in61.0%
sub-neg61.0%
metadata-eval61.0%
distribute-rgt-neg-in61.0%
Simplified61.0%
Taylor expanded in x around 0 43.1%
Taylor expanded in eps around inf 80.0%
exp-prod80.0%
*-commutative80.0%
sub-neg80.0%
mul-1-neg80.0%
*-commutative80.0%
exp-prod80.0%
associate-*r*80.0%
mul-1-neg80.0%
mul-1-neg80.0%
sub-neg80.0%
Simplified80.0%
Taylor expanded in eps around 0 74.6%
neg-mul-174.6%
Simplified74.6%
if 7100 < x < 1.01999999999999996e42 or 5.2000000000000001e89 < x < 4.1999999999999997e249 or 2.80000000000000016e285 < 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 x around 0 44.5%
add-log-exp44.5%
*-un-lft-identity44.5%
log-prod44.5%
metadata-eval44.5%
add-log-exp44.5%
add-sqr-sqrt0.0%
sqrt-unprod32.1%
sqr-neg32.1%
sqrt-prod32.1%
add-sqr-sqrt32.1%
Applied egg-rr32.1%
+-lft-identity32.1%
*-commutative32.1%
Simplified32.1%
Taylor expanded in eps around 0 43.3%
expm1-def43.3%
Simplified43.3%
if 1.01999999999999996e42 < x < 5.2000000000000001e89 or 4.1999999999999997e249 < x < 2.80000000000000016e285Initial 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 12.9%
Taylor expanded in x around 0 72.3%
Final simplification67.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 8.5e-6)
(/ (- 2.0 (* eps_m x)) 2.0)
(if (or (<= x 8.8e+74) (not (<= x 2.6e+249)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (+ 1.0 (/ -1.0 eps_m))) 2.0)
(/ (+ 1.0 (+ 1.0 (* eps_m x))) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 8.5e-6) {
tmp = (2.0 - (eps_m * x)) / 2.0;
} else if ((x <= 8.8e+74) || !(x <= 2.6e+249)) {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
} else {
tmp = (1.0 + (1.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 <= 8.5d-6) then
tmp = (2.0d0 - (eps_m * x)) / 2.0d0
else if ((x <= 8.8d+74) .or. (.not. (x <= 2.6d+249))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (1.0d0 + ((-1.0d0) / eps_m))) / 2.0d0
else
tmp = (1.0d0 + (1.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 <= 8.5e-6) {
tmp = (2.0 - (eps_m * x)) / 2.0;
} else if ((x <= 8.8e+74) || !(x <= 2.6e+249)) {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
} else {
tmp = (1.0 + (1.0 + (eps_m * x))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 8.5e-6: tmp = (2.0 - (eps_m * x)) / 2.0 elif (x <= 8.8e+74) or not (x <= 2.6e+249): tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0 else: tmp = (1.0 + (1.0 + (eps_m * x))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 8.5e-6) tmp = Float64(Float64(2.0 - Float64(eps_m * x)) / 2.0); elseif ((x <= 8.8e+74) || !(x <= 2.6e+249)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(1.0 + Float64(-1.0 / eps_m))) / 2.0); else tmp = Float64(Float64(1.0 + Float64(1.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 <= 8.5e-6) tmp = (2.0 - (eps_m * x)) / 2.0; elseif ((x <= 8.8e+74) || ~((x <= 2.6e+249))) tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0; else tmp = (1.0 + (1.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, 8.5e-6], N[(N[(2.0 - N[(eps$95$m * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 8.8e+74], N[Not[LessEqual[x, 2.6e+249]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[(1.0 + N[(eps$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{-6}:\\
\;\;\;\;\frac{2 - eps\_m \cdot x}{2}\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{+74} \lor \neg \left(x \leq 2.6 \cdot 10^{+249}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(1 + eps\_m \cdot x\right)}{2}\\
\end{array}
\end{array}
if x < 8.4999999999999999e-6Initial program 60.1%
fma-neg60.1%
/-rgt-identity60.1%
fma-neg60.1%
/-rgt-identity60.1%
distribute-rgt-neg-in60.1%
sub-neg60.1%
metadata-eval60.1%
distribute-rgt-neg-in60.1%
Simplified60.1%
Taylor expanded in x around 0 42.3%
add-log-exp42.3%
*-un-lft-identity42.3%
log-prod42.3%
metadata-eval42.3%
add-log-exp42.3%
add-sqr-sqrt26.9%
sqrt-unprod37.9%
sqr-neg37.9%
sqrt-prod14.3%
add-sqr-sqrt38.9%
Applied egg-rr38.9%
+-lft-identity38.9%
*-commutative38.9%
Simplified38.9%
Taylor expanded in x around 0 47.8%
*-commutative47.8%
Simplified47.8%
Taylor expanded in eps around inf 64.7%
associate-*r*64.7%
neg-mul-164.7%
Simplified64.7%
if 8.4999999999999999e-6 < x < 8.8000000000000005e74 or 2.60000000000000019e249 < 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 x around 0 33.6%
Taylor expanded in x around 0 50.5%
if 8.8000000000000005e74 < x < 2.60000000000000019e249Initial 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 38.3%
Taylor expanded in eps around inf 38.6%
exp-prod38.6%
*-commutative38.6%
sub-neg38.6%
mul-1-neg38.6%
*-commutative38.6%
exp-prod38.6%
associate-*r*38.6%
mul-1-neg38.6%
mul-1-neg38.6%
sub-neg38.6%
Simplified38.6%
Taylor expanded in eps around inf 38.5%
*-commutative38.5%
Simplified38.5%
Taylor expanded in x around 0 21.7%
Final simplification55.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -4e-263) (/ (- 2.0 (* eps_m x)) 2.0) (/ (+ 1.0 (+ 1.0 (* eps_m x))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -4e-263) {
tmp = (2.0 - (eps_m * x)) / 2.0;
} else {
tmp = (1.0 + (1.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 <= (-4d-263)) then
tmp = (2.0d0 - (eps_m * x)) / 2.0d0
else
tmp = (1.0d0 + (1.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 <= -4e-263) {
tmp = (2.0 - (eps_m * x)) / 2.0;
} else {
tmp = (1.0 + (1.0 + (eps_m * x))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -4e-263: tmp = (2.0 - (eps_m * x)) / 2.0 else: tmp = (1.0 + (1.0 + (eps_m * x))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -4e-263) tmp = Float64(Float64(2.0 - Float64(eps_m * x)) / 2.0); else tmp = Float64(Float64(1.0 + Float64(1.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 <= -4e-263) tmp = (2.0 - (eps_m * x)) / 2.0; else tmp = (1.0 + (1.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, -4e-263], N[(N[(2.0 - N[(eps$95$m * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[(1.0 + N[(eps$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-263}:\\
\;\;\;\;\frac{2 - eps\_m \cdot x}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(1 + eps\_m \cdot x\right)}{2}\\
\end{array}
\end{array}
if x < -4e-263Initial program 71.5%
fma-neg71.4%
/-rgt-identity71.4%
fma-neg71.5%
/-rgt-identity71.5%
distribute-rgt-neg-in71.5%
sub-neg71.5%
metadata-eval71.5%
distribute-rgt-neg-in71.5%
Simplified71.5%
Taylor expanded in x around 0 46.0%
add-log-exp46.0%
*-un-lft-identity46.0%
log-prod46.0%
metadata-eval46.0%
add-log-exp46.0%
add-sqr-sqrt46.0%
sqrt-unprod44.1%
sqr-neg44.1%
sqrt-prod0.0%
add-sqr-sqrt41.4%
Applied egg-rr41.4%
+-lft-identity41.4%
*-commutative41.4%
Simplified41.4%
Taylor expanded in x around 0 39.6%
*-commutative39.6%
Simplified39.6%
Taylor expanded in eps around inf 51.6%
associate-*r*51.6%
neg-mul-151.6%
Simplified51.6%
if -4e-263 < x Initial program 75.0%
fma-neg75.0%
/-rgt-identity75.0%
fma-neg75.0%
/-rgt-identity75.0%
distribute-rgt-neg-in75.0%
sub-neg75.0%
metadata-eval75.0%
distribute-rgt-neg-in75.0%
Simplified75.0%
Taylor expanded in x around 0 37.1%
Taylor expanded in eps around inf 61.8%
exp-prod61.8%
*-commutative61.8%
sub-neg61.8%
mul-1-neg61.8%
*-commutative61.8%
exp-prod61.8%
associate-*r*61.8%
mul-1-neg61.8%
mul-1-neg61.8%
sub-neg61.8%
Simplified61.8%
Taylor expanded in eps around inf 62.2%
*-commutative62.2%
Simplified62.2%
Taylor expanded in x around 0 46.8%
Final simplification48.4%
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}
Initial program 73.8%
fma-neg73.8%
/-rgt-identity73.8%
fma-neg73.8%
/-rgt-identity73.8%
distribute-rgt-neg-in73.8%
sub-neg73.8%
metadata-eval73.8%
distribute-rgt-neg-in73.8%
Simplified73.8%
Taylor expanded in x around 0 40.1%
add-log-exp40.1%
*-un-lft-identity40.1%
log-prod40.1%
metadata-eval40.1%
add-log-exp40.1%
add-sqr-sqrt17.6%
sqrt-unprod33.7%
sqr-neg33.7%
sqrt-prod18.2%
add-sqr-sqrt34.3%
Applied egg-rr34.3%
+-lft-identity34.3%
*-commutative34.3%
Simplified34.3%
Taylor expanded in x around 0 36.9%
*-commutative36.9%
Simplified36.9%
Taylor expanded in eps around inf 48.1%
associate-*r*48.1%
neg-mul-148.1%
Simplified48.1%
Final simplification48.1%
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.8%
fma-neg73.8%
/-rgt-identity73.8%
fma-neg73.8%
/-rgt-identity73.8%
distribute-rgt-neg-in73.8%
sub-neg73.8%
metadata-eval73.8%
distribute-rgt-neg-in73.8%
Simplified73.8%
Taylor expanded in x around 0 40.5%
Final simplification40.5%
herbie shell --seed 2024040
(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))