
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* (+ x 1.0) (exp (- x)))))
(if (<= eps_m 5e-19)
(/ (+ t_0 t_0) 2.0)
(/ (+ (exp (* x (+ -1.0 eps_m))) (exp (* x (- eps_m)))) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (x + 1.0) * exp(-x);
double tmp;
if (eps_m <= 5e-19) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps_m))) + exp((x * -eps_m))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = (x + 1.0d0) * exp(-x)
if (eps_m <= 5d-19) then
tmp = (t_0 + t_0) / 2.0d0
else
tmp = (exp((x * ((-1.0d0) + eps_m))) + exp((x * -eps_m))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = (x + 1.0) * Math.exp(-x);
double tmp;
if (eps_m <= 5e-19) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (Math.exp((x * (-1.0 + eps_m))) + Math.exp((x * -eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = (x + 1.0) * math.exp(-x) tmp = 0 if eps_m <= 5e-19: tmp = (t_0 + t_0) / 2.0 else: tmp = (math.exp((x * (-1.0 + eps_m))) + math.exp((x * -eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(x + 1.0) * exp(Float64(-x))) tmp = 0.0 if (eps_m <= 5e-19) tmp = Float64(Float64(t_0 + t_0) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) + exp(Float64(x * Float64(-eps_m)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = (x + 1.0) * exp(-x); tmp = 0.0; if (eps_m <= 5e-19) tmp = (t_0 + t_0) / 2.0; else tmp = (exp((x * (-1.0 + eps_m))) + exp((x * -eps_m))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps$95$m, 5e-19], N[(N[(t$95$0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], 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|
\\
\begin{array}{l}
t_0 := \left(x + 1\right) \cdot e^{-x}\\
\mathbf{if}\;eps_m \leq 5 \cdot 10^{-19}:\\
\;\;\;\;\frac{t_0 + t_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps_m\right)} + e^{x \cdot \left(-eps_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 5.0000000000000004e-19Initial program 60.6%
Simplified60.6%
Taylor expanded in eps around 0 74.7%
Simplified75.8%
if 5.0000000000000004e-19 < eps Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r*100.0%
sub-neg100.0%
mul-1-neg100.0%
associate-*r*100.0%
associate-*r*100.0%
neg-mul-1100.0%
mul-1-neg100.0%
sub-neg100.0%
mul-1-neg100.0%
associate-*r*100.0%
mul-1-neg100.0%
Simplified100.0%
Final simplification82.8%
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 72.0%
Simplified72.0%
Taylor expanded in eps around inf 98.6%
Final simplification98.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 3.1e+39)
(/ (+ (exp (* x eps_m)) (exp (* x (- eps_m)))) 2.0)
(if (or (<= x 5.5e+234) (not (<= x 3.7e+259)))
(/ (- (+ 1.0 (/ 1.0 eps_m)) (fabs (+ -1.0 (/ -1.0 eps_m)))) 2.0)
(/ (- (exp (* x (+ -1.0 eps_m))) -1.0) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 3.1e+39) {
tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0;
} else if ((x <= 5.5e+234) || !(x <= 3.7e+259)) {
tmp = ((1.0 + (1.0 / eps_m)) - fabs((-1.0 + (-1.0 / eps_m)))) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps_m))) - -1.0) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 3.1d+39) then
tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0d0
else if ((x <= 5.5d+234) .or. (.not. (x <= 3.7d+259))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) - abs(((-1.0d0) + ((-1.0d0) / eps_m)))) / 2.0d0
else
tmp = (exp((x * ((-1.0d0) + eps_m))) - (-1.0d0)) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 3.1e+39) {
tmp = (Math.exp((x * eps_m)) + Math.exp((x * -eps_m))) / 2.0;
} else if ((x <= 5.5e+234) || !(x <= 3.7e+259)) {
tmp = ((1.0 + (1.0 / eps_m)) - Math.abs((-1.0 + (-1.0 / eps_m)))) / 2.0;
} else {
tmp = (Math.exp((x * (-1.0 + eps_m))) - -1.0) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 3.1e+39: tmp = (math.exp((x * eps_m)) + math.exp((x * -eps_m))) / 2.0 elif (x <= 5.5e+234) or not (x <= 3.7e+259): tmp = ((1.0 + (1.0 / eps_m)) - math.fabs((-1.0 + (-1.0 / eps_m)))) / 2.0 else: tmp = (math.exp((x * (-1.0 + eps_m))) - -1.0) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 3.1e+39) tmp = Float64(Float64(exp(Float64(x * eps_m)) + exp(Float64(x * Float64(-eps_m)))) / 2.0); elseif ((x <= 5.5e+234) || !(x <= 3.7e+259)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) - abs(Float64(-1.0 + Float64(-1.0 / eps_m)))) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) - -1.0) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 3.1e+39) tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0; elseif ((x <= 5.5e+234) || ~((x <= 3.7e+259))) tmp = ((1.0 + (1.0 / eps_m)) - abs((-1.0 + (-1.0 / eps_m)))) / 2.0; else tmp = (exp((x * (-1.0 + eps_m))) - -1.0) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 3.1e+39], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 5.5e+234], N[Not[LessEqual[x, 3.7e+259]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] - N[Abs[N[(-1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.1 \cdot 10^{+39}:\\
\;\;\;\;\frac{e^{x \cdot eps_m} + e^{x \cdot \left(-eps_m\right)}}{2}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{+234} \lor \neg \left(x \leq 3.7 \cdot 10^{+259}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) - \left|-1 + \frac{-1}{eps_m}\right|}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps_m\right)} - -1}{2}\\
\end{array}
\end{array}
if x < 3.1000000000000003e39Initial program 61.6%
Simplified61.6%
Taylor expanded in eps around inf 98.1%
Taylor expanded in eps around inf 97.1%
*-commutative97.1%
Simplified97.1%
Taylor expanded in x around inf 97.1%
associate-*r*97.1%
sub-neg97.1%
mul-1-neg97.1%
associate-*r*97.1%
associate-*r*97.1%
neg-mul-197.1%
mul-1-neg97.1%
sub-neg97.1%
mul-1-neg97.1%
associate-*r*97.1%
mul-1-neg97.1%
Simplified97.1%
Taylor expanded in eps around inf 97.6%
*-commutative97.6%
Simplified97.6%
if 3.1000000000000003e39 < x < 5.5e234 or 3.70000000000000015e259 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 18.4%
Taylor expanded in x around 0 65.1%
sub-neg65.1%
add-sqr-sqrt12.2%
metadata-eval12.2%
sqrt-unprod18.4%
frac-times13.6%
metadata-eval13.6%
metadata-eval13.6%
frac-times18.4%
sqrt-unprod1.5%
add-sqr-sqrt2.5%
+-commutative2.5%
add-sqr-sqrt1.0%
sqrt-unprod21.1%
pow221.1%
Applied egg-rr21.1%
unpow221.1%
rem-sqrt-square29.3%
Simplified29.3%
if 5.5e234 < x < 3.70000000000000015e259Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 87.7%
*-commutative87.7%
Simplified87.7%
Taylor expanded in x around inf 87.7%
associate-*r*87.7%
sub-neg87.7%
mul-1-neg87.7%
associate-*r*87.7%
associate-*r*87.7%
neg-mul-187.7%
mul-1-neg87.7%
sub-neg87.7%
mul-1-neg87.7%
associate-*r*87.7%
mul-1-neg87.7%
Simplified87.7%
Taylor expanded in eps around 0 39.5%
Final simplification79.5%
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 72.0%
Simplified72.0%
Taylor expanded in eps around inf 98.6%
Taylor expanded in eps around inf 85.3%
*-commutative85.3%
Simplified85.3%
Taylor expanded in x around inf 85.3%
associate-*r*85.3%
sub-neg85.3%
mul-1-neg85.3%
associate-*r*85.3%
associate-*r*85.3%
neg-mul-185.3%
mul-1-neg85.3%
sub-neg85.3%
mul-1-neg85.3%
associate-*r*85.3%
mul-1-neg85.3%
Simplified85.3%
Final simplification85.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -5e-287)
(/ (+ 1.0 (exp (* x (- eps_m)))) 2.0)
(if (or (<= x 6.8e+40) (and (not (<= x 3.1e+234)) (<= x 7.2e+259)))
(/ (- (exp (* x (+ -1.0 eps_m))) -1.0) 2.0)
(/ (- (+ 1.0 (/ 1.0 eps_m)) (fabs (+ -1.0 (/ -1.0 eps_m)))) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -5e-287) {
tmp = (1.0 + exp((x * -eps_m))) / 2.0;
} else if ((x <= 6.8e+40) || (!(x <= 3.1e+234) && (x <= 7.2e+259))) {
tmp = (exp((x * (-1.0 + eps_m))) - -1.0) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps_m)) - fabs((-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-287)) then
tmp = (1.0d0 + exp((x * -eps_m))) / 2.0d0
else if ((x <= 6.8d+40) .or. (.not. (x <= 3.1d+234)) .and. (x <= 7.2d+259)) then
tmp = (exp((x * ((-1.0d0) + eps_m))) - (-1.0d0)) / 2.0d0
else
tmp = ((1.0d0 + (1.0d0 / eps_m)) - abs(((-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-287) {
tmp = (1.0 + Math.exp((x * -eps_m))) / 2.0;
} else if ((x <= 6.8e+40) || (!(x <= 3.1e+234) && (x <= 7.2e+259))) {
tmp = (Math.exp((x * (-1.0 + eps_m))) - -1.0) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps_m)) - Math.abs((-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-287: tmp = (1.0 + math.exp((x * -eps_m))) / 2.0 elif (x <= 6.8e+40) or (not (x <= 3.1e+234) and (x <= 7.2e+259)): tmp = (math.exp((x * (-1.0 + eps_m))) - -1.0) / 2.0 else: tmp = ((1.0 + (1.0 / eps_m)) - math.fabs((-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-287) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps_m)))) / 2.0); elseif ((x <= 6.8e+40) || (!(x <= 3.1e+234) && (x <= 7.2e+259))) tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) - -1.0) / 2.0); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) - abs(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-287) tmp = (1.0 + exp((x * -eps_m))) / 2.0; elseif ((x <= 6.8e+40) || (~((x <= 3.1e+234)) && (x <= 7.2e+259))) tmp = (exp((x * (-1.0 + eps_m))) - -1.0) / 2.0; else tmp = ((1.0 + (1.0 / eps_m)) - abs((-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-287], N[(N[(1.0 + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 6.8e+40], And[N[Not[LessEqual[x, 3.1e+234]], $MachinePrecision], LessEqual[x, 7.2e+259]]], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] - N[Abs[N[(-1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-287}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-eps_m\right)}}{2}\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+40} \lor \neg \left(x \leq 3.1 \cdot 10^{+234}\right) \land x \leq 7.2 \cdot 10^{+259}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps_m\right)} - -1}{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.00000000000000025e-287Initial program 60.7%
Simplified60.7%
Taylor expanded in x around 0 44.8%
Taylor expanded in eps around inf 81.8%
Taylor expanded in eps around inf 82.4%
*-commutative97.7%
Simplified82.4%
if -5.00000000000000025e-287 < x < 6.79999999999999977e40 or 3.0999999999999999e234 < x < 7.2000000000000006e259Initial program 66.6%
Simplified66.6%
Taylor expanded in eps around inf 99.0%
Taylor expanded in eps around inf 95.5%
*-commutative95.5%
Simplified95.5%
Taylor expanded in x around inf 95.5%
associate-*r*95.5%
sub-neg95.5%
mul-1-neg95.5%
associate-*r*95.5%
associate-*r*95.5%
neg-mul-195.5%
mul-1-neg95.5%
sub-neg95.5%
mul-1-neg95.5%
associate-*r*95.5%
mul-1-neg95.5%
Simplified95.5%
Taylor expanded in eps around 0 74.8%
if 6.79999999999999977e40 < x < 3.0999999999999999e234 or 7.2000000000000006e259 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 18.4%
Taylor expanded in x around 0 65.1%
sub-neg65.1%
add-sqr-sqrt12.2%
metadata-eval12.2%
sqrt-unprod18.4%
frac-times13.6%
metadata-eval13.6%
metadata-eval13.6%
frac-times18.4%
sqrt-unprod1.5%
add-sqr-sqrt2.5%
+-commutative2.5%
add-sqr-sqrt1.0%
sqrt-unprod21.1%
pow221.1%
Applied egg-rr21.1%
unpow221.1%
rem-sqrt-square29.3%
Simplified29.3%
Final simplification67.2%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -5e-288)
(/ (+ 1.0 (exp (* x (- eps_m)))) 2.0)
(if (or (<= x 1.1e+47) (and (not (<= x 3.6e+234)) (<= x 4e+259)))
(/ (- (exp (* x (+ -1.0 eps_m))) -1.0) 2.0)
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (- (/ -1.0 eps_m) -1.0)) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -5e-288) {
tmp = (1.0 + exp((x * -eps_m))) / 2.0;
} else if ((x <= 1.1e+47) || (!(x <= 3.6e+234) && (x <= 4e+259))) {
tmp = (exp((x * (-1.0 + eps_m))) - -1.0) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-5d-288)) then
tmp = (1.0d0 + exp((x * -eps_m))) / 2.0d0
else if ((x <= 1.1d+47) .or. (.not. (x <= 3.6d+234)) .and. (x <= 4d+259)) then
tmp = (exp((x * ((-1.0d0) + eps_m))) - (-1.0d0)) / 2.0d0
else
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (((-1.0d0) / eps_m) - (-1.0d0))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -5e-288) {
tmp = (1.0 + Math.exp((x * -eps_m))) / 2.0;
} else if ((x <= 1.1e+47) || (!(x <= 3.6e+234) && (x <= 4e+259))) {
tmp = (Math.exp((x * (-1.0 + eps_m))) - -1.0) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -5e-288: tmp = (1.0 + math.exp((x * -eps_m))) / 2.0 elif (x <= 1.1e+47) or (not (x <= 3.6e+234) and (x <= 4e+259)): tmp = (math.exp((x * (-1.0 + eps_m))) - -1.0) / 2.0 else: tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -5e-288) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps_m)))) / 2.0); elseif ((x <= 1.1e+47) || (!(x <= 3.6e+234) && (x <= 4e+259))) tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) - -1.0) / 2.0); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(Float64(-1.0 / eps_m) - -1.0)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -5e-288) tmp = (1.0 + exp((x * -eps_m))) / 2.0; elseif ((x <= 1.1e+47) || (~((x <= 3.6e+234)) && (x <= 4e+259))) tmp = (exp((x * (-1.0 + eps_m))) - -1.0) / 2.0; else tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -5e-288], N[(N[(1.0 + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 1.1e+47], And[N[Not[LessEqual[x, 3.6e+234]], $MachinePrecision], LessEqual[x, 4e+259]]], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-288}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-eps_m\right)}}{2}\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+47} \lor \neg \left(x \leq 3.6 \cdot 10^{+234}\right) \land x \leq 4 \cdot 10^{+259}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps_m\right)} - -1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\end{array}
\end{array}
if x < -5.00000000000000011e-288Initial program 60.7%
Simplified60.7%
Taylor expanded in x around 0 44.8%
Taylor expanded in eps around inf 81.8%
Taylor expanded in eps around inf 82.4%
*-commutative97.7%
Simplified82.4%
if -5.00000000000000011e-288 < x < 1.1e47 or 3.59999999999999999e234 < x < 4e259Initial program 66.9%
Simplified66.9%
Taylor expanded in eps around inf 99.0%
Taylor expanded in eps around inf 94.4%
*-commutative94.4%
Simplified94.4%
Taylor expanded in x around inf 94.4%
associate-*r*94.4%
sub-neg94.4%
mul-1-neg94.4%
associate-*r*94.4%
associate-*r*94.4%
neg-mul-194.4%
mul-1-neg94.4%
sub-neg94.4%
mul-1-neg94.4%
associate-*r*94.4%
mul-1-neg94.4%
Simplified94.4%
Taylor expanded in eps around 0 74.0%
if 1.1e47 < x < 3.59999999999999999e234 or 4e259 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 18.7%
Taylor expanded in x around 0 66.1%
Final simplification75.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 360.0)
(/ (+ 1.0 (exp (* x (- eps_m)))) 2.0)
(if (or (<= x 3.3e+234) (not (<= x 3.7e+259)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (- (/ -1.0 eps_m) -1.0)) 2.0)
(/ (* x eps_m) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 360.0) {
tmp = (1.0 + exp((x * -eps_m))) / 2.0;
} else if ((x <= 3.3e+234) || !(x <= 3.7e+259)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 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 <= 360.0d0) then
tmp = (1.0d0 + exp((x * -eps_m))) / 2.0d0
else if ((x <= 3.3d+234) .or. (.not. (x <= 3.7d+259))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (((-1.0d0) / eps_m) - (-1.0d0))) / 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 <= 360.0) {
tmp = (1.0 + Math.exp((x * -eps_m))) / 2.0;
} else if ((x <= 3.3e+234) || !(x <= 3.7e+259)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 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 <= 360.0: tmp = (1.0 + math.exp((x * -eps_m))) / 2.0 elif (x <= 3.3e+234) or not (x <= 3.7e+259): tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 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 <= 360.0) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps_m)))) / 2.0); elseif ((x <= 3.3e+234) || !(x <= 3.7e+259)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(Float64(-1.0 / eps_m) - -1.0)) / 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 <= 360.0) tmp = (1.0 + exp((x * -eps_m))) / 2.0; elseif ((x <= 3.3e+234) || ~((x <= 3.7e+259))) tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 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, 360.0], N[(N[(1.0 + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 3.3e+234], N[Not[LessEqual[x, 3.7e+259]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $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 360:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-eps_m\right)}}{2}\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+234} \lor \neg \left(x \leq 3.7 \cdot 10^{+259}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps_m}{2}\\
\end{array}
\end{array}
if x < 360Initial program 60.1%
Simplified60.1%
Taylor expanded in x around 0 43.9%
Taylor expanded in eps around inf 81.9%
Taylor expanded in eps around inf 82.4%
*-commutative98.1%
Simplified82.4%
if 360 < x < 3.3000000000000003e234 or 3.70000000000000015e259 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 24.0%
Taylor expanded in x around 0 61.5%
if 3.3000000000000003e234 < x < 3.70000000000000015e259Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 37.7%
Taylor expanded in x around inf 37.7%
mul-1-neg37.7%
associate-*r*37.7%
*-commutative37.7%
distribute-rgt-neg-in37.7%
distribute-rgt-neg-in37.7%
distribute-neg-in37.7%
metadata-eval37.7%
distribute-neg-frac37.7%
metadata-eval37.7%
Simplified37.7%
Taylor expanded in eps around inf 37.9%
Final simplification75.4%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 360.0)
(/ (+ 1.0 (exp (- x))) 2.0)
(if (or (<= x 3.8e+234) (not (<= x 9.8e+259)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (- (/ -1.0 eps_m) -1.0)) 2.0)
(/ (* x eps_m) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 360.0) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if ((x <= 3.8e+234) || !(x <= 9.8e+259)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 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 <= 360.0d0) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else if ((x <= 3.8d+234) .or. (.not. (x <= 9.8d+259))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (((-1.0d0) / eps_m) - (-1.0d0))) / 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 <= 360.0) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if ((x <= 3.8e+234) || !(x <= 9.8e+259)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 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 <= 360.0: tmp = (1.0 + math.exp(-x)) / 2.0 elif (x <= 3.8e+234) or not (x <= 9.8e+259): tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 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 <= 360.0) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif ((x <= 3.8e+234) || !(x <= 9.8e+259)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(Float64(-1.0 / eps_m) - -1.0)) / 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 <= 360.0) tmp = (1.0 + exp(-x)) / 2.0; elseif ((x <= 3.8e+234) || ~((x <= 9.8e+259))) tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 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, 360.0], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 3.8e+234], N[Not[LessEqual[x, 9.8e+259]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $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 360:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+234} \lor \neg \left(x \leq 9.8 \cdot 10^{+259}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps_m}{2}\\
\end{array}
\end{array}
if x < 360Initial program 60.1%
Simplified60.1%
Taylor expanded in eps around inf 98.1%
Taylor expanded in eps around inf 98.1%
*-commutative98.1%
Simplified98.1%
Taylor expanded in eps around 0 75.7%
neg-mul-175.7%
Simplified75.7%
if 360 < x < 3.8e234 or 9.79999999999999958e259 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 24.0%
Taylor expanded in x around 0 61.5%
if 3.8e234 < x < 9.79999999999999958e259Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 37.7%
Taylor expanded in x around inf 37.7%
mul-1-neg37.7%
associate-*r*37.7%
*-commutative37.7%
distribute-rgt-neg-in37.7%
distribute-rgt-neg-in37.7%
distribute-neg-in37.7%
metadata-eval37.7%
distribute-neg-frac37.7%
metadata-eval37.7%
Simplified37.7%
Taylor expanded in eps around inf 37.9%
Final simplification70.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 165.0)
(/ (- 2.0 (* x eps_m)) 2.0)
(if (or (<= x 6.5e+234) (not (<= x 1.1e+260)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (- (/ -1.0 eps_m) -1.0)) 2.0)
(/ (* x eps_m) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 165.0) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else if ((x <= 6.5e+234) || !(x <= 1.1e+260)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 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 <= 165.0d0) then
tmp = (2.0d0 - (x * eps_m)) / 2.0d0
else if ((x <= 6.5d+234) .or. (.not. (x <= 1.1d+260))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (((-1.0d0) / eps_m) - (-1.0d0))) / 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 <= 165.0) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else if ((x <= 6.5e+234) || !(x <= 1.1e+260)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 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 <= 165.0: tmp = (2.0 - (x * eps_m)) / 2.0 elif (x <= 6.5e+234) or not (x <= 1.1e+260): tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 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 <= 165.0) tmp = Float64(Float64(2.0 - Float64(x * eps_m)) / 2.0); elseif ((x <= 6.5e+234) || !(x <= 1.1e+260)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(Float64(-1.0 / eps_m) - -1.0)) / 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 <= 165.0) tmp = (2.0 - (x * eps_m)) / 2.0; elseif ((x <= 6.5e+234) || ~((x <= 1.1e+260))) tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 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, 165.0], N[(N[(2.0 - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 6.5e+234], N[Not[LessEqual[x, 1.1e+260]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $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 165:\\
\;\;\;\;\frac{2 - x \cdot eps_m}{2}\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+234} \lor \neg \left(x \leq 1.1 \cdot 10^{+260}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps_m}{2}\\
\end{array}
\end{array}
if x < 165Initial program 60.1%
Simplified60.1%
Taylor expanded in x around 0 43.9%
Taylor expanded in x around 0 50.3%
Taylor expanded in eps around inf 66.7%
associate-*r*66.7%
mul-1-neg66.7%
Simplified66.7%
if 165 < x < 6.4999999999999995e234 or 1.10000000000000006e260 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 24.0%
Taylor expanded in x around 0 61.5%
if 6.4999999999999995e234 < x < 1.10000000000000006e260Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 37.7%
Taylor expanded in x around inf 37.7%
mul-1-neg37.7%
associate-*r*37.7%
*-commutative37.7%
distribute-rgt-neg-in37.7%
distribute-rgt-neg-in37.7%
distribute-neg-in37.7%
metadata-eval37.7%
distribute-neg-frac37.7%
metadata-eval37.7%
Simplified37.7%
Taylor expanded in eps around inf 37.9%
Final simplification64.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 21.0) (/ (- 2.0 (* x eps_m)) 2.0) (/ (* x eps_m) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 21.0) {
tmp = (2.0 - (x * 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 <= 21.0d0) then
tmp = (2.0d0 - (x * 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 <= 21.0) {
tmp = (2.0 - (x * 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 <= 21.0: tmp = (2.0 - (x * 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 <= 21.0) tmp = Float64(Float64(2.0 - Float64(x * 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 <= 21.0) tmp = (2.0 - (x * 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, 21.0], N[(N[(2.0 - N[(x * eps$95$m), $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 21:\\
\;\;\;\;\frac{2 - x \cdot eps_m}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps_m}{2}\\
\end{array}
\end{array}
if x < 21Initial program 60.1%
Simplified60.1%
Taylor expanded in x around 0 43.9%
Taylor expanded in x around 0 50.3%
Taylor expanded in eps around inf 66.7%
associate-*r*66.7%
mul-1-neg66.7%
Simplified66.7%
if 21 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 25.0%
Taylor expanded in x around inf 11.9%
mul-1-neg11.9%
associate-*r*11.9%
*-commutative11.9%
distribute-rgt-neg-in11.9%
distribute-rgt-neg-in11.9%
distribute-neg-in11.9%
metadata-eval11.9%
distribute-neg-frac11.9%
metadata-eval11.9%
Simplified11.9%
Taylor expanded in eps around inf 12.7%
Final simplification50.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 42.0) 1.0 (/ (* x eps_m) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 42.0) {
tmp = 1.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 42.0d0) then
tmp = 1.0d0
else
tmp = (x * eps_m) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 42.0) {
tmp = 1.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 42.0: tmp = 1.0 else: tmp = (x * eps_m) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 42.0) tmp = 1.0; else tmp = Float64(Float64(x * eps_m) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 42.0) tmp = 1.0; else tmp = (x * eps_m) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 42.0], 1.0, N[(N[(x * eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 42:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps_m}{2}\\
\end{array}
\end{array}
if x < 42Initial program 60.1%
Simplified60.1%
Taylor expanded in x around 0 63.3%
if 42 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 25.0%
Taylor expanded in x around inf 11.9%
mul-1-neg11.9%
associate-*r*11.9%
*-commutative11.9%
distribute-rgt-neg-in11.9%
distribute-rgt-neg-in11.9%
distribute-neg-in11.9%
metadata-eval11.9%
distribute-neg-frac11.9%
metadata-eval11.9%
Simplified11.9%
Taylor expanded in eps around inf 12.7%
Final simplification48.3%
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.0%
Simplified72.0%
Taylor expanded in x around 0 45.4%
Final simplification45.4%
herbie shell --seed 2023322
(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))