
(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 15 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 (exp (* x (+ eps_m -1.0)))))
(if (<= x 4e-10)
(/ (+ t_0 (exp (* x (- eps_m)))) 2.0)
(/ (+ t_0 (exp (- x))) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp((x * (eps_m + -1.0)));
double tmp;
if (x <= 4e-10) {
tmp = (t_0 + exp((x * -eps_m))) / 2.0;
} else {
tmp = (t_0 + exp(-x)) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = exp((x * (eps_m + (-1.0d0))))
if (x <= 4d-10) then
tmp = (t_0 + exp((x * -eps_m))) / 2.0d0
else
tmp = (t_0 + exp(-x)) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = Math.exp((x * (eps_m + -1.0)));
double tmp;
if (x <= 4e-10) {
tmp = (t_0 + Math.exp((x * -eps_m))) / 2.0;
} else {
tmp = (t_0 + Math.exp(-x)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp((x * (eps_m + -1.0))) tmp = 0 if x <= 4e-10: tmp = (t_0 + math.exp((x * -eps_m))) / 2.0 else: tmp = (t_0 + math.exp(-x)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(x * Float64(eps_m + -1.0))) tmp = 0.0 if (x <= 4e-10) tmp = Float64(Float64(t_0 + exp(Float64(x * Float64(-eps_m)))) / 2.0); else tmp = Float64(Float64(t_0 + exp(Float64(-x))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp((x * (eps_m + -1.0))); tmp = 0.0; if (x <= 4e-10) tmp = (t_0 + exp((x * -eps_m))) / 2.0; else tmp = (t_0 + exp(-x)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 4e-10], N[(N[(t$95$0 + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(eps\_m + -1\right)}\\
\mathbf{if}\;x \leq 4 \cdot 10^{-10}:\\
\;\;\;\;\frac{t\_0 + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 + e^{-x}}{2}\\
\end{array}
\end{array}
if x < 4.00000000000000015e-10Initial program 62.2%
fma-neg62.2%
/-rgt-identity62.2%
fma-neg62.2%
/-rgt-identity62.2%
distribute-rgt-neg-in62.2%
sub-neg62.2%
metadata-eval62.2%
distribute-rgt-neg-in62.2%
Simplified62.2%
Taylor expanded in eps around inf 98.9%
Taylor expanded in eps around -inf 98.9%
associate-*r*98.9%
mul-1-neg98.9%
sub-neg98.9%
mul-1-neg98.9%
mul-1-neg98.9%
associate-*r*98.9%
mul-1-neg98.9%
mul-1-neg98.9%
Simplified98.9%
Taylor expanded in eps around inf 98.9%
Taylor expanded in x around inf 98.9%
associate-*r*98.9%
neg-mul-198.9%
associate-*r*98.9%
neg-mul-198.9%
Simplified98.9%
if 4.00000000000000015e-10 < x Initial program 99.1%
fma-neg99.1%
/-rgt-identity99.1%
fma-neg99.1%
/-rgt-identity99.1%
distribute-rgt-neg-in99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-rgt-neg-in99.1%
Simplified99.1%
Taylor expanded in eps around inf 98.8%
Taylor expanded in eps around -inf 98.8%
associate-*r*98.8%
mul-1-neg98.8%
sub-neg98.8%
mul-1-neg98.8%
mul-1-neg98.8%
associate-*r*98.8%
mul-1-neg98.8%
mul-1-neg98.8%
Simplified98.8%
Taylor expanded in eps around 0 65.6%
Final simplification89.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 5e-14) (/ (* 2.0 (exp (- x))) 2.0) (/ (+ (exp (* x (+ eps_m -1.0))) (exp (* x (- eps_m)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 5e-14) {
tmp = (2.0 * exp(-x)) / 2.0;
} else {
tmp = (exp((x * (eps_m + -1.0))) + exp((x * -eps_m))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 5d-14) then
tmp = (2.0d0 * exp(-x)) / 2.0d0
else
tmp = (exp((x * (eps_m + (-1.0d0)))) + exp((x * -eps_m))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 5e-14) {
tmp = (2.0 * Math.exp(-x)) / 2.0;
} else {
tmp = (Math.exp((x * (eps_m + -1.0))) + Math.exp((x * -eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 5e-14: tmp = (2.0 * math.exp(-x)) / 2.0 else: tmp = (math.exp((x * (eps_m + -1.0))) + math.exp((x * -eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 5e-14) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(eps_m + -1.0))) + exp(Float64(x * Float64(-eps_m)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 5e-14) tmp = (2.0 * exp(-x)) / 2.0; else tmp = (exp((x * (eps_m + -1.0))) + exp((x * -eps_m))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 5e-14], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(eps\_m + -1\right)} + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 5.0000000000000002e-14Initial program 60.3%
fma-neg60.2%
/-rgt-identity60.2%
fma-neg60.3%
/-rgt-identity60.3%
distribute-rgt-neg-in60.3%
sub-neg60.3%
metadata-eval60.3%
distribute-rgt-neg-in60.3%
Simplified60.3%
Taylor expanded in eps around inf 98.4%
Taylor expanded in eps around -inf 98.4%
associate-*r*98.4%
mul-1-neg98.4%
sub-neg98.4%
mul-1-neg98.4%
mul-1-neg98.4%
associate-*r*98.4%
mul-1-neg98.4%
mul-1-neg98.4%
Simplified98.4%
Taylor expanded in eps around 0 75.1%
if 5.0000000000000002e-14 < eps Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around -inf 100.0%
associate-*r*100.0%
mul-1-neg100.0%
sub-neg100.0%
mul-1-neg100.0%
mul-1-neg100.0%
associate-*r*100.0%
mul-1-neg100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
associate-*r*100.0%
neg-mul-1100.0%
Simplified100.0%
Final simplification83.0%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ (exp (* x (+ eps_m -1.0))) (exp (* x (- -1.0 eps_m)))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp((x * (eps_m + -1.0))) + exp((x * (-1.0 - eps_m)))) / 2.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = (exp((x * (eps_m + (-1.0d0)))) + exp((x * ((-1.0d0) - eps_m)))) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (Math.exp((x * (eps_m + -1.0))) + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (math.exp((x * (eps_m + -1.0))) + math.exp((x * (-1.0 - eps_m)))) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(exp(Float64(x * Float64(eps_m + -1.0))) + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (exp((x * (eps_m + -1.0))) + exp((x * (-1.0 - eps_m)))) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{e^{x \cdot \left(eps\_m + -1\right)} + e^{x \cdot \left(-1 - eps\_m\right)}}{2}
\end{array}
Initial program 72.8%
fma-neg72.8%
/-rgt-identity72.8%
fma-neg72.8%
/-rgt-identity72.8%
distribute-rgt-neg-in72.8%
sub-neg72.8%
metadata-eval72.8%
distribute-rgt-neg-in72.8%
Simplified72.8%
Taylor expanded in eps around inf 98.9%
Taylor expanded in eps around -inf 98.9%
associate-*r*98.9%
mul-1-neg98.9%
sub-neg98.9%
mul-1-neg98.9%
mul-1-neg98.9%
associate-*r*98.9%
mul-1-neg98.9%
mul-1-neg98.9%
Simplified98.9%
Final simplification98.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0
(/
(+ (+ x (- (exp (* x (+ eps_m -1.0))) (* x eps_m))) (- 1.0 x))
2.0))
(t_1 (* (* x eps_m) 0.5)))
(if (<= x -6e-257)
(/ (+ 1.0 (exp (* x (- eps_m)))) 2.0)
(if (<= x 4.2e+94)
t_0
(if (<= x 2.8e+155)
t_1
(if (<= x 1.66e+183)
t_0
(if (<= x 6e+225) t_1 (* 0.25 (/ (* x x) eps_m)))))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = ((x + (exp((x * (eps_m + -1.0))) - (x * eps_m))) + (1.0 - x)) / 2.0;
double t_1 = (x * eps_m) * 0.5;
double tmp;
if (x <= -6e-257) {
tmp = (1.0 + exp((x * -eps_m))) / 2.0;
} else if (x <= 4.2e+94) {
tmp = t_0;
} else if (x <= 2.8e+155) {
tmp = t_1;
} else if (x <= 1.66e+183) {
tmp = t_0;
} else if (x <= 6e+225) {
tmp = t_1;
} else {
tmp = 0.25 * ((x * x) / eps_m);
}
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) :: t_1
real(8) :: tmp
t_0 = ((x + (exp((x * (eps_m + (-1.0d0)))) - (x * eps_m))) + (1.0d0 - x)) / 2.0d0
t_1 = (x * eps_m) * 0.5d0
if (x <= (-6d-257)) then
tmp = (1.0d0 + exp((x * -eps_m))) / 2.0d0
else if (x <= 4.2d+94) then
tmp = t_0
else if (x <= 2.8d+155) then
tmp = t_1
else if (x <= 1.66d+183) then
tmp = t_0
else if (x <= 6d+225) then
tmp = t_1
else
tmp = 0.25d0 * ((x * x) / eps_m)
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = ((x + (Math.exp((x * (eps_m + -1.0))) - (x * eps_m))) + (1.0 - x)) / 2.0;
double t_1 = (x * eps_m) * 0.5;
double tmp;
if (x <= -6e-257) {
tmp = (1.0 + Math.exp((x * -eps_m))) / 2.0;
} else if (x <= 4.2e+94) {
tmp = t_0;
} else if (x <= 2.8e+155) {
tmp = t_1;
} else if (x <= 1.66e+183) {
tmp = t_0;
} else if (x <= 6e+225) {
tmp = t_1;
} else {
tmp = 0.25 * ((x * x) / eps_m);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = ((x + (math.exp((x * (eps_m + -1.0))) - (x * eps_m))) + (1.0 - x)) / 2.0 t_1 = (x * eps_m) * 0.5 tmp = 0 if x <= -6e-257: tmp = (1.0 + math.exp((x * -eps_m))) / 2.0 elif x <= 4.2e+94: tmp = t_0 elif x <= 2.8e+155: tmp = t_1 elif x <= 1.66e+183: tmp = t_0 elif x <= 6e+225: tmp = t_1 else: tmp = 0.25 * ((x * x) / eps_m) return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(Float64(x + Float64(exp(Float64(x * Float64(eps_m + -1.0))) - Float64(x * eps_m))) + Float64(1.0 - x)) / 2.0) t_1 = Float64(Float64(x * eps_m) * 0.5) tmp = 0.0 if (x <= -6e-257) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps_m)))) / 2.0); elseif (x <= 4.2e+94) tmp = t_0; elseif (x <= 2.8e+155) tmp = t_1; elseif (x <= 1.66e+183) tmp = t_0; elseif (x <= 6e+225) tmp = t_1; else tmp = Float64(0.25 * Float64(Float64(x * x) / eps_m)); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = ((x + (exp((x * (eps_m + -1.0))) - (x * eps_m))) + (1.0 - x)) / 2.0; t_1 = (x * eps_m) * 0.5; tmp = 0.0; if (x <= -6e-257) tmp = (1.0 + exp((x * -eps_m))) / 2.0; elseif (x <= 4.2e+94) tmp = t_0; elseif (x <= 2.8e+155) tmp = t_1; elseif (x <= 1.66e+183) tmp = t_0; elseif (x <= 6e+225) tmp = t_1; else tmp = 0.25 * ((x * x) / eps_m); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(N[(x + N[(N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * eps$95$m), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[x, -6e-257], N[(N[(1.0 + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 4.2e+94], t$95$0, If[LessEqual[x, 2.8e+155], t$95$1, If[LessEqual[x, 1.66e+183], t$95$0, If[LessEqual[x, 6e+225], t$95$1, N[(0.25 * N[(N[(x * x), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \frac{\left(x + \left(e^{x \cdot \left(eps\_m + -1\right)} - x \cdot eps\_m\right)\right) + \left(1 - x\right)}{2}\\
t_1 := \left(x \cdot eps\_m\right) \cdot 0.5\\
\mathbf{if}\;x \leq -6 \cdot 10^{-257}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+94}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{+155}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.66 \cdot 10^{+183}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+225}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{x \cdot x}{eps\_m}\\
\end{array}
\end{array}
if x < -5.9999999999999999e-257Initial program 69.8%
fma-neg69.7%
/-rgt-identity69.7%
fma-neg69.8%
/-rgt-identity69.8%
distribute-rgt-neg-in69.8%
sub-neg69.8%
metadata-eval69.8%
distribute-rgt-neg-in69.8%
Simplified69.8%
Taylor expanded in eps around inf 98.0%
Taylor expanded in eps around -inf 98.0%
associate-*r*98.0%
mul-1-neg98.0%
sub-neg98.0%
mul-1-neg98.0%
mul-1-neg98.0%
associate-*r*98.0%
mul-1-neg98.0%
mul-1-neg98.0%
Simplified98.0%
Taylor expanded in eps around inf 98.0%
Taylor expanded in x around 0 76.4%
if -5.9999999999999999e-257 < x < 4.19999999999999979e94 or 2.80000000000000016e155 < x < 1.66000000000000008e183Initial program 64.6%
fma-neg64.6%
/-rgt-identity64.6%
fma-neg64.6%
/-rgt-identity64.6%
distribute-rgt-neg-in64.6%
sub-neg64.6%
metadata-eval64.6%
distribute-rgt-neg-in64.6%
Simplified64.6%
Taylor expanded in x around 0 39.2%
Taylor expanded in eps around inf 74.2%
Simplified85.6%
if 4.19999999999999979e94 < x < 2.80000000000000016e155 or 1.66000000000000008e183 < x < 6.000000000000001e225Initial 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.7%
Taylor expanded in eps around inf 39.0%
associate-*r*39.0%
mul-1-neg39.0%
Simplified39.0%
div-inv39.0%
add-sqr-sqrt39.0%
sqrt-unprod38.8%
sqr-neg38.8%
sqrt-unprod0.0%
add-sqr-sqrt29.5%
distribute-rgt-neg-in29.5%
*-commutative29.5%
distribute-rgt-neg-in29.5%
remove-double-neg29.5%
metadata-eval29.5%
Applied egg-rr29.5%
if 6.000000000000001e225 < 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 48.6%
Taylor expanded in eps around 0 1.6%
associate--r+1.6%
cancel-sign-sub-inv1.6%
expm1-def1.6%
mul-1-neg1.6%
metadata-eval1.6%
*-lft-identity1.6%
Simplified1.6%
Taylor expanded in x around 0 20.6%
unpow220.6%
Applied egg-rr20.6%
Final simplification71.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 420.0)
(/ (+ 1.0 (exp (- x))) 2.0)
(if (<= x 9e+85)
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (+ 1.0 (/ -1.0 eps_m))) 2.0)
(* 0.5 (/ (+ x (expm1 x)) eps_m)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 420.0) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if (x <= 9e+85) {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
} else {
tmp = 0.5 * ((x + expm1(x)) / eps_m);
}
return tmp;
}
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 420.0) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if (x <= 9e+85) {
tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
} else {
tmp = 0.5 * ((x + Math.expm1(x)) / eps_m);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 420.0: tmp = (1.0 + math.exp(-x)) / 2.0 elif x <= 9e+85: tmp = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0 else: tmp = 0.5 * ((x + math.expm1(x)) / eps_m) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 420.0) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif (x <= 9e+85) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(1.0 + Float64(-1.0 / eps_m))) / 2.0); else tmp = Float64(0.5 * Float64(Float64(x + expm1(x)) / eps_m)); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 420.0], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 9e+85], 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[(0.5 * N[(N[(x + N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 420:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+85}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x + \mathsf{expm1}\left(x\right)}{eps\_m}\\
\end{array}
\end{array}
if x < 420Initial program 62.8%
fma-neg62.8%
/-rgt-identity62.8%
fma-neg62.8%
/-rgt-identity62.8%
distribute-rgt-neg-in62.8%
sub-neg62.8%
metadata-eval62.8%
distribute-rgt-neg-in62.8%
Simplified62.8%
Taylor expanded in eps around inf 98.5%
Taylor expanded in eps around -inf 98.5%
associate-*r*98.5%
mul-1-neg98.5%
sub-neg98.5%
mul-1-neg98.5%
mul-1-neg98.5%
associate-*r*98.5%
mul-1-neg98.5%
mul-1-neg98.5%
Simplified98.5%
Taylor expanded in eps around inf 98.4%
Taylor expanded in eps around 0 76.4%
neg-mul-176.4%
Simplified76.4%
if 420 < x < 9.00000000000000013e85Initial 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.4%
Taylor expanded in x around 0 75.8%
if 9.00000000000000013e85 < 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 0 1.6%
associate--r+1.6%
cancel-sign-sub-inv1.6%
expm1-def1.6%
mul-1-neg1.6%
metadata-eval1.6%
*-lft-identity1.6%
Simplified1.6%
div-inv1.6%
+-commutative1.6%
add-sqr-sqrt0.0%
sqrt-unprod23.2%
sqr-neg23.2%
sqrt-unprod23.2%
add-sqr-sqrt23.2%
metadata-eval23.2%
Applied egg-rr23.2%
Final simplification65.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -2e-259)
(/ (+ 1.0 (exp (* x (- eps_m)))) 2.0)
(if (<= x 1e+90)
(/ (* 2.0 (exp (- x))) 2.0)
(* 0.5 (/ (+ x (expm1 x)) eps_m)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -2e-259) {
tmp = (1.0 + exp((x * -eps_m))) / 2.0;
} else if (x <= 1e+90) {
tmp = (2.0 * exp(-x)) / 2.0;
} else {
tmp = 0.5 * ((x + expm1(x)) / eps_m);
}
return tmp;
}
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -2e-259) {
tmp = (1.0 + Math.exp((x * -eps_m))) / 2.0;
} else if (x <= 1e+90) {
tmp = (2.0 * Math.exp(-x)) / 2.0;
} else {
tmp = 0.5 * ((x + Math.expm1(x)) / eps_m);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -2e-259: tmp = (1.0 + math.exp((x * -eps_m))) / 2.0 elif x <= 1e+90: tmp = (2.0 * math.exp(-x)) / 2.0 else: tmp = 0.5 * ((x + math.expm1(x)) / eps_m) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -2e-259) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps_m)))) / 2.0); elseif (x <= 1e+90) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0); else tmp = Float64(0.5 * Float64(Float64(x + expm1(x)) / eps_m)); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -2e-259], N[(N[(1.0 + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1e+90], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(0.5 * N[(N[(x + N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-259}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\mathbf{elif}\;x \leq 10^{+90}:\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x + \mathsf{expm1}\left(x\right)}{eps\_m}\\
\end{array}
\end{array}
if x < -2.0000000000000001e-259Initial program 69.8%
fma-neg69.7%
/-rgt-identity69.7%
fma-neg69.8%
/-rgt-identity69.8%
distribute-rgt-neg-in69.8%
sub-neg69.8%
metadata-eval69.8%
distribute-rgt-neg-in69.8%
Simplified69.8%
Taylor expanded in eps around inf 98.0%
Taylor expanded in eps around -inf 98.0%
associate-*r*98.0%
mul-1-neg98.0%
sub-neg98.0%
mul-1-neg98.0%
mul-1-neg98.0%
associate-*r*98.0%
mul-1-neg98.0%
mul-1-neg98.0%
Simplified98.0%
Taylor expanded in eps around inf 98.0%
Taylor expanded in x around 0 76.4%
if -2.0000000000000001e-259 < x < 9.99999999999999966e89Initial program 62.4%
fma-neg62.3%
/-rgt-identity62.3%
fma-neg62.4%
/-rgt-identity62.4%
distribute-rgt-neg-in62.4%
sub-neg62.4%
metadata-eval62.4%
distribute-rgt-neg-in62.4%
Simplified62.4%
Taylor expanded in eps around inf 99.1%
Taylor expanded in eps around -inf 99.1%
associate-*r*99.1%
mul-1-neg99.1%
sub-neg99.1%
mul-1-neg99.1%
mul-1-neg99.1%
associate-*r*99.1%
mul-1-neg99.1%
mul-1-neg99.1%
Simplified99.1%
Taylor expanded in eps around 0 74.7%
if 9.99999999999999966e89 < 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 0 1.6%
associate--r+1.6%
cancel-sign-sub-inv1.6%
expm1-def1.6%
mul-1-neg1.6%
metadata-eval1.6%
*-lft-identity1.6%
Simplified1.6%
div-inv1.6%
+-commutative1.6%
add-sqr-sqrt0.0%
sqrt-unprod23.2%
sqr-neg23.2%
sqrt-unprod23.2%
add-sqr-sqrt23.2%
metadata-eval23.2%
Applied egg-rr23.2%
Final simplification64.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 1e+90) (/ (* 2.0 (exp (- x))) 2.0) (* 0.5 (/ (+ x (expm1 x)) eps_m))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 1e+90) {
tmp = (2.0 * exp(-x)) / 2.0;
} else {
tmp = 0.5 * ((x + expm1(x)) / eps_m);
}
return tmp;
}
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 1e+90) {
tmp = (2.0 * Math.exp(-x)) / 2.0;
} else {
tmp = 0.5 * ((x + Math.expm1(x)) / eps_m);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 1e+90: tmp = (2.0 * math.exp(-x)) / 2.0 else: tmp = 0.5 * ((x + math.expm1(x)) / eps_m) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 1e+90) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0); else tmp = Float64(0.5 * Float64(Float64(x + expm1(x)) / eps_m)); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 1e+90], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(0.5 * N[(N[(x + N[(Exp[x] - 1), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+90}:\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x + \mathsf{expm1}\left(x\right)}{eps\_m}\\
\end{array}
\end{array}
if x < 9.99999999999999966e89Initial program 65.8%
fma-neg65.7%
/-rgt-identity65.7%
fma-neg65.8%
/-rgt-identity65.8%
distribute-rgt-neg-in65.8%
sub-neg65.8%
metadata-eval65.8%
distribute-rgt-neg-in65.8%
Simplified65.8%
Taylor expanded in eps around inf 98.6%
Taylor expanded in eps around -inf 98.6%
associate-*r*98.6%
mul-1-neg98.6%
sub-neg98.6%
mul-1-neg98.6%
mul-1-neg98.6%
associate-*r*98.6%
mul-1-neg98.6%
mul-1-neg98.6%
Simplified98.6%
Taylor expanded in eps around 0 76.3%
if 9.99999999999999966e89 < 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 0 1.6%
associate--r+1.6%
cancel-sign-sub-inv1.6%
expm1-def1.6%
mul-1-neg1.6%
metadata-eval1.6%
*-lft-identity1.6%
Simplified1.6%
div-inv1.6%
+-commutative1.6%
add-sqr-sqrt0.0%
sqrt-unprod23.2%
sqr-neg23.2%
sqrt-unprod23.2%
add-sqr-sqrt23.2%
metadata-eval23.2%
Applied egg-rr23.2%
Final simplification65.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (/ (+ (+ 1.0 (/ 1.0 eps_m)) (+ 1.0 (/ -1.0 eps_m))) 2.0)))
(if (<= x 420.0)
(/ (+ 1.0 (exp (- x))) 2.0)
(if (<= x 5e+87)
t_0
(if (<= x 3e+155)
(* (* x eps_m) 0.5)
(if (<= x 5.5e+179) t_0 (* 0.25 (/ (* x x) eps_m))))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
double tmp;
if (x <= 420.0) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if (x <= 5e+87) {
tmp = t_0;
} else if (x <= 3e+155) {
tmp = (x * eps_m) * 0.5;
} else if (x <= 5.5e+179) {
tmp = t_0;
} else {
tmp = 0.25 * ((x * x) / eps_m);
}
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 = ((1.0d0 + (1.0d0 / eps_m)) + (1.0d0 + ((-1.0d0) / eps_m))) / 2.0d0
if (x <= 420.0d0) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else if (x <= 5d+87) then
tmp = t_0
else if (x <= 3d+155) then
tmp = (x * eps_m) * 0.5d0
else if (x <= 5.5d+179) then
tmp = t_0
else
tmp = 0.25d0 * ((x * x) / eps_m)
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0;
double tmp;
if (x <= 420.0) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if (x <= 5e+87) {
tmp = t_0;
} else if (x <= 3e+155) {
tmp = (x * eps_m) * 0.5;
} else if (x <= 5.5e+179) {
tmp = t_0;
} else {
tmp = 0.25 * ((x * x) / eps_m);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0 tmp = 0 if x <= 420.0: tmp = (1.0 + math.exp(-x)) / 2.0 elif x <= 5e+87: tmp = t_0 elif x <= 3e+155: tmp = (x * eps_m) * 0.5 elif x <= 5.5e+179: tmp = t_0 else: tmp = 0.25 * ((x * x) / eps_m) return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(1.0 + Float64(-1.0 / eps_m))) / 2.0) tmp = 0.0 if (x <= 420.0) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif (x <= 5e+87) tmp = t_0; elseif (x <= 3e+155) tmp = Float64(Float64(x * eps_m) * 0.5); elseif (x <= 5.5e+179) tmp = t_0; else tmp = Float64(0.25 * Float64(Float64(x * x) / eps_m)); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = ((1.0 + (1.0 / eps_m)) + (1.0 + (-1.0 / eps_m))) / 2.0; tmp = 0.0; if (x <= 420.0) tmp = (1.0 + exp(-x)) / 2.0; elseif (x <= 5e+87) tmp = t_0; elseif (x <= 3e+155) tmp = (x * eps_m) * 0.5; elseif (x <= 5.5e+179) tmp = t_0; else tmp = 0.25 * ((x * x) / eps_m); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{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]}, If[LessEqual[x, 420.0], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 5e+87], t$95$0, If[LessEqual[x, 3e+155], N[(N[(x * eps$95$m), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 5.5e+179], t$95$0, N[(0.25 * N[(N[(x * x), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \frac{\left(1 + \frac{1}{eps\_m}\right) + \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\mathbf{if}\;x \leq 420:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+87}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+155}:\\
\;\;\;\;\left(x \cdot eps\_m\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+179}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{x \cdot x}{eps\_m}\\
\end{array}
\end{array}
if x < 420Initial program 62.8%
fma-neg62.8%
/-rgt-identity62.8%
fma-neg62.8%
/-rgt-identity62.8%
distribute-rgt-neg-in62.8%
sub-neg62.8%
metadata-eval62.8%
distribute-rgt-neg-in62.8%
Simplified62.8%
Taylor expanded in eps around inf 98.5%
Taylor expanded in eps around -inf 98.5%
associate-*r*98.5%
mul-1-neg98.5%
sub-neg98.5%
mul-1-neg98.5%
mul-1-neg98.5%
associate-*r*98.5%
mul-1-neg98.5%
mul-1-neg98.5%
Simplified98.5%
Taylor expanded in eps around inf 98.4%
Taylor expanded in eps around 0 76.4%
neg-mul-176.4%
Simplified76.4%
if 420 < x < 4.9999999999999998e87 or 3.0000000000000001e155 < x < 5.4999999999999998e179Initial 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 76.9%
if 4.9999999999999998e87 < x < 3.0000000000000001e155Initial 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 28.3%
Taylor expanded in eps around inf 28.5%
associate-*r*28.5%
mul-1-neg28.5%
Simplified28.5%
div-inv28.5%
add-sqr-sqrt28.5%
sqrt-unprod28.5%
sqr-neg28.5%
sqrt-unprod0.0%
add-sqr-sqrt37.1%
distribute-rgt-neg-in37.1%
*-commutative37.1%
distribute-rgt-neg-in37.1%
remove-double-neg37.1%
metadata-eval37.1%
Applied egg-rr37.1%
if 5.4999999999999998e179 < 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 49.2%
Taylor expanded in eps around 0 1.6%
associate--r+1.6%
cancel-sign-sub-inv1.6%
expm1-def1.6%
mul-1-neg1.6%
metadata-eval1.6%
*-lft-identity1.6%
Simplified1.6%
Taylor expanded in x around 0 22.2%
unpow222.2%
Applied egg-rr22.2%
Final simplification66.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (+ 1.0 (/ -1.0 eps_m)))
(t_1 (/ (+ (+ 1.0 (/ 1.0 eps_m)) t_0) 2.0)))
(if (<= x -1.0)
(/ (* x (* t_0 (- -1.0 eps_m))) 2.0)
(if (<= x 4e-10)
1.0
(if (<= x 4e+91)
t_1
(if (<= x 3.3e+155)
(* (* x eps_m) 0.5)
(if (<= x 5.2e+179) t_1 (* 0.25 (/ (* x x) eps_m)))))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = 1.0 + (-1.0 / eps_m);
double t_1 = ((1.0 + (1.0 / eps_m)) + t_0) / 2.0;
double tmp;
if (x <= -1.0) {
tmp = (x * (t_0 * (-1.0 - eps_m))) / 2.0;
} else if (x <= 4e-10) {
tmp = 1.0;
} else if (x <= 4e+91) {
tmp = t_1;
} else if (x <= 3.3e+155) {
tmp = (x * eps_m) * 0.5;
} else if (x <= 5.2e+179) {
tmp = t_1;
} else {
tmp = 0.25 * ((x * x) / eps_m);
}
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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 + ((-1.0d0) / eps_m)
t_1 = ((1.0d0 + (1.0d0 / eps_m)) + t_0) / 2.0d0
if (x <= (-1.0d0)) then
tmp = (x * (t_0 * ((-1.0d0) - eps_m))) / 2.0d0
else if (x <= 4d-10) then
tmp = 1.0d0
else if (x <= 4d+91) then
tmp = t_1
else if (x <= 3.3d+155) then
tmp = (x * eps_m) * 0.5d0
else if (x <= 5.2d+179) then
tmp = t_1
else
tmp = 0.25d0 * ((x * x) / eps_m)
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = 1.0 + (-1.0 / eps_m);
double t_1 = ((1.0 + (1.0 / eps_m)) + t_0) / 2.0;
double tmp;
if (x <= -1.0) {
tmp = (x * (t_0 * (-1.0 - eps_m))) / 2.0;
} else if (x <= 4e-10) {
tmp = 1.0;
} else if (x <= 4e+91) {
tmp = t_1;
} else if (x <= 3.3e+155) {
tmp = (x * eps_m) * 0.5;
} else if (x <= 5.2e+179) {
tmp = t_1;
} else {
tmp = 0.25 * ((x * x) / eps_m);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = 1.0 + (-1.0 / eps_m) t_1 = ((1.0 + (1.0 / eps_m)) + t_0) / 2.0 tmp = 0 if x <= -1.0: tmp = (x * (t_0 * (-1.0 - eps_m))) / 2.0 elif x <= 4e-10: tmp = 1.0 elif x <= 4e+91: tmp = t_1 elif x <= 3.3e+155: tmp = (x * eps_m) * 0.5 elif x <= 5.2e+179: tmp = t_1 else: tmp = 0.25 * ((x * x) / eps_m) return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(1.0 + Float64(-1.0 / eps_m)) t_1 = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + t_0) / 2.0) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(x * Float64(t_0 * Float64(-1.0 - eps_m))) / 2.0); elseif (x <= 4e-10) tmp = 1.0; elseif (x <= 4e+91) tmp = t_1; elseif (x <= 3.3e+155) tmp = Float64(Float64(x * eps_m) * 0.5); elseif (x <= 5.2e+179) tmp = t_1; else tmp = Float64(0.25 * Float64(Float64(x * x) / eps_m)); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = 1.0 + (-1.0 / eps_m); t_1 = ((1.0 + (1.0 / eps_m)) + t_0) / 2.0; tmp = 0.0; if (x <= -1.0) tmp = (x * (t_0 * (-1.0 - eps_m))) / 2.0; elseif (x <= 4e-10) tmp = 1.0; elseif (x <= 4e+91) tmp = t_1; elseif (x <= 3.3e+155) tmp = (x * eps_m) * 0.5; elseif (x <= 5.2e+179) tmp = t_1; else tmp = 0.25 * ((x * x) / eps_m); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(N[(x * N[(t$95$0 * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 4e-10], 1.0, If[LessEqual[x, 4e+91], t$95$1, If[LessEqual[x, 3.3e+155], N[(N[(x * eps$95$m), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 5.2e+179], t$95$1, N[(0.25 * N[(N[(x * x), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := 1 + \frac{-1}{eps\_m}\\
t_1 := \frac{\left(1 + \frac{1}{eps\_m}\right) + t\_0}{2}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x \cdot \left(t\_0 \cdot \left(-1 - eps\_m\right)\right)}{2}\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-10}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+155}:\\
\;\;\;\;\left(x \cdot eps\_m\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{+179}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{x \cdot x}{eps\_m}\\
\end{array}
\end{array}
if x < -1Initial program 97.3%
fma-neg97.3%
/-rgt-identity97.3%
fma-neg97.3%
/-rgt-identity97.3%
distribute-rgt-neg-in97.3%
sub-neg97.3%
metadata-eval97.3%
distribute-rgt-neg-in97.3%
Simplified97.3%
Taylor expanded in x around 0 73.8%
Taylor expanded in x around inf 49.5%
if -1 < x < 4.00000000000000015e-10Initial program 53.2%
fma-neg53.2%
/-rgt-identity53.2%
fma-neg53.2%
/-rgt-identity53.2%
distribute-rgt-neg-in53.2%
sub-neg53.2%
metadata-eval53.2%
distribute-rgt-neg-in53.2%
Simplified53.2%
Taylor expanded in x around 0 73.9%
if 4.00000000000000015e-10 < x < 4.00000000000000032e91 or 3.2999999999999999e155 < x < 5.2000000000000004e179Initial program 97.3%
fma-neg97.3%
/-rgt-identity97.3%
fma-neg97.3%
/-rgt-identity97.3%
distribute-rgt-neg-in97.3%
sub-neg97.3%
metadata-eval97.3%
distribute-rgt-neg-in97.3%
Simplified97.3%
Taylor expanded in x around 0 21.2%
Taylor expanded in x around 0 62.8%
if 4.00000000000000032e91 < x < 3.2999999999999999e155Initial 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 28.3%
Taylor expanded in eps around inf 28.5%
associate-*r*28.5%
mul-1-neg28.5%
Simplified28.5%
div-inv28.5%
add-sqr-sqrt28.5%
sqrt-unprod28.5%
sqr-neg28.5%
sqrt-unprod0.0%
add-sqr-sqrt37.1%
distribute-rgt-neg-in37.1%
*-commutative37.1%
distribute-rgt-neg-in37.1%
remove-double-neg37.1%
metadata-eval37.1%
Applied egg-rr37.1%
if 5.2000000000000004e179 < 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 49.2%
Taylor expanded in eps around 0 1.6%
associate--r+1.6%
cancel-sign-sub-inv1.6%
expm1-def1.6%
mul-1-neg1.6%
metadata-eval1.6%
*-lft-identity1.6%
Simplified1.6%
Taylor expanded in x around 0 22.2%
unpow222.2%
Applied egg-rr22.2%
Final simplification60.2%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (+ 1.0 (/ -1.0 eps_m))) (t_1 (/ (+ (/ 1.0 eps_m) t_0) 2.0)))
(if (<= x -1.0)
(/ (* x (* t_0 (- -1.0 eps_m))) 2.0)
(if (<= x 360.0)
1.0
(if (<= x 7e+92)
t_1
(if (<= x 3.7e+156)
(* (* x eps_m) 0.5)
(if (<= x 6e+179) t_1 (* 0.25 (/ (* x x) eps_m)))))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = 1.0 + (-1.0 / eps_m);
double t_1 = ((1.0 / eps_m) + t_0) / 2.0;
double tmp;
if (x <= -1.0) {
tmp = (x * (t_0 * (-1.0 - eps_m))) / 2.0;
} else if (x <= 360.0) {
tmp = 1.0;
} else if (x <= 7e+92) {
tmp = t_1;
} else if (x <= 3.7e+156) {
tmp = (x * eps_m) * 0.5;
} else if (x <= 6e+179) {
tmp = t_1;
} else {
tmp = 0.25 * ((x * x) / eps_m);
}
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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 + ((-1.0d0) / eps_m)
t_1 = ((1.0d0 / eps_m) + t_0) / 2.0d0
if (x <= (-1.0d0)) then
tmp = (x * (t_0 * ((-1.0d0) - eps_m))) / 2.0d0
else if (x <= 360.0d0) then
tmp = 1.0d0
else if (x <= 7d+92) then
tmp = t_1
else if (x <= 3.7d+156) then
tmp = (x * eps_m) * 0.5d0
else if (x <= 6d+179) then
tmp = t_1
else
tmp = 0.25d0 * ((x * x) / eps_m)
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = 1.0 + (-1.0 / eps_m);
double t_1 = ((1.0 / eps_m) + t_0) / 2.0;
double tmp;
if (x <= -1.0) {
tmp = (x * (t_0 * (-1.0 - eps_m))) / 2.0;
} else if (x <= 360.0) {
tmp = 1.0;
} else if (x <= 7e+92) {
tmp = t_1;
} else if (x <= 3.7e+156) {
tmp = (x * eps_m) * 0.5;
} else if (x <= 6e+179) {
tmp = t_1;
} else {
tmp = 0.25 * ((x * x) / eps_m);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = 1.0 + (-1.0 / eps_m) t_1 = ((1.0 / eps_m) + t_0) / 2.0 tmp = 0 if x <= -1.0: tmp = (x * (t_0 * (-1.0 - eps_m))) / 2.0 elif x <= 360.0: tmp = 1.0 elif x <= 7e+92: tmp = t_1 elif x <= 3.7e+156: tmp = (x * eps_m) * 0.5 elif x <= 6e+179: tmp = t_1 else: tmp = 0.25 * ((x * x) / eps_m) return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(1.0 + Float64(-1.0 / eps_m)) t_1 = Float64(Float64(Float64(1.0 / eps_m) + t_0) / 2.0) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(x * Float64(t_0 * Float64(-1.0 - eps_m))) / 2.0); elseif (x <= 360.0) tmp = 1.0; elseif (x <= 7e+92) tmp = t_1; elseif (x <= 3.7e+156) tmp = Float64(Float64(x * eps_m) * 0.5); elseif (x <= 6e+179) tmp = t_1; else tmp = Float64(0.25 * Float64(Float64(x * x) / eps_m)); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = 1.0 + (-1.0 / eps_m); t_1 = ((1.0 / eps_m) + t_0) / 2.0; tmp = 0.0; if (x <= -1.0) tmp = (x * (t_0 * (-1.0 - eps_m))) / 2.0; elseif (x <= 360.0) tmp = 1.0; elseif (x <= 7e+92) tmp = t_1; elseif (x <= 3.7e+156) tmp = (x * eps_m) * 0.5; elseif (x <= 6e+179) tmp = t_1; else tmp = 0.25 * ((x * x) / eps_m); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(1.0 / eps$95$m), $MachinePrecision] + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(N[(x * N[(t$95$0 * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 360.0], 1.0, If[LessEqual[x, 7e+92], t$95$1, If[LessEqual[x, 3.7e+156], N[(N[(x * eps$95$m), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 6e+179], t$95$1, N[(0.25 * N[(N[(x * x), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := 1 + \frac{-1}{eps\_m}\\
t_1 := \frac{\frac{1}{eps\_m} + t\_0}{2}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x \cdot \left(t\_0 \cdot \left(-1 - eps\_m\right)\right)}{2}\\
\mathbf{elif}\;x \leq 360:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+92}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{+156}:\\
\;\;\;\;\left(x \cdot eps\_m\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+179}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{x \cdot x}{eps\_m}\\
\end{array}
\end{array}
if x < -1Initial program 97.3%
fma-neg97.3%
/-rgt-identity97.3%
fma-neg97.3%
/-rgt-identity97.3%
distribute-rgt-neg-in97.3%
sub-neg97.3%
metadata-eval97.3%
distribute-rgt-neg-in97.3%
Simplified97.3%
Taylor expanded in x around 0 73.8%
Taylor expanded in x around inf 49.5%
if -1 < x < 360Initial program 54.5%
fma-neg54.4%
/-rgt-identity54.4%
fma-neg54.5%
/-rgt-identity54.5%
distribute-rgt-neg-in54.5%
sub-neg54.5%
metadata-eval54.5%
distribute-rgt-neg-in54.5%
Simplified54.5%
Taylor expanded in x around 0 72.0%
if 360 < x < 6.99999999999999972e92 or 3.70000000000000001e156 < x < 5.9999999999999996e179Initial program 96.8%
fma-neg96.8%
/-rgt-identity96.8%
fma-neg96.8%
/-rgt-identity96.8%
distribute-rgt-neg-in96.8%
sub-neg96.8%
metadata-eval96.8%
distribute-rgt-neg-in96.8%
Simplified96.8%
Taylor expanded in x around 0 15.6%
Taylor expanded in x around 0 73.6%
Taylor expanded in eps around 0 73.6%
if 6.99999999999999972e92 < x < 3.70000000000000001e156Initial 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 28.3%
Taylor expanded in eps around inf 28.5%
associate-*r*28.5%
mul-1-neg28.5%
Simplified28.5%
div-inv28.5%
add-sqr-sqrt28.5%
sqrt-unprod28.5%
sqr-neg28.5%
sqrt-unprod0.0%
add-sqr-sqrt37.1%
distribute-rgt-neg-in37.1%
*-commutative37.1%
distribute-rgt-neg-in37.1%
remove-double-neg37.1%
metadata-eval37.1%
Applied egg-rr37.1%
if 5.9999999999999996e179 < 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 49.2%
Taylor expanded in eps around 0 1.6%
associate--r+1.6%
cancel-sign-sub-inv1.6%
expm1-def1.6%
mul-1-neg1.6%
metadata-eval1.6%
*-lft-identity1.6%
Simplified1.6%
Taylor expanded in x around 0 22.2%
unpow222.2%
Applied egg-rr22.2%
Final simplification60.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -1.0) (/ (* x (* (+ 1.0 (/ -1.0 eps_m)) (- -1.0 eps_m))) 2.0) (if (<= x 4e-10) 1.0 (* (* x eps_m) 0.5))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.0) {
tmp = (x * ((1.0 + (-1.0 / eps_m)) * (-1.0 - eps_m))) / 2.0;
} else if (x <= 4e-10) {
tmp = 1.0;
} else {
tmp = (x * eps_m) * 0.5;
}
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.0d0)) then
tmp = (x * ((1.0d0 + ((-1.0d0) / eps_m)) * ((-1.0d0) - eps_m))) / 2.0d0
else if (x <= 4d-10) then
tmp = 1.0d0
else
tmp = (x * eps_m) * 0.5d0
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.0) {
tmp = (x * ((1.0 + (-1.0 / eps_m)) * (-1.0 - eps_m))) / 2.0;
} else if (x <= 4e-10) {
tmp = 1.0;
} else {
tmp = (x * eps_m) * 0.5;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1.0: tmp = (x * ((1.0 + (-1.0 / eps_m)) * (-1.0 - eps_m))) / 2.0 elif x <= 4e-10: tmp = 1.0 else: tmp = (x * eps_m) * 0.5 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(x * Float64(Float64(1.0 + Float64(-1.0 / eps_m)) * Float64(-1.0 - eps_m))) / 2.0); elseif (x <= 4e-10) tmp = 1.0; else tmp = Float64(Float64(x * eps_m) * 0.5); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -1.0) tmp = (x * ((1.0 + (-1.0 / eps_m)) * (-1.0 - eps_m))) / 2.0; elseif (x <= 4e-10) tmp = 1.0; else tmp = (x * eps_m) * 0.5; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.0], N[(N[(x * N[(N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 4e-10], 1.0, N[(N[(x * eps$95$m), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x \cdot \left(\left(1 + \frac{-1}{eps\_m}\right) \cdot \left(-1 - eps\_m\right)\right)}{2}\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-10}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot eps\_m\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -1Initial program 97.3%
fma-neg97.3%
/-rgt-identity97.3%
fma-neg97.3%
/-rgt-identity97.3%
distribute-rgt-neg-in97.3%
sub-neg97.3%
metadata-eval97.3%
distribute-rgt-neg-in97.3%
Simplified97.3%
Taylor expanded in x around 0 73.8%
Taylor expanded in x around inf 49.5%
if -1 < x < 4.00000000000000015e-10Initial program 53.2%
fma-neg53.2%
/-rgt-identity53.2%
fma-neg53.2%
/-rgt-identity53.2%
distribute-rgt-neg-in53.2%
sub-neg53.2%
metadata-eval53.2%
distribute-rgt-neg-in53.2%
Simplified53.2%
Taylor expanded in x around 0 73.9%
if 4.00000000000000015e-10 < x Initial program 99.1%
fma-neg99.1%
/-rgt-identity99.1%
fma-neg99.1%
/-rgt-identity99.1%
distribute-rgt-neg-in99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-rgt-neg-in99.1%
Simplified99.1%
Taylor expanded in x around 0 35.1%
Taylor expanded in eps around inf 27.8%
associate-*r*27.8%
mul-1-neg27.8%
Simplified27.8%
div-inv27.8%
add-sqr-sqrt27.8%
sqrt-unprod28.9%
sqr-neg28.9%
sqrt-unprod0.0%
add-sqr-sqrt15.6%
distribute-rgt-neg-in15.6%
*-commutative15.6%
distribute-rgt-neg-in15.6%
remove-double-neg15.6%
metadata-eval15.6%
Applied egg-rr15.6%
Final simplification53.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -1.0) (* (* x eps_m) -0.5) (if (<= x 4e-10) 1.0 (* (* x eps_m) 0.5))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.0) {
tmp = (x * eps_m) * -0.5;
} else if (x <= 4e-10) {
tmp = 1.0;
} else {
tmp = (x * eps_m) * 0.5;
}
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.0d0)) then
tmp = (x * eps_m) * (-0.5d0)
else if (x <= 4d-10) then
tmp = 1.0d0
else
tmp = (x * eps_m) * 0.5d0
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.0) {
tmp = (x * eps_m) * -0.5;
} else if (x <= 4e-10) {
tmp = 1.0;
} else {
tmp = (x * eps_m) * 0.5;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1.0: tmp = (x * eps_m) * -0.5 elif x <= 4e-10: tmp = 1.0 else: tmp = (x * eps_m) * 0.5 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(x * eps_m) * -0.5); elseif (x <= 4e-10) tmp = 1.0; else tmp = Float64(Float64(x * eps_m) * 0.5); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -1.0) tmp = (x * eps_m) * -0.5; elseif (x <= 4e-10) tmp = 1.0; else tmp = (x * eps_m) * 0.5; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.0], N[(N[(x * eps$95$m), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[x, 4e-10], 1.0, N[(N[(x * eps$95$m), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\left(x \cdot eps\_m\right) \cdot -0.5\\
\mathbf{elif}\;x \leq 4 \cdot 10^{-10}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot eps\_m\right) \cdot 0.5\\
\end{array}
\end{array}
if x < -1Initial program 97.3%
fma-neg97.3%
/-rgt-identity97.3%
fma-neg97.3%
/-rgt-identity97.3%
distribute-rgt-neg-in97.3%
sub-neg97.3%
metadata-eval97.3%
distribute-rgt-neg-in97.3%
Simplified97.3%
Taylor expanded in x around 0 73.8%
Taylor expanded in eps around inf 49.6%
associate-*r*49.6%
mul-1-neg49.6%
Simplified49.6%
frac-2neg49.6%
div-inv49.6%
*-commutative49.6%
distribute-rgt-neg-in49.6%
remove-double-neg49.6%
metadata-eval49.6%
metadata-eval49.6%
Applied egg-rr49.6%
if -1 < x < 4.00000000000000015e-10Initial program 53.2%
fma-neg53.2%
/-rgt-identity53.2%
fma-neg53.2%
/-rgt-identity53.2%
distribute-rgt-neg-in53.2%
sub-neg53.2%
metadata-eval53.2%
distribute-rgt-neg-in53.2%
Simplified53.2%
Taylor expanded in x around 0 73.9%
if 4.00000000000000015e-10 < x Initial program 99.1%
fma-neg99.1%
/-rgt-identity99.1%
fma-neg99.1%
/-rgt-identity99.1%
distribute-rgt-neg-in99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-rgt-neg-in99.1%
Simplified99.1%
Taylor expanded in x around 0 35.1%
Taylor expanded in eps around inf 27.8%
associate-*r*27.8%
mul-1-neg27.8%
Simplified27.8%
div-inv27.8%
add-sqr-sqrt27.8%
sqrt-unprod28.9%
sqr-neg28.9%
sqrt-unprod0.0%
add-sqr-sqrt15.6%
distribute-rgt-neg-in15.6%
*-commutative15.6%
distribute-rgt-neg-in15.6%
remove-double-neg15.6%
metadata-eval15.6%
Applied egg-rr15.6%
Final simplification53.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -1.0) (* (* x eps_m) -0.5) 1.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.0) {
tmp = (x * eps_m) * -0.5;
} else {
tmp = 1.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.0d0)) then
tmp = (x * eps_m) * (-0.5d0)
else
tmp = 1.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.0) {
tmp = (x * eps_m) * -0.5;
} else {
tmp = 1.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1.0: tmp = (x * eps_m) * -0.5 else: tmp = 1.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(x * eps_m) * -0.5); else tmp = 1.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -1.0) tmp = (x * eps_m) * -0.5; else tmp = 1.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.0], N[(N[(x * eps$95$m), $MachinePrecision] * -0.5), $MachinePrecision], 1.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\left(x \cdot eps\_m\right) \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1Initial program 97.3%
fma-neg97.3%
/-rgt-identity97.3%
fma-neg97.3%
/-rgt-identity97.3%
distribute-rgt-neg-in97.3%
sub-neg97.3%
metadata-eval97.3%
distribute-rgt-neg-in97.3%
Simplified97.3%
Taylor expanded in x around 0 73.8%
Taylor expanded in eps around inf 49.6%
associate-*r*49.6%
mul-1-neg49.6%
Simplified49.6%
frac-2neg49.6%
div-inv49.6%
*-commutative49.6%
distribute-rgt-neg-in49.6%
remove-double-neg49.6%
metadata-eval49.6%
metadata-eval49.6%
Applied egg-rr49.6%
if -1 < x Initial program 68.7%
fma-neg68.7%
/-rgt-identity68.7%
fma-neg68.7%
/-rgt-identity68.7%
distribute-rgt-neg-in68.7%
sub-neg68.7%
metadata-eval68.7%
distribute-rgt-neg-in68.7%
Simplified68.7%
Taylor expanded in x around 0 50.0%
Final simplification49.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 0.5)
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 0.5;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = 0.5d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 0.5;
}
eps_m = math.fabs(eps) def code(x, eps_m): return 0.5
eps_m = abs(eps) function code(x, eps_m) return 0.5 end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 0.5; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := 0.5
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
0.5
\end{array}
Initial program 72.8%
fma-neg72.8%
/-rgt-identity72.8%
fma-neg72.8%
/-rgt-identity72.8%
distribute-rgt-neg-in72.8%
sub-neg72.8%
metadata-eval72.8%
distribute-rgt-neg-in72.8%
Simplified72.8%
Taylor expanded in x around 0 42.0%
Taylor expanded in x around 0 28.6%
Taylor expanded in eps around 0 17.1%
Taylor expanded in eps around 0 9.7%
Final simplification9.7%
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 72.8%
fma-neg72.8%
/-rgt-identity72.8%
fma-neg72.8%
/-rgt-identity72.8%
distribute-rgt-neg-in72.8%
sub-neg72.8%
metadata-eval72.8%
distribute-rgt-neg-in72.8%
Simplified72.8%
Taylor expanded in x around 0 43.2%
Final simplification43.2%
herbie shell --seed 2024031
(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))