
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 1.0) (/ (/ (* eps_m (* 2.0 (* (+ x 1.0) (exp (- x))))) eps_m) 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 tmp;
if (eps_m <= 1.0) {
tmp = ((eps_m * (2.0 * ((x + 1.0) * exp(-x)))) / eps_m) / 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) :: tmp
if (eps_m <= 1.0d0) then
tmp = ((eps_m * (2.0d0 * ((x + 1.0d0) * exp(-x)))) / eps_m) / 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 tmp;
if (eps_m <= 1.0) {
tmp = ((eps_m * (2.0 * ((x + 1.0) * Math.exp(-x)))) / eps_m) / 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): tmp = 0 if eps_m <= 1.0: tmp = ((eps_m * (2.0 * ((x + 1.0) * math.exp(-x)))) / eps_m) / 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) tmp = 0.0 if (eps_m <= 1.0) tmp = Float64(Float64(Float64(eps_m * Float64(2.0 * Float64(Float64(x + 1.0) * exp(Float64(-x))))) / eps_m) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 - eps_m))) + exp(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 (eps_m <= 1.0) tmp = ((eps_m * (2.0 * ((x + 1.0) * exp(-x)))) / eps_m) / 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_] := If[LessEqual[eps$95$m, 1.0], N[(N[(N[(eps$95$m * N[(2.0 * N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $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}
\mathbf{if}\;eps\_m \leq 1:\\
\;\;\;\;\frac{\frac{eps\_m \cdot \left(2 \cdot \left(\left(x + 1\right) \cdot e^{-x}\right)\right)}{eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 - eps\_m\right)} + e^{x \cdot eps\_m}}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 63.0%
Simplified54.8%
Taylor expanded in eps around 0 33.4%
associate-+r+69.8%
mul-1-neg69.8%
sub-neg69.8%
+-inverses69.8%
distribute-lft-out69.8%
distribute-rgt1-in70.4%
mul-1-neg70.4%
Simplified70.4%
if 1 < eps Initial program 99.8%
Simplified90.7%
Taylor expanded in eps around inf 99.8%
Taylor expanded in x around -inf 99.8%
rec-exp99.8%
sub-neg99.8%
neg-mul-199.8%
remove-double-neg99.8%
*-commutative99.8%
distribute-neg-in99.8%
distribute-lft-neg-in99.8%
neg-mul-199.8%
*-rgt-identity99.8%
distribute-lft-neg-in99.8%
neg-mul-199.8%
distribute-lft-in99.8%
+-commutative99.8%
associate-*r*99.8%
mul-1-neg99.8%
distribute-rgt-neg-in99.8%
distribute-neg-in99.8%
metadata-eval99.8%
unsub-neg99.8%
Simplified99.8%
Taylor expanded in eps around inf 99.8%
*-commutative99.8%
Simplified99.8%
Final simplification79.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ (exp (* x (+ eps_m -1.0))) (expm1 (log1p (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))) + expm1(log1p(exp((x * (-1.0 - eps_m)))))) / 2.0;
}
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (Math.exp((x * (eps_m + -1.0))) + Math.expm1(Math.log1p(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.expm1(math.log1p(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))) + expm1(log1p(exp(Float64(x * Float64(-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[Log[1 + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{e^{x \cdot \left(eps\_m + -1\right)} + \mathsf{expm1}\left(\mathsf{log1p}\left(e^{x \cdot \left(-1 - eps\_m\right)}\right)\right)}{2}
\end{array}
Initial program 74.4%
Simplified68.9%
Taylor expanded in eps around inf 98.8%
expm1-log1p-u98.8%
expm1-undefine98.8%
rec-exp98.8%
+-commutative98.8%
*-commutative98.8%
fma-define98.8%
Applied egg-rr98.8%
expm1-define98.8%
remove-double-neg98.8%
neg-mul-198.8%
fmm-def98.8%
*-commutative98.8%
sub-neg98.8%
neg-mul-198.8%
remove-double-neg98.8%
*-commutative98.8%
distribute-neg-in98.8%
distribute-lft-neg-in98.8%
neg-mul-198.8%
*-rgt-identity98.8%
distribute-lft-neg-in98.8%
neg-mul-198.8%
distribute-lft-in98.8%
+-commutative98.8%
associate-*r*98.8%
mul-1-neg98.8%
distribute-rgt-neg-in98.8%
distribute-neg-in98.8%
metadata-eval98.8%
unsub-neg98.8%
Simplified98.8%
Final simplification98.8%
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 74.4%
Simplified68.9%
Taylor expanded in eps around inf 98.8%
Taylor expanded in x around -inf 98.8%
rec-exp98.8%
sub-neg98.8%
neg-mul-198.8%
remove-double-neg98.8%
*-commutative98.8%
distribute-neg-in98.8%
distribute-lft-neg-in98.8%
neg-mul-198.8%
*-rgt-identity98.8%
distribute-lft-neg-in98.8%
neg-mul-198.8%
distribute-lft-in98.8%
+-commutative98.8%
associate-*r*98.8%
mul-1-neg98.8%
distribute-rgt-neg-in98.8%
distribute-neg-in98.8%
metadata-eval98.8%
unsub-neg98.8%
Simplified98.8%
Final simplification98.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 1.0)
(/ (/ (* eps_m (* 2.0 (* (+ x 1.0) (exp (- x))))) eps_m) 2.0)
(if (<= eps_m 8.4e+133)
(/ (+ (exp (* x (+ eps_m -1.0))) (+ 1.0 (* x (- -1.0 eps_m)))) 2.0)
(/
(*
x
(+ -1.0 (+ eps_m (+ (/ 1.0 x) (/ 1.0 (* x (exp (+ x (* x eps_m)))))))))
2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.0) {
tmp = ((eps_m * (2.0 * ((x + 1.0) * exp(-x)))) / eps_m) / 2.0;
} else if (eps_m <= 8.4e+133) {
tmp = (exp((x * (eps_m + -1.0))) + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
} else {
tmp = (x * (-1.0 + (eps_m + ((1.0 / x) + (1.0 / (x * exp((x + (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 <= 1.0d0) then
tmp = ((eps_m * (2.0d0 * ((x + 1.0d0) * exp(-x)))) / eps_m) / 2.0d0
else if (eps_m <= 8.4d+133) then
tmp = (exp((x * (eps_m + (-1.0d0)))) + (1.0d0 + (x * ((-1.0d0) - eps_m)))) / 2.0d0
else
tmp = (x * ((-1.0d0) + (eps_m + ((1.0d0 / x) + (1.0d0 / (x * exp((x + (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 <= 1.0) {
tmp = ((eps_m * (2.0 * ((x + 1.0) * Math.exp(-x)))) / eps_m) / 2.0;
} else if (eps_m <= 8.4e+133) {
tmp = (Math.exp((x * (eps_m + -1.0))) + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
} else {
tmp = (x * (-1.0 + (eps_m + ((1.0 / x) + (1.0 / (x * Math.exp((x + (x * eps_m))))))))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.0: tmp = ((eps_m * (2.0 * ((x + 1.0) * math.exp(-x)))) / eps_m) / 2.0 elif eps_m <= 8.4e+133: tmp = (math.exp((x * (eps_m + -1.0))) + (1.0 + (x * (-1.0 - eps_m)))) / 2.0 else: tmp = (x * (-1.0 + (eps_m + ((1.0 / x) + (1.0 / (x * math.exp((x + (x * eps_m))))))))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.0) tmp = Float64(Float64(Float64(eps_m * Float64(2.0 * Float64(Float64(x + 1.0) * exp(Float64(-x))))) / eps_m) / 2.0); elseif (eps_m <= 8.4e+133) tmp = Float64(Float64(exp(Float64(x * Float64(eps_m + -1.0))) + Float64(1.0 + Float64(x * Float64(-1.0 - eps_m)))) / 2.0); else tmp = Float64(Float64(x * Float64(-1.0 + Float64(eps_m + Float64(Float64(1.0 / x) + Float64(1.0 / Float64(x * exp(Float64(x + 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 (eps_m <= 1.0) tmp = ((eps_m * (2.0 * ((x + 1.0) * exp(-x)))) / eps_m) / 2.0; elseif (eps_m <= 8.4e+133) tmp = (exp((x * (eps_m + -1.0))) + (1.0 + (x * (-1.0 - eps_m)))) / 2.0; else tmp = (x * (-1.0 + (eps_m + ((1.0 / x) + (1.0 / (x * exp((x + (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, 1.0], N[(N[(N[(eps$95$m * N[(2.0 * N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps$95$m, 8.4e+133], N[(N[(N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(1.0 + N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * N[(-1.0 + N[(eps$95$m + N[(N[(1.0 / x), $MachinePrecision] + N[(1.0 / N[(x * N[Exp[N[(x + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1:\\
\;\;\;\;\frac{\frac{eps\_m \cdot \left(2 \cdot \left(\left(x + 1\right) \cdot e^{-x}\right)\right)}{eps\_m}}{2}\\
\mathbf{elif}\;eps\_m \leq 8.4 \cdot 10^{+133}:\\
\;\;\;\;\frac{e^{x \cdot \left(eps\_m + -1\right)} + \left(1 + x \cdot \left(-1 - eps\_m\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(-1 + \left(eps\_m + \left(\frac{1}{x} + \frac{1}{x \cdot e^{x + x \cdot eps\_m}}\right)\right)\right)}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 63.0%
Simplified54.8%
Taylor expanded in eps around 0 33.4%
associate-+r+69.8%
mul-1-neg69.8%
sub-neg69.8%
+-inverses69.8%
distribute-lft-out69.8%
distribute-rgt1-in70.4%
mul-1-neg70.4%
Simplified70.4%
if 1 < eps < 8.4e133Initial program 99.6%
Simplified96.5%
Taylor expanded in eps around inf 99.6%
Taylor expanded in x around 0 78.2%
associate-*r*78.2%
neg-mul-178.2%
Simplified78.2%
if 8.4e133 < eps Initial program 100.0%
Simplified86.9%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 59.8%
Taylor expanded in x around inf 78.6%
Final simplification72.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -7.2e-226) (/ (+ (- 1.0 x) (/ 1.0 (exp (+ x (* x eps_m))))) 2.0) (/ (+ 1.0 (exp (* x (+ eps_m -1.0)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -7.2e-226) {
tmp = ((1.0 - x) + (1.0 / exp((x + (x * eps_m))))) / 2.0;
} else {
tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-7.2d-226)) then
tmp = ((1.0d0 - x) + (1.0d0 / exp((x + (x * eps_m))))) / 2.0d0
else
tmp = (1.0d0 + exp((x * (eps_m + (-1.0d0))))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -7.2e-226) {
tmp = ((1.0 - x) + (1.0 / Math.exp((x + (x * eps_m))))) / 2.0;
} else {
tmp = (1.0 + Math.exp((x * (eps_m + -1.0)))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -7.2e-226: tmp = ((1.0 - x) + (1.0 / math.exp((x + (x * eps_m))))) / 2.0 else: tmp = (1.0 + math.exp((x * (eps_m + -1.0)))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -7.2e-226) tmp = Float64(Float64(Float64(1.0 - x) + Float64(1.0 / exp(Float64(x + Float64(x * eps_m))))) / 2.0); else tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps_m + -1.0)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -7.2e-226) tmp = ((1.0 - x) + (1.0 / exp((x + (x * eps_m))))) / 2.0; else tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -7.2e-226], N[(N[(N[(1.0 - x), $MachinePrecision] + N[(1.0 / N[Exp[N[(x + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{-226}:\\
\;\;\;\;\frac{\left(1 - x\right) + \frac{1}{e^{x + x \cdot eps\_m}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(eps\_m + -1\right)}}{2}\\
\end{array}
\end{array}
if x < -7.19999999999999988e-226Initial program 74.0%
Simplified66.2%
Taylor expanded in eps around inf 96.2%
Taylor expanded in x around 0 60.4%
Taylor expanded in eps around 0 71.9%
neg-mul-171.9%
Simplified71.9%
if -7.19999999999999988e-226 < x Initial program 74.5%
Simplified70.2%
Taylor expanded in eps around inf 99.9%
Taylor expanded in x around 0 59.0%
Final simplification63.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 5e-293) (/ (+ 1.0 (exp (- x))) 2.0) (/ (+ 1.0 (exp (* x (+ eps_m -1.0)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 5e-293) {
tmp = (1.0 + exp(-x)) / 2.0;
} else {
tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 5d-293) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else
tmp = (1.0d0 + exp((x * (eps_m + (-1.0d0))))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 5e-293) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else {
tmp = (1.0 + Math.exp((x * (eps_m + -1.0)))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 5e-293: tmp = (1.0 + math.exp(-x)) / 2.0 else: tmp = (1.0 + math.exp((x * (eps_m + -1.0)))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 5e-293) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); else tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps_m + -1.0)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 5e-293) tmp = (1.0 + exp(-x)) / 2.0; else tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 5e-293], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-293}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(eps\_m + -1\right)}}{2}\\
\end{array}
\end{array}
if x < 5.0000000000000003e-293Initial program 67.6%
Simplified61.0%
Taylor expanded in eps around inf 97.0%
Taylor expanded in x around 0 68.2%
Taylor expanded in eps around 0 78.1%
neg-mul-177.5%
Simplified78.1%
if 5.0000000000000003e-293 < x Initial program 79.0%
Simplified74.3%
Taylor expanded in eps around inf 99.9%
Taylor expanded in x around 0 53.3%
Final simplification63.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 5e-291) (/ (+ 1.0 (exp (- x))) 2.0) (/ (+ 1.0 (exp (* x eps_m))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 5e-291) {
tmp = (1.0 + exp(-x)) / 2.0;
} else {
tmp = (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 (x <= 5d-291) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else
tmp = (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 (x <= 5e-291) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else {
tmp = (1.0 + Math.exp((x * eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 5e-291: tmp = (1.0 + math.exp(-x)) / 2.0 else: tmp = (1.0 + math.exp((x * eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 5e-291) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); else tmp = Float64(Float64(1.0 + exp(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 <= 5e-291) tmp = (1.0 + exp(-x)) / 2.0; else tmp = (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[x, 5e-291], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 + 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}\;x \leq 5 \cdot 10^{-291}:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot eps\_m}}{2}\\
\end{array}
\end{array}
if x < 5.0000000000000003e-291Initial program 67.6%
Simplified61.0%
Taylor expanded in eps around inf 97.0%
Taylor expanded in x around 0 68.2%
Taylor expanded in eps around 0 78.1%
neg-mul-177.5%
Simplified78.1%
if 5.0000000000000003e-291 < x Initial program 79.0%
Simplified74.3%
Taylor expanded in eps around inf 99.9%
Taylor expanded in x around 0 53.3%
Taylor expanded in eps around inf 53.2%
*-commutative81.4%
Simplified53.2%
Final simplification63.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 540.0) (/ (+ 1.0 (exp (- x))) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 540.0) {
tmp = (1.0 + exp(-x)) / 2.0;
} else {
tmp = 0.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 <= 540.0d0) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else
tmp = 0.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 <= 540.0) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 540.0: tmp = (1.0 + math.exp(-x)) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 540.0) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 540.0) tmp = (1.0 + exp(-x)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 540.0], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 540:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 540Initial program 62.1%
Simplified54.0%
Taylor expanded in eps around inf 98.2%
Taylor expanded in x around 0 74.5%
Taylor expanded in eps around 0 76.8%
neg-mul-181.8%
Simplified76.8%
if 540 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 47.8%
div-sub47.8%
mul-1-neg47.8%
rec-exp47.8%
+-inverses47.8%
metadata-eval47.8%
Simplified47.8%
Final simplification67.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 1.6e-13) (/ (- 2.0 (* x eps_m)) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 1.6e-13) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else {
tmp = 0.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.6d-13) then
tmp = (2.0d0 - (x * eps_m)) / 2.0d0
else
tmp = 0.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.6e-13) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 1.6e-13: tmp = (2.0 - (x * eps_m)) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 1.6e-13) tmp = Float64(Float64(2.0 - Float64(x * eps_m)) / 2.0); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 1.6e-13) tmp = (2.0 - (x * eps_m)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 1.6e-13], N[(N[(2.0 - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6 \cdot 10^{-13}:\\
\;\;\;\;\frac{2 - x \cdot eps\_m}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.6e-13Initial program 61.6%
Simplified53.4%
Taylor expanded in x around 0 61.0%
Taylor expanded in eps around 0 67.5%
Taylor expanded in eps around inf 67.5%
associate-*r*67.5%
neg-mul-167.5%
Simplified67.5%
if 1.6e-13 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 46.7%
div-sub46.7%
mul-1-neg46.7%
rec-exp46.7%
+-inverses46.7%
metadata-eval46.7%
Simplified46.7%
Final simplification60.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 470.0) 1.0 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 470.0) {
tmp = 1.0;
} else {
tmp = 0.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 <= 470.0d0) then
tmp = 1.0d0
else
tmp = 0.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 <= 470.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 470.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 470.0) tmp = 1.0; else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 470.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 470.0], 1.0, 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 470:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 470Initial program 62.1%
Simplified54.0%
Taylor expanded in x around 0 60.4%
Taylor expanded in eps around 0 66.8%
Taylor expanded in eps around 0 60.3%
mul-1-neg60.3%
Simplified60.3%
Taylor expanded in x around 0 60.4%
if 470 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 47.8%
div-sub47.8%
mul-1-neg47.8%
rec-exp47.8%
+-inverses47.8%
metadata-eval47.8%
Simplified47.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 0.0)
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 0.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = 0.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 0.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return 0.0
eps_m = abs(eps) function code(x, eps_m) return 0.0 end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 0.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := 0.0
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
0
\end{array}
Initial program 74.4%
Simplified68.9%
Taylor expanded in eps around 0 17.0%
div-sub17.0%
mul-1-neg17.0%
rec-exp17.0%
+-inverses17.2%
metadata-eval17.2%
Simplified17.2%
herbie shell --seed 2024172
(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))