
(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 16 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 (pow (sqrt (exp (fma x eps_m x))) -1.0))) (/ (+ (exp (* x (+ -1.0 eps_m))) (* t_0 t_0)) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = pow(sqrt(exp(fma(x, eps_m, x))), -1.0);
return (exp((x * (-1.0 + eps_m))) + (t_0 * t_0)) / 2.0;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = sqrt(exp(fma(x, eps_m, x))) ^ -1.0 return Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) + Float64(t_0 * t_0)) / 2.0) end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Power[N[Sqrt[N[Exp[N[(x * eps$95$m + x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], -1.0], $MachinePrecision]}, N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := {\left(\sqrt{e^{\mathsf{fma}\left(x, eps\_m, x\right)}}\right)}^{-1}\\
\frac{e^{x \cdot \left(-1 + eps\_m\right)} + t\_0 \cdot t\_0}{2}
\end{array}
\end{array}
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 eps around inf 98.9%
*-commutative98.9%
distribute-rgt-in98.9%
*-un-lft-identity98.9%
add-log-exp98.9%
pow-to-exp98.9%
add-sqr-sqrt98.9%
unpow-prod-down98.9%
+-commutative98.9%
*-commutative98.9%
fma-define98.9%
+-commutative98.9%
*-commutative98.9%
fma-define98.9%
Applied egg-rr98.9%
Final simplification98.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0
(/
(+ (exp (* x (+ -1.0 eps_m))) (/ 1.0 (+ 1.0 (* x (+ 1.0 eps_m)))))
2.0)))
(if (<= x -2e-287)
(/ (+ 1.0 (exp (* x (- -1.0 eps_m)))) 2.0)
(if (<= x 6.8e+68)
t_0
(if (<= x 1.4e+77)
(/ (/ (+ (exp (- x)) (/ -1.0 (exp x))) eps_m) 2.0)
(if (or (<= x 7.5e+157) (not (<= x 7.2e+212)))
t_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 * (-1.0 + eps_m))) + (1.0 / (1.0 + (x * (1.0 + eps_m))))) / 2.0;
double tmp;
if (x <= -2e-287) {
tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0;
} else if (x <= 6.8e+68) {
tmp = t_0;
} else if (x <= 1.4e+77) {
tmp = ((exp(-x) + (-1.0 / exp(x))) / eps_m) / 2.0;
} else if ((x <= 7.5e+157) || !(x <= 7.2e+212)) {
tmp = t_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 * ((-1.0d0) + eps_m))) + (1.0d0 / (1.0d0 + (x * (1.0d0 + eps_m))))) / 2.0d0
if (x <= (-2d-287)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps_m)))) / 2.0d0
else if (x <= 6.8d+68) then
tmp = t_0
else if (x <= 1.4d+77) then
tmp = ((exp(-x) + ((-1.0d0) / exp(x))) / eps_m) / 2.0d0
else if ((x <= 7.5d+157) .or. (.not. (x <= 7.2d+212))) then
tmp = t_0
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 * (-1.0 + eps_m))) + (1.0 / (1.0 + (x * (1.0 + eps_m))))) / 2.0;
double tmp;
if (x <= -2e-287) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
} else if (x <= 6.8e+68) {
tmp = t_0;
} else if (x <= 1.4e+77) {
tmp = ((Math.exp(-x) + (-1.0 / Math.exp(x))) / eps_m) / 2.0;
} else if ((x <= 7.5e+157) || !(x <= 7.2e+212)) {
tmp = t_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 * (-1.0 + eps_m))) + (1.0 / (1.0 + (x * (1.0 + eps_m))))) / 2.0 tmp = 0 if x <= -2e-287: tmp = (1.0 + math.exp((x * (-1.0 - eps_m)))) / 2.0 elif x <= 6.8e+68: tmp = t_0 elif x <= 1.4e+77: tmp = ((math.exp(-x) + (-1.0 / math.exp(x))) / eps_m) / 2.0 elif (x <= 7.5e+157) or not (x <= 7.2e+212): tmp = t_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(exp(Float64(x * Float64(-1.0 + eps_m))) + Float64(1.0 / Float64(1.0 + Float64(x * Float64(1.0 + eps_m))))) / 2.0) tmp = 0.0 if (x <= -2e-287) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0); elseif (x <= 6.8e+68) tmp = t_0; elseif (x <= 1.4e+77) tmp = Float64(Float64(Float64(exp(Float64(-x)) + Float64(-1.0 / exp(x))) / eps_m) / 2.0); elseif ((x <= 7.5e+157) || !(x <= 7.2e+212)) tmp = t_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 * (-1.0 + eps_m))) + (1.0 / (1.0 + (x * (1.0 + eps_m))))) / 2.0; tmp = 0.0; if (x <= -2e-287) tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0; elseif (x <= 6.8e+68) tmp = t_0; elseif (x <= 1.4e+77) tmp = ((exp(-x) + (-1.0 / exp(x))) / eps_m) / 2.0; elseif ((x <= 7.5e+157) || ~((x <= 7.2e+212))) tmp = t_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[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(1.0 / N[(1.0 + N[(x * N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, -2e-287], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.8e+68], t$95$0, If[LessEqual[x, 1.4e+77], N[(N[(N[(N[Exp[(-x)], $MachinePrecision] + N[(-1.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 7.5e+157], N[Not[LessEqual[x, 7.2e+212]], $MachinePrecision]], t$95$0, 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 := \frac{e^{x \cdot \left(-1 + eps\_m\right)} + \frac{1}{1 + x \cdot \left(1 + eps\_m\right)}}{2}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-287}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+68}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+77}:\\
\;\;\;\;\frac{\frac{e^{-x} + \frac{-1}{e^{x}}}{eps\_m}}{2}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+157} \lor \neg \left(x \leq 7.2 \cdot 10^{+212}\right):\\
\;\;\;\;t\_0\\
\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.00000000000000004e-287Initial program 70.8%
fma-neg70.7%
/-rgt-identity70.7%
fma-neg70.8%
/-rgt-identity70.8%
distribute-rgt-neg-in70.8%
sub-neg70.8%
metadata-eval70.8%
distribute-rgt-neg-in70.8%
Simplified70.8%
Taylor expanded in x around 0 40.1%
Taylor expanded in eps around inf 66.1%
mul-1-neg66.1%
associate-*r*66.1%
neg-mul-166.1%
Simplified66.1%
if -2.00000000000000004e-287 < x < 6.8000000000000003e68 or 1.4e77 < x < 7.5e157 or 7.2e212 < x Initial program 72.9%
Simplified65.0%
Taylor expanded in eps around inf 99.7%
Taylor expanded in x around 0 67.9%
if 6.8000000000000003e68 < x < 1.4e77Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 100.0%
if 7.5e157 < x < 7.2e212Initial 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 24.0%
Taylor expanded in x around 0 78.5%
Final simplification69.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ (exp (* x (+ -1.0 eps_m))) (/ 1.0 (exp (+ x (* x eps_m))))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp((x * (-1.0 + eps_m))) + (1.0 / exp((x + (x * 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 * ((-1.0d0) + eps_m))) + (1.0d0 / exp((x + (x * eps_m))))) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (Math.exp((x * (-1.0 + eps_m))) + (1.0 / Math.exp((x + (x * eps_m))))) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (math.exp((x * (-1.0 + eps_m))) + (1.0 / math.exp((x + (x * eps_m))))) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) + Float64(1.0 / exp(Float64(x + Float64(x * eps_m))))) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (exp((x * (-1.0 + eps_m))) + (1.0 / exp((x + (x * eps_m))))) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(1.0 / N[Exp[N[(x + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{e^{x \cdot \left(-1 + eps\_m\right)} + \frac{1}{e^{x + x \cdot eps\_m}}}{2}
\end{array}
Initial program 75.0%
Simplified66.8%
Taylor expanded in eps around inf 98.9%
Final simplification98.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ (exp (* x (+ -1.0 eps_m))) (exp (* x (- -1.0 eps_m)))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp((x * (-1.0 + eps_m))) + 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 * ((-1.0d0) + eps_m))) + 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 * (-1.0 + eps_m))) + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (math.exp((x * (-1.0 + eps_m))) + 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(-1.0 + eps_m))) + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (exp((x * (-1.0 + eps_m))) + 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[(-1.0 + eps$95$m), $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(-1 + eps\_m\right)} + e^{x \cdot \left(-1 - eps\_m\right)}}{2}
\end{array}
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 eps around inf 98.9%
Final simplification98.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ (exp (* x (+ -1.0 eps_m))) (exp (* x (- eps_m)))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp((x * (-1.0 + eps_m))) + exp((x * -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 * ((-1.0d0) + eps_m))) + exp((x * -eps_m))) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (Math.exp((x * (-1.0 + eps_m))) + Math.exp((x * -eps_m))) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (math.exp((x * (-1.0 + eps_m))) + math.exp((x * -eps_m))) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) + exp(Float64(x * Float64(-eps_m)))) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (exp((x * (-1.0 + eps_m))) + exp((x * -eps_m))) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{e^{x \cdot \left(-1 + eps\_m\right)} + e^{x \cdot \left(-eps\_m\right)}}{2}
\end{array}
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 eps around inf 98.9%
Taylor expanded in eps around inf 87.1%
*-commutative87.1%
Simplified87.1%
Taylor expanded in x around inf 87.1%
associate-*r*87.1%
sub-neg87.1%
neg-mul-187.1%
associate-*r*87.1%
associate-*r*87.1%
neg-mul-187.1%
neg-mul-187.1%
sub-neg87.1%
mul-1-neg87.1%
associate-*r*87.1%
neg-mul-187.1%
Simplified87.1%
Final simplification87.1%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -5e-286)
(/ (+ 1.0 (exp (* x (- -1.0 eps_m)))) 2.0)
(if (or (<= x 9e+68)
(and (not (<= x 1.45e+77))
(or (<= x 3.7e+157) (not (<= x 1.62e+212)))))
(/ (+ (exp (* x (+ -1.0 eps_m))) (/ 1.0 (+ 1.0 (* x (+ 1.0 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 <= -5e-286) {
tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0;
} else if ((x <= 9e+68) || (!(x <= 1.45e+77) && ((x <= 3.7e+157) || !(x <= 1.62e+212)))) {
tmp = (exp((x * (-1.0 + eps_m))) + (1.0 / (1.0 + (x * (1.0 + 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)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-5d-286)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps_m)))) / 2.0d0
else if ((x <= 9d+68) .or. (.not. (x <= 1.45d+77)) .and. (x <= 3.7d+157) .or. (.not. (x <= 1.62d+212))) then
tmp = (exp((x * ((-1.0d0) + eps_m))) + (1.0d0 / (1.0d0 + (x * (1.0d0 + eps_m))))) / 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 <= -5e-286) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
} else if ((x <= 9e+68) || (!(x <= 1.45e+77) && ((x <= 3.7e+157) || !(x <= 1.62e+212)))) {
tmp = (Math.exp((x * (-1.0 + eps_m))) + (1.0 / (1.0 + (x * (1.0 + 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 <= -5e-286: tmp = (1.0 + math.exp((x * (-1.0 - eps_m)))) / 2.0 elif (x <= 9e+68) or (not (x <= 1.45e+77) and ((x <= 3.7e+157) or not (x <= 1.62e+212))): tmp = (math.exp((x * (-1.0 + eps_m))) + (1.0 / (1.0 + (x * (1.0 + 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 <= -5e-286) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0); elseif ((x <= 9e+68) || (!(x <= 1.45e+77) && ((x <= 3.7e+157) || !(x <= 1.62e+212)))) tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) + Float64(1.0 / Float64(1.0 + Float64(x * Float64(1.0 + 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 = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -5e-286) tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0; elseif ((x <= 9e+68) || (~((x <= 1.45e+77)) && ((x <= 3.7e+157) || ~((x <= 1.62e+212))))) tmp = (exp((x * (-1.0 + eps_m))) + (1.0 / (1.0 + (x * (1.0 + eps_m))))) / 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, -5e-286], 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, 9e+68], And[N[Not[LessEqual[x, 1.45e+77]], $MachinePrecision], Or[LessEqual[x, 3.7e+157], N[Not[LessEqual[x, 1.62e+212]], $MachinePrecision]]]], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(1.0 / N[(1.0 + N[(x * N[(1.0 + eps$95$m), $MachinePrecision]), $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}
\mathbf{if}\;x \leq -5 \cdot 10^{-286}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+68} \lor \neg \left(x \leq 1.45 \cdot 10^{+77}\right) \land \left(x \leq 3.7 \cdot 10^{+157} \lor \neg \left(x \leq 1.62 \cdot 10^{+212}\right)\right):\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps\_m\right)} + \frac{1}{1 + x \cdot \left(1 + eps\_m\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 < -5.00000000000000037e-286Initial program 70.8%
fma-neg70.7%
/-rgt-identity70.7%
fma-neg70.8%
/-rgt-identity70.8%
distribute-rgt-neg-in70.8%
sub-neg70.8%
metadata-eval70.8%
distribute-rgt-neg-in70.8%
Simplified70.8%
Taylor expanded in x around 0 40.1%
Taylor expanded in eps around inf 66.1%
mul-1-neg66.1%
associate-*r*66.1%
neg-mul-166.1%
Simplified66.1%
if -5.00000000000000037e-286 < x < 9.0000000000000007e68 or 1.4500000000000001e77 < x < 3.6999999999999999e157 or 1.61999999999999994e212 < x Initial program 72.9%
Simplified65.0%
Taylor expanded in eps around inf 99.7%
Taylor expanded in x around 0 67.9%
if 9.0000000000000007e68 < x < 1.4500000000000001e77 or 3.6999999999999999e157 < x < 1.61999999999999994e212Initial 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 16.2%
Taylor expanded in x around 0 79.2%
Final simplification68.4%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -0.0008)
(/ (+ 2.0 (* (* x (+ 1.0 eps_m)) (+ -1.0 (/ 1.0 eps_m)))) 2.0)
(if (<= x 510.0)
(/
(+
2.0
(*
x
(- (+ (/ 1.0 eps_m) (* (- 1.0 eps_m) (- -1.0 (/ 1.0 eps_m)))) eps_m)))
2.0)
(if (or (<= x 9.5e+65)
(and (not (<= x 1.6e+77))
(or (<= x 1.52e+155) (not (<= x 1.05e+214)))))
(/ (/ (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 <= -0.0008) {
tmp = (2.0 + ((x * (1.0 + eps_m)) * (-1.0 + (1.0 / eps_m)))) / 2.0;
} else if (x <= 510.0) {
tmp = (2.0 + (x * (((1.0 / eps_m) + ((1.0 - eps_m) * (-1.0 - (1.0 / eps_m)))) - eps_m))) / 2.0;
} else if ((x <= 9.5e+65) || (!(x <= 1.6e+77) && ((x <= 1.52e+155) || !(x <= 1.05e+214)))) {
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 <= -0.0008) {
tmp = (2.0 + ((x * (1.0 + eps_m)) * (-1.0 + (1.0 / eps_m)))) / 2.0;
} else if (x <= 510.0) {
tmp = (2.0 + (x * (((1.0 / eps_m) + ((1.0 - eps_m) * (-1.0 - (1.0 / eps_m)))) - eps_m))) / 2.0;
} else if ((x <= 9.5e+65) || (!(x <= 1.6e+77) && ((x <= 1.52e+155) || !(x <= 1.05e+214)))) {
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 <= -0.0008: tmp = (2.0 + ((x * (1.0 + eps_m)) * (-1.0 + (1.0 / eps_m)))) / 2.0 elif x <= 510.0: tmp = (2.0 + (x * (((1.0 / eps_m) + ((1.0 - eps_m) * (-1.0 - (1.0 / eps_m)))) - eps_m))) / 2.0 elif (x <= 9.5e+65) or (not (x <= 1.6e+77) and ((x <= 1.52e+155) or not (x <= 1.05e+214))): 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 <= -0.0008) tmp = Float64(Float64(2.0 + Float64(Float64(x * Float64(1.0 + eps_m)) * Float64(-1.0 + Float64(1.0 / eps_m)))) / 2.0); elseif (x <= 510.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(1.0 / eps_m) + Float64(Float64(1.0 - eps_m) * Float64(-1.0 - Float64(1.0 / eps_m)))) - eps_m))) / 2.0); elseif ((x <= 9.5e+65) || (!(x <= 1.6e+77) && ((x <= 1.52e+155) || !(x <= 1.05e+214)))) 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, -0.0008], N[(N[(2.0 + N[(N[(x * N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] * N[(-1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 510.0], N[(N[(2.0 + N[(x * N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] + N[(N[(1.0 - eps$95$m), $MachinePrecision] * N[(-1.0 - N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 9.5e+65], And[N[Not[LessEqual[x, 1.6e+77]], $MachinePrecision], Or[LessEqual[x, 1.52e+155], N[Not[LessEqual[x, 1.05e+214]], $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 -0.0008:\\
\;\;\;\;\frac{2 + \left(x \cdot \left(1 + eps\_m\right)\right) \cdot \left(-1 + \frac{1}{eps\_m}\right)}{2}\\
\mathbf{elif}\;x \leq 510:\\
\;\;\;\;\frac{2 + x \cdot \left(\left(\frac{1}{eps\_m} + \left(1 - eps\_m\right) \cdot \left(-1 - \frac{1}{eps\_m}\right)\right) - eps\_m\right)}{2}\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+65} \lor \neg \left(x \leq 1.6 \cdot 10^{+77}\right) \land \left(x \leq 1.52 \cdot 10^{+155} \lor \neg \left(x \leq 1.05 \cdot 10^{+214}\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 < -8.00000000000000038e-4Initial program 95.0%
fma-neg95.0%
/-rgt-identity95.0%
fma-neg95.0%
/-rgt-identity95.0%
distribute-rgt-neg-in95.0%
sub-neg95.0%
metadata-eval95.0%
distribute-rgt-neg-in95.0%
Simplified95.0%
Taylor expanded in x around 0 46.6%
Taylor expanded in x around 0 26.1%
associate-*r*26.1%
sub-neg26.1%
metadata-eval26.1%
+-commutative26.1%
Simplified26.1%
if -8.00000000000000038e-4 < x < 510Initial program 54.1%
Simplified38.5%
Taylor expanded in x around 0 71.2%
if 510 < x < 9.5000000000000005e65 or 1.6000000000000001e77 < x < 1.5199999999999999e155 or 1.05e214 < 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.9%
Taylor expanded in eps around 0 1.8%
expm1-define1.8%
mul-1-neg1.8%
Simplified1.8%
add01.8%
expm1-undefine1.8%
expm1-undefine1.8%
add-sqr-sqrt0.0%
sqrt-unprod39.7%
sqr-neg39.7%
sqrt-unprod39.7%
add-sqr-sqrt39.7%
Applied egg-rr39.7%
add039.7%
Simplified39.7%
if 9.5000000000000005e65 < x < 1.6000000000000001e77 or 1.5199999999999999e155 < x < 1.05e214Initial 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.3%
Taylor expanded in x around 0 77.4%
Final simplification58.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -4e-288)
(/ (+ 1.0 (exp (- x))) 2.0)
(if (or (<= x 9e+68)
(and (not (<= x 1.85e+77))
(or (<= x 3.6e+154) (not (<= x 7.5e+212)))))
(/ (+ 1.0 (exp (* x (+ -1.0 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 <= -4e-288) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if ((x <= 9e+68) || (!(x <= 1.85e+77) && ((x <= 3.6e+154) || !(x <= 7.5e+212)))) {
tmp = (1.0 + exp((x * (-1.0 + 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)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-4d-288)) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else if ((x <= 9d+68) .or. (.not. (x <= 1.85d+77)) .and. (x <= 3.6d+154) .or. (.not. (x <= 7.5d+212))) then
tmp = (1.0d0 + exp((x * ((-1.0d0) + eps_m)))) / 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 <= -4e-288) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if ((x <= 9e+68) || (!(x <= 1.85e+77) && ((x <= 3.6e+154) || !(x <= 7.5e+212)))) {
tmp = (1.0 + Math.exp((x * (-1.0 + 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 <= -4e-288: tmp = (1.0 + math.exp(-x)) / 2.0 elif (x <= 9e+68) or (not (x <= 1.85e+77) and ((x <= 3.6e+154) or not (x <= 7.5e+212))): tmp = (1.0 + math.exp((x * (-1.0 + 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 <= -4e-288) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif ((x <= 9e+68) || (!(x <= 1.85e+77) && ((x <= 3.6e+154) || !(x <= 7.5e+212)))) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 + 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 = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -4e-288) tmp = (1.0 + exp(-x)) / 2.0; elseif ((x <= 9e+68) || (~((x <= 1.85e+77)) && ((x <= 3.6e+154) || ~((x <= 7.5e+212))))) tmp = (1.0 + exp((x * (-1.0 + eps_m)))) / 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, -4e-288], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 9e+68], And[N[Not[LessEqual[x, 1.85e+77]], $MachinePrecision], Or[LessEqual[x, 3.6e+154], N[Not[LessEqual[x, 7.5e+212]], $MachinePrecision]]]], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 + eps$95$m), $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}
\mathbf{if}\;x \leq -4 \cdot 10^{-288}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+68} \lor \neg \left(x \leq 1.85 \cdot 10^{+77}\right) \land \left(x \leq 3.6 \cdot 10^{+154} \lor \neg \left(x \leq 7.5 \cdot 10^{+212}\right)\right):\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 + eps\_m\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 < -4.00000000000000023e-288Initial program 70.8%
fma-neg70.7%
/-rgt-identity70.7%
fma-neg70.8%
/-rgt-identity70.8%
distribute-rgt-neg-in70.8%
sub-neg70.8%
metadata-eval70.8%
distribute-rgt-neg-in70.8%
Simplified70.8%
Taylor expanded in eps around inf 97.7%
Taylor expanded in eps around inf 97.8%
*-commutative97.8%
Simplified97.8%
Taylor expanded in eps around 0 77.0%
neg-mul-177.0%
Simplified77.0%
if -4.00000000000000023e-288 < x < 9.0000000000000007e68 or 1.84999999999999997e77 < x < 3.6000000000000001e154 or 7.5000000000000003e212 < x Initial program 72.9%
fma-neg72.9%
/-rgt-identity72.9%
fma-neg72.9%
/-rgt-identity72.9%
distribute-rgt-neg-in72.9%
sub-neg72.9%
metadata-eval72.9%
distribute-rgt-neg-in72.9%
Simplified72.9%
Taylor expanded in x around 0 40.9%
Taylor expanded in eps around inf 67.9%
neg-mul-167.9%
distribute-rgt-neg-in67.9%
Simplified67.9%
if 9.0000000000000007e68 < x < 1.84999999999999997e77 or 3.6000000000000001e154 < x < 7.5000000000000003e212Initial 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 16.2%
Taylor expanded in x around 0 79.2%
Final simplification72.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -2e-284)
(/ (+ 1.0 (exp (* x (- -1.0 eps_m)))) 2.0)
(if (or (<= x 8.5e+68)
(not
(or (<= x 1.4e+77) (and (not (<= x 6.5e+157)) (<= x 2.05e+212)))))
(/ (+ 1.0 (exp (* x (+ -1.0 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 <= -2e-284) {
tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0;
} else if ((x <= 8.5e+68) || !((x <= 1.4e+77) || (!(x <= 6.5e+157) && (x <= 2.05e+212)))) {
tmp = (1.0 + exp((x * (-1.0 + 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)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-2d-284)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps_m)))) / 2.0d0
else if ((x <= 8.5d+68) .or. (.not. (x <= 1.4d+77) .or. (.not. (x <= 6.5d+157)) .and. (x <= 2.05d+212))) then
tmp = (1.0d0 + exp((x * ((-1.0d0) + eps_m)))) / 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-284) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
} else if ((x <= 8.5e+68) || !((x <= 1.4e+77) || (!(x <= 6.5e+157) && (x <= 2.05e+212)))) {
tmp = (1.0 + Math.exp((x * (-1.0 + 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 <= -2e-284: tmp = (1.0 + math.exp((x * (-1.0 - eps_m)))) / 2.0 elif (x <= 8.5e+68) or not ((x <= 1.4e+77) or (not (x <= 6.5e+157) and (x <= 2.05e+212))): tmp = (1.0 + math.exp((x * (-1.0 + 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 <= -2e-284) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0); elseif ((x <= 8.5e+68) || !((x <= 1.4e+77) || (!(x <= 6.5e+157) && (x <= 2.05e+212)))) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 + 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 = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -2e-284) tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0; elseif ((x <= 8.5e+68) || ~(((x <= 1.4e+77) || (~((x <= 6.5e+157)) && (x <= 2.05e+212))))) tmp = (1.0 + exp((x * (-1.0 + eps_m)))) / 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-284], 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, 8.5e+68], N[Not[Or[LessEqual[x, 1.4e+77], And[N[Not[LessEqual[x, 6.5e+157]], $MachinePrecision], LessEqual[x, 2.05e+212]]]], $MachinePrecision]], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 + eps$95$m), $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}
\mathbf{if}\;x \leq -2 \cdot 10^{-284}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+68} \lor \neg \left(x \leq 1.4 \cdot 10^{+77} \lor \neg \left(x \leq 6.5 \cdot 10^{+157}\right) \land x \leq 2.05 \cdot 10^{+212}\right):\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 + eps\_m\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.00000000000000007e-284Initial program 70.8%
fma-neg70.7%
/-rgt-identity70.7%
fma-neg70.8%
/-rgt-identity70.8%
distribute-rgt-neg-in70.8%
sub-neg70.8%
metadata-eval70.8%
distribute-rgt-neg-in70.8%
Simplified70.8%
Taylor expanded in x around 0 40.1%
Taylor expanded in eps around inf 66.1%
mul-1-neg66.1%
associate-*r*66.1%
neg-mul-166.1%
Simplified66.1%
if -2.00000000000000007e-284 < x < 8.49999999999999966e68 or 1.4e77 < x < 6.5e157 or 2.04999999999999995e212 < x Initial program 72.9%
fma-neg72.9%
/-rgt-identity72.9%
fma-neg72.9%
/-rgt-identity72.9%
distribute-rgt-neg-in72.9%
sub-neg72.9%
metadata-eval72.9%
distribute-rgt-neg-in72.9%
Simplified72.9%
Taylor expanded in x around 0 40.9%
Taylor expanded in eps around inf 67.9%
neg-mul-167.9%
distribute-rgt-neg-in67.9%
Simplified67.9%
if 8.49999999999999966e68 < x < 1.4e77 or 6.5e157 < x < 2.04999999999999995e212Initial 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 16.2%
Taylor expanded in x around 0 79.2%
Final simplification68.4%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 580.0)
(/ (+ 1.0 (exp (- x))) 2.0)
(if (or (<= x 9e+65)
(and (not (<= x 1.5e+77))
(or (<= x 1.65e+155) (not (<= x 6.5e+212)))))
(/ (/ (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 <= 580.0) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if ((x <= 9e+65) || (!(x <= 1.5e+77) && ((x <= 1.65e+155) || !(x <= 6.5e+212)))) {
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 <= 580.0) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if ((x <= 9e+65) || (!(x <= 1.5e+77) && ((x <= 1.65e+155) || !(x <= 6.5e+212)))) {
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 <= 580.0: tmp = (1.0 + math.exp(-x)) / 2.0 elif (x <= 9e+65) or (not (x <= 1.5e+77) and ((x <= 1.65e+155) or not (x <= 6.5e+212))): 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 <= 580.0) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif ((x <= 9e+65) || (!(x <= 1.5e+77) && ((x <= 1.65e+155) || !(x <= 6.5e+212)))) 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, 580.0], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 9e+65], And[N[Not[LessEqual[x, 1.5e+77]], $MachinePrecision], Or[LessEqual[x, 1.65e+155], N[Not[LessEqual[x, 6.5e+212]], $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 580:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+65} \lor \neg \left(x \leq 1.5 \cdot 10^{+77}\right) \land \left(x \leq 1.65 \cdot 10^{+155} \lor \neg \left(x \leq 6.5 \cdot 10^{+212}\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 < 580Initial program 63.4%
fma-neg63.4%
/-rgt-identity63.4%
fma-neg63.4%
/-rgt-identity63.4%
distribute-rgt-neg-in63.4%
sub-neg63.4%
metadata-eval63.4%
distribute-rgt-neg-in63.4%
Simplified63.4%
Taylor expanded in eps around inf 98.4%
Taylor expanded in eps around inf 98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in eps around 0 75.7%
neg-mul-175.7%
Simplified75.7%
if 580 < x < 9e65 or 1.4999999999999999e77 < x < 1.6499999999999999e155 or 6.49999999999999997e212 < 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.9%
Taylor expanded in eps around 0 1.8%
expm1-define1.8%
mul-1-neg1.8%
Simplified1.8%
add01.8%
expm1-undefine1.8%
expm1-undefine1.8%
add-sqr-sqrt0.0%
sqrt-unprod39.7%
sqr-neg39.7%
sqrt-unprod39.7%
add-sqr-sqrt39.7%
Applied egg-rr39.7%
add039.7%
Simplified39.7%
if 9e65 < x < 1.4999999999999999e77 or 1.6499999999999999e155 < x < 6.49999999999999997e212Initial 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.3%
Taylor expanded in x around 0 77.4%
Final simplification68.7%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -0.0008)
(/ (+ 2.0 (* (* x (+ 1.0 eps_m)) (+ -1.0 (/ 1.0 eps_m)))) 2.0)
(if (<= x 1.12e-10)
1.0
(if (or (<= x 3.9e+213) (not (<= x 3.3e+306)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (+ 1.0 (/ -1.0 eps_m))) 2.0)
(/ (* x eps_m) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -0.0008) {
tmp = (2.0 + ((x * (1.0 + eps_m)) * (-1.0 + (1.0 / eps_m)))) / 2.0;
} else if (x <= 1.12e-10) {
tmp = 1.0;
} else if ((x <= 3.9e+213) || !(x <= 3.3e+306)) {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.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 <= (-0.0008d0)) then
tmp = (2.0d0 + ((x * (1.0d0 + eps_m)) * ((-1.0d0) + (1.0d0 / eps_m)))) / 2.0d0
else if (x <= 1.12d-10) then
tmp = 1.0d0
else if ((x <= 3.9d+213) .or. (.not. (x <= 3.3d+306))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (1.0d0 + ((-1.0d0) / eps_m))) / 2.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 <= -0.0008) {
tmp = (2.0 + ((x * (1.0 + eps_m)) * (-1.0 + (1.0 / eps_m)))) / 2.0;
} else if (x <= 1.12e-10) {
tmp = 1.0;
} else if ((x <= 3.9e+213) || !(x <= 3.3e+306)) {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -0.0008: tmp = (2.0 + ((x * (1.0 + eps_m)) * (-1.0 + (1.0 / eps_m)))) / 2.0 elif x <= 1.12e-10: tmp = 1.0 elif (x <= 3.9e+213) or not (x <= 3.3e+306): tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0 else: tmp = (x * eps_m) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -0.0008) tmp = Float64(Float64(2.0 + Float64(Float64(x * Float64(1.0 + eps_m)) * Float64(-1.0 + Float64(1.0 / eps_m)))) / 2.0); elseif (x <= 1.12e-10) tmp = 1.0; elseif ((x <= 3.9e+213) || !(x <= 3.3e+306)) 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(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 <= -0.0008) tmp = (2.0 + ((x * (1.0 + eps_m)) * (-1.0 + (1.0 / eps_m)))) / 2.0; elseif (x <= 1.12e-10) tmp = 1.0; elseif ((x <= 3.9e+213) || ~((x <= 3.3e+306))) tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.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, -0.0008], N[(N[(2.0 + N[(N[(x * N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] * N[(-1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.12e-10], 1.0, If[Or[LessEqual[x, 3.9e+213], N[Not[LessEqual[x, 3.3e+306]], $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[(x * eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0008:\\
\;\;\;\;\frac{2 + \left(x \cdot \left(1 + eps\_m\right)\right) \cdot \left(-1 + \frac{1}{eps\_m}\right)}{2}\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{-10}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{+213} \lor \neg \left(x \leq 3.3 \cdot 10^{+306}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps\_m}{2}\\
\end{array}
\end{array}
if x < -8.00000000000000038e-4Initial program 95.0%
fma-neg95.0%
/-rgt-identity95.0%
fma-neg95.0%
/-rgt-identity95.0%
distribute-rgt-neg-in95.0%
sub-neg95.0%
metadata-eval95.0%
distribute-rgt-neg-in95.0%
Simplified95.0%
Taylor expanded in x around 0 46.6%
Taylor expanded in x around 0 26.1%
associate-*r*26.1%
sub-neg26.1%
metadata-eval26.1%
+-commutative26.1%
Simplified26.1%
if -8.00000000000000038e-4 < x < 1.12e-10Initial program 53.4%
fma-neg53.3%
/-rgt-identity53.3%
fma-neg53.4%
/-rgt-identity53.4%
distribute-rgt-neg-in53.4%
sub-neg53.4%
metadata-eval53.4%
distribute-rgt-neg-in53.4%
Simplified53.4%
Taylor expanded in x around 0 72.2%
if 1.12e-10 < x < 3.9000000000000001e213 or 3.2999999999999999e306 < 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 30.4%
Taylor expanded in x around 0 50.8%
if 3.9000000000000001e213 < x < 3.2999999999999999e306Initial 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%
Taylor expanded in x around inf 26.5%
mul-1-neg26.5%
*-commutative26.5%
distribute-rgt-neg-in26.5%
*-commutative26.5%
distribute-rgt-neg-in26.5%
sub-neg26.5%
neg-mul-126.5%
distribute-neg-in26.5%
metadata-eval26.5%
neg-mul-126.5%
remove-double-neg26.5%
+-commutative26.5%
Simplified26.5%
Taylor expanded in eps around inf 26.7%
*-commutative26.7%
Simplified26.7%
Final simplification56.2%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -0.0008)
(/ (+ 2.0 (* (* x (+ 1.0 eps_m)) (+ -1.0 (/ 1.0 eps_m)))) 2.0)
(if (<= x 1.12e-10)
(/
(+
2.0
(*
x
(- (+ (/ 1.0 eps_m) (* (- 1.0 eps_m) (- -1.0 (/ 1.0 eps_m)))) eps_m)))
2.0)
(if (or (<= x 2.12e+214) (not (<= x 1.2e+306)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (+ 1.0 (/ -1.0 eps_m))) 2.0)
(/ (* x eps_m) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -0.0008) {
tmp = (2.0 + ((x * (1.0 + eps_m)) * (-1.0 + (1.0 / eps_m)))) / 2.0;
} else if (x <= 1.12e-10) {
tmp = (2.0 + (x * (((1.0 / eps_m) + ((1.0 - eps_m) * (-1.0 - (1.0 / eps_m)))) - eps_m))) / 2.0;
} else if ((x <= 2.12e+214) || !(x <= 1.2e+306)) {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.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 <= (-0.0008d0)) then
tmp = (2.0d0 + ((x * (1.0d0 + eps_m)) * ((-1.0d0) + (1.0d0 / eps_m)))) / 2.0d0
else if (x <= 1.12d-10) then
tmp = (2.0d0 + (x * (((1.0d0 / eps_m) + ((1.0d0 - eps_m) * ((-1.0d0) - (1.0d0 / eps_m)))) - eps_m))) / 2.0d0
else if ((x <= 2.12d+214) .or. (.not. (x <= 1.2d+306))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (1.0d0 + ((-1.0d0) / eps_m))) / 2.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 <= -0.0008) {
tmp = (2.0 + ((x * (1.0 + eps_m)) * (-1.0 + (1.0 / eps_m)))) / 2.0;
} else if (x <= 1.12e-10) {
tmp = (2.0 + (x * (((1.0 / eps_m) + ((1.0 - eps_m) * (-1.0 - (1.0 / eps_m)))) - eps_m))) / 2.0;
} else if ((x <= 2.12e+214) || !(x <= 1.2e+306)) {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -0.0008: tmp = (2.0 + ((x * (1.0 + eps_m)) * (-1.0 + (1.0 / eps_m)))) / 2.0 elif x <= 1.12e-10: tmp = (2.0 + (x * (((1.0 / eps_m) + ((1.0 - eps_m) * (-1.0 - (1.0 / eps_m)))) - eps_m))) / 2.0 elif (x <= 2.12e+214) or not (x <= 1.2e+306): tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0 else: tmp = (x * eps_m) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -0.0008) tmp = Float64(Float64(2.0 + Float64(Float64(x * Float64(1.0 + eps_m)) * Float64(-1.0 + Float64(1.0 / eps_m)))) / 2.0); elseif (x <= 1.12e-10) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(1.0 / eps_m) + Float64(Float64(1.0 - eps_m) * Float64(-1.0 - Float64(1.0 / eps_m)))) - eps_m))) / 2.0); elseif ((x <= 2.12e+214) || !(x <= 1.2e+306)) 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(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 <= -0.0008) tmp = (2.0 + ((x * (1.0 + eps_m)) * (-1.0 + (1.0 / eps_m)))) / 2.0; elseif (x <= 1.12e-10) tmp = (2.0 + (x * (((1.0 / eps_m) + ((1.0 - eps_m) * (-1.0 - (1.0 / eps_m)))) - eps_m))) / 2.0; elseif ((x <= 2.12e+214) || ~((x <= 1.2e+306))) tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.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, -0.0008], N[(N[(2.0 + N[(N[(x * N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] * N[(-1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.12e-10], N[(N[(2.0 + N[(x * N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] + N[(N[(1.0 - eps$95$m), $MachinePrecision] * N[(-1.0 - N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 2.12e+214], N[Not[LessEqual[x, 1.2e+306]], $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[(x * eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0008:\\
\;\;\;\;\frac{2 + \left(x \cdot \left(1 + eps\_m\right)\right) \cdot \left(-1 + \frac{1}{eps\_m}\right)}{2}\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{-10}:\\
\;\;\;\;\frac{2 + x \cdot \left(\left(\frac{1}{eps\_m} + \left(1 - eps\_m\right) \cdot \left(-1 - \frac{1}{eps\_m}\right)\right) - eps\_m\right)}{2}\\
\mathbf{elif}\;x \leq 2.12 \cdot 10^{+214} \lor \neg \left(x \leq 1.2 \cdot 10^{+306}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps\_m}{2}\\
\end{array}
\end{array}
if x < -8.00000000000000038e-4Initial program 95.0%
fma-neg95.0%
/-rgt-identity95.0%
fma-neg95.0%
/-rgt-identity95.0%
distribute-rgt-neg-in95.0%
sub-neg95.0%
metadata-eval95.0%
distribute-rgt-neg-in95.0%
Simplified95.0%
Taylor expanded in x around 0 46.6%
Taylor expanded in x around 0 26.1%
associate-*r*26.1%
sub-neg26.1%
metadata-eval26.1%
+-commutative26.1%
Simplified26.1%
if -8.00000000000000038e-4 < x < 1.12e-10Initial program 53.4%
Simplified37.6%
Taylor expanded in x around 0 72.2%
if 1.12e-10 < x < 2.1199999999999999e214 or 1.19999999999999993e306 < 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 30.4%
Taylor expanded in x around 0 50.8%
if 2.1199999999999999e214 < x < 1.19999999999999993e306Initial 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%
Taylor expanded in x around inf 26.5%
mul-1-neg26.5%
*-commutative26.5%
distribute-rgt-neg-in26.5%
*-commutative26.5%
distribute-rgt-neg-in26.5%
sub-neg26.5%
neg-mul-126.5%
distribute-neg-in26.5%
metadata-eval26.5%
neg-mul-126.5%
remove-double-neg26.5%
+-commutative26.5%
Simplified26.5%
Taylor expanded in eps around inf 26.7%
*-commutative26.7%
Simplified26.7%
Final simplification56.2%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 1.12e-10)
1.0
(if (or (<= x 2.9e+212) (not (<= x 3.15e+305)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (+ 1.0 (/ -1.0 eps_m))) 2.0)
(/ (* x eps_m) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 1.12e-10) {
tmp = 1.0;
} else if ((x <= 2.9e+212) || !(x <= 3.15e+305)) {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.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 <= 1.12d-10) then
tmp = 1.0d0
else if ((x <= 2.9d+212) .or. (.not. (x <= 3.15d+305))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (1.0d0 + ((-1.0d0) / eps_m))) / 2.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 <= 1.12e-10) {
tmp = 1.0;
} else if ((x <= 2.9e+212) || !(x <= 3.15e+305)) {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 1.12e-10: tmp = 1.0 elif (x <= 2.9e+212) or not (x <= 3.15e+305): tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0 else: tmp = (x * eps_m) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 1.12e-10) tmp = 1.0; elseif ((x <= 2.9e+212) || !(x <= 3.15e+305)) 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(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 <= 1.12e-10) tmp = 1.0; elseif ((x <= 2.9e+212) || ~((x <= 3.15e+305))) tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.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, 1.12e-10], 1.0, If[Or[LessEqual[x, 2.9e+212], N[Not[LessEqual[x, 3.15e+305]], $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[(x * eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.12 \cdot 10^{-10}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{+212} \lor \neg \left(x \leq 3.15 \cdot 10^{+305}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps\_m}{2}\\
\end{array}
\end{array}
if x < 1.12e-10Initial 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 x around 0 56.2%
if 1.12e-10 < x < 2.8999999999999998e212 or 3.1499999999999999e305 < 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 30.4%
Taylor expanded in x around 0 50.8%
if 2.8999999999999998e212 < x < 3.1499999999999999e305Initial 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%
Taylor expanded in x around inf 26.5%
mul-1-neg26.5%
*-commutative26.5%
distribute-rgt-neg-in26.5%
*-commutative26.5%
distribute-rgt-neg-in26.5%
sub-neg26.5%
neg-mul-126.5%
distribute-neg-in26.5%
metadata-eval26.5%
neg-mul-126.5%
remove-double-neg26.5%
+-commutative26.5%
Simplified26.5%
Taylor expanded in eps around inf 26.7%
*-commutative26.7%
Simplified26.7%
Final simplification52.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 1.12e-10) 1.0 (/ (* x eps_m) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 1.12e-10) {
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 <= 1.12d-10) 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 <= 1.12e-10) {
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 <= 1.12e-10: 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 <= 1.12e-10) 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 <= 1.12e-10) 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, 1.12e-10], 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 1.12 \cdot 10^{-10}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps\_m}{2}\\
\end{array}
\end{array}
if x < 1.12e-10Initial 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 x around 0 56.2%
if 1.12e-10 < 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 26.3%
Taylor expanded in x around inf 11.9%
mul-1-neg11.9%
*-commutative11.9%
distribute-rgt-neg-in11.9%
*-commutative11.9%
distribute-rgt-neg-in11.9%
sub-neg11.9%
neg-mul-111.9%
distribute-neg-in11.9%
metadata-eval11.9%
neg-mul-111.9%
remove-double-neg11.9%
+-commutative11.9%
Simplified11.9%
Taylor expanded in eps around inf 12.6%
*-commutative12.6%
Simplified12.6%
Final simplification42.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ 2.0 (* x eps_m)) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (2.0 + (x * 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 = (2.0d0 + (x * eps_m)) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (2.0 + (x * eps_m)) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (2.0 + (x * eps_m)) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(2.0 + Float64(x * eps_m)) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (2.0 + (x * eps_m)) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(2.0 + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{2 + x \cdot eps\_m}{2}
\end{array}
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 40.1%
Taylor expanded in x around 0 28.5%
mul-1-neg28.5%
*-commutative28.5%
unsub-neg28.5%
Simplified28.5%
Taylor expanded in eps around inf 46.0%
associate-*r*46.0%
neg-mul-146.0%
Simplified46.0%
Final simplification46.0%
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 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 39.0%
Final simplification39.0%
herbie shell --seed 2024034
(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))