
(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 10 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 1e-5) (/ (* (exp (- x)) (+ 2.0 (* x 2.0))) 2.0) (/ (+ (exp (* x (+ eps_m -1.0))) (exp (* eps_m (- x)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1e-5) {
tmp = (exp(-x) * (2.0 + (x * 2.0))) / 2.0;
} else {
tmp = (exp((x * (eps_m + -1.0))) + exp((eps_m * -x))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 1d-5) then
tmp = (exp(-x) * (2.0d0 + (x * 2.0d0))) / 2.0d0
else
tmp = (exp((x * (eps_m + (-1.0d0)))) + exp((eps_m * -x))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1e-5) {
tmp = (Math.exp(-x) * (2.0 + (x * 2.0))) / 2.0;
} else {
tmp = (Math.exp((x * (eps_m + -1.0))) + Math.exp((eps_m * -x))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1e-5: tmp = (math.exp(-x) * (2.0 + (x * 2.0))) / 2.0 else: tmp = (math.exp((x * (eps_m + -1.0))) + math.exp((eps_m * -x))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1e-5) tmp = Float64(Float64(exp(Float64(-x)) * Float64(2.0 + Float64(x * 2.0))) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(eps_m + -1.0))) + exp(Float64(eps_m * Float64(-x)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 1e-5) tmp = (exp(-x) * (2.0 + (x * 2.0))) / 2.0; else tmp = (exp((x * (eps_m + -1.0))) + exp((eps_m * -x))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1e-5], N[(N[(N[Exp[(-x)], $MachinePrecision] * N[(2.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(eps$95$m * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 10^{-5}:\\
\;\;\;\;\frac{e^{-x} \cdot \left(2 + x \cdot 2\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(eps\_m + -1\right)} + e^{eps\_m \cdot \left(-x\right)}}{2}\\
\end{array}
\end{array}
if eps < 1.00000000000000008e-5Initial program 69.6%
Simplified61.4%
Taylor expanded in eps around 0 33.2%
+-commutative33.2%
associate-+r+33.2%
associate-+l+63.6%
associate-*r*63.6%
distribute-rgt-out63.6%
mul-1-neg63.6%
mul-1-neg63.6%
sub-neg63.6%
+-inverses63.6%
Simplified63.6%
if 1.00000000000000008e-5 < eps Initial program 99.8%
Simplified93.3%
Taylor expanded in eps around inf 99.8%
Taylor expanded in eps around inf 99.8%
rec-exp99.8%
distribute-rgt-neg-in99.8%
Applied egg-rr99.8%
Final simplification73.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ (exp (* x (+ eps_m -1.0))) (/ 1.0 (exp (+ x (* x eps_m))))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp((x * (eps_m + -1.0))) + (1.0 / exp((x + (x * eps_m))))) / 2.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = (exp((x * (eps_m + (-1.0d0)))) + (1.0d0 / exp((x + (x * eps_m))))) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (Math.exp((x * (eps_m + -1.0))) + (1.0 / Math.exp((x + (x * eps_m))))) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (math.exp((x * (eps_m + -1.0))) + (1.0 / math.exp((x + (x * eps_m))))) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(exp(Float64(x * Float64(eps_m + -1.0))) + Float64(1.0 / exp(Float64(x + Float64(x * eps_m))))) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (exp((x * (eps_m + -1.0))) + (1.0 / exp((x + (x * eps_m))))) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(1.0 / N[Exp[N[(x + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{e^{x \cdot \left(eps\_m + -1\right)} + \frac{1}{e^{x + x \cdot eps\_m}}}{2}
\end{array}
Initial program 77.5%
Simplified71.3%
Taylor expanded in eps around inf 99.2%
Final simplification99.2%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -2.4e-275)
(/ (+ 1.0 (/ 1.0 (pow E (* x eps_m)))) 2.0)
(if (<= x 9.5e+241)
(/ (+ (exp (* x (+ eps_m -1.0))) (/ 1.0 (+ 1.0 (* x (+ eps_m 1.0))))) 2.0)
0.0)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -2.4e-275) {
tmp = (1.0 + (1.0 / pow(((double) M_E), (x * eps_m)))) / 2.0;
} else if (x <= 9.5e+241) {
tmp = (exp((x * (eps_m + -1.0))) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -2.4e-275) {
tmp = (1.0 + (1.0 / Math.pow(Math.E, (x * eps_m)))) / 2.0;
} else if (x <= 9.5e+241) {
tmp = (Math.exp((x * (eps_m + -1.0))) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -2.4e-275: tmp = (1.0 + (1.0 / math.pow(math.e, (x * eps_m)))) / 2.0 elif x <= 9.5e+241: tmp = (math.exp((x * (eps_m + -1.0))) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -2.4e-275) tmp = Float64(Float64(1.0 + Float64(1.0 / (exp(1) ^ Float64(x * eps_m)))) / 2.0); elseif (x <= 9.5e+241) tmp = Float64(Float64(exp(Float64(x * Float64(eps_m + -1.0))) + Float64(1.0 / Float64(1.0 + Float64(x * Float64(eps_m + 1.0))))) / 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 <= -2.4e-275) tmp = (1.0 + (1.0 / (2.71828182845904523536 ^ (x * eps_m)))) / 2.0; elseif (x <= 9.5e+241) tmp = (exp((x * (eps_m + -1.0))) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 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, -2.4e-275], N[(N[(1.0 + N[(1.0 / N[Power[E, N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 9.5e+241], N[(N[(N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(1.0 / N[(1.0 + N[(x * N[(eps$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{-275}:\\
\;\;\;\;\frac{1 + \frac{1}{{e}^{\left(x \cdot eps\_m\right)}}}{2}\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+241}:\\
\;\;\;\;\frac{e^{x \cdot \left(eps\_m + -1\right)} + \frac{1}{1 + x \cdot \left(eps\_m + 1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -2.39999999999999991e-275Initial program 80.8%
Simplified68.1%
Taylor expanded in eps around inf 99.2%
Taylor expanded in eps around inf 99.3%
Taylor expanded in x around 0 61.4%
*-un-lft-identity61.4%
exp-prod61.4%
add-log-exp61.4%
add-sqr-sqrt61.4%
log-prod61.4%
unpow-prod-up61.4%
pow1/261.4%
log-pow61.4%
add-log-exp61.4%
pow1/261.4%
log-pow61.4%
add-log-exp61.4%
Applied egg-rr61.4%
pow-sqr61.4%
exp-1-e61.4%
associate-*r*61.4%
metadata-eval61.4%
*-lft-identity61.4%
Simplified61.4%
if -2.39999999999999991e-275 < x < 9.50000000000000019e241Initial program 71.7%
Simplified69.0%
Taylor expanded in eps around inf 99.1%
Taylor expanded in x around 0 61.7%
if 9.50000000000000019e241 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 64.2%
mul-1-neg64.2%
mul-1-neg64.2%
rec-exp64.2%
sub-neg64.2%
div-sub64.2%
rec-exp64.2%
mul-1-neg64.2%
+-inverses64.2%
Simplified64.2%
Final simplification61.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -2.4e-275) (/ (+ 1.0 (exp (* eps_m (- x)))) 2.0) (if (<= x 9e+241) (/ (+ 1.0 (exp (* x (+ eps_m -1.0)))) 2.0) 0.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -2.4e-275) {
tmp = (1.0 + exp((eps_m * -x))) / 2.0;
} else if (x <= 9e+241) {
tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 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 <= (-2.4d-275)) then
tmp = (1.0d0 + exp((eps_m * -x))) / 2.0d0
else if (x <= 9d+241) then
tmp = (1.0d0 + exp((x * (eps_m + (-1.0d0))))) / 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 <= -2.4e-275) {
tmp = (1.0 + Math.exp((eps_m * -x))) / 2.0;
} else if (x <= 9e+241) {
tmp = (1.0 + Math.exp((x * (eps_m + -1.0)))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -2.4e-275: tmp = (1.0 + math.exp((eps_m * -x))) / 2.0 elif x <= 9e+241: tmp = (1.0 + math.exp((x * (eps_m + -1.0)))) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -2.4e-275) tmp = Float64(Float64(1.0 + exp(Float64(eps_m * Float64(-x)))) / 2.0); elseif (x <= 9e+241) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps_m + -1.0)))) / 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 <= -2.4e-275) tmp = (1.0 + exp((eps_m * -x))) / 2.0; elseif (x <= 9e+241) tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 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, -2.4e-275], N[(N[(1.0 + N[Exp[N[(eps$95$m * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 9e+241], N[(N[(1.0 + N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{-275}:\\
\;\;\;\;\frac{1 + e^{eps\_m \cdot \left(-x\right)}}{2}\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+241}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(eps\_m + -1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -2.39999999999999991e-275Initial program 80.8%
Simplified68.1%
Taylor expanded in eps around inf 99.2%
Taylor expanded in eps around inf 99.3%
rec-exp99.3%
distribute-rgt-neg-in99.3%
Applied egg-rr99.3%
Taylor expanded in x around 0 61.4%
if -2.39999999999999991e-275 < x < 8.99999999999999987e241Initial program 71.7%
Simplified69.0%
Taylor expanded in eps around inf 99.1%
Taylor expanded in eps around inf 85.0%
rec-exp85.0%
distribute-rgt-neg-in85.0%
Applied egg-rr85.0%
Taylor expanded in eps around 0 61.9%
if 8.99999999999999987e241 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 64.2%
mul-1-neg64.2%
mul-1-neg64.2%
rec-exp64.2%
sub-neg64.2%
div-sub64.2%
rec-exp64.2%
mul-1-neg64.2%
+-inverses64.2%
Simplified64.2%
Final simplification61.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -1e-270) (/ (+ 1.0 (/ 1.0 (pow E (* x eps_m)))) 2.0) (if (<= x 9.5e+241) (/ (+ 1.0 (exp (* x (+ eps_m -1.0)))) 2.0) 0.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1e-270) {
tmp = (1.0 + (1.0 / pow(((double) M_E), (x * eps_m)))) / 2.0;
} else if (x <= 9.5e+241) {
tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -1e-270) {
tmp = (1.0 + (1.0 / Math.pow(Math.E, (x * eps_m)))) / 2.0;
} else if (x <= 9.5e+241) {
tmp = (1.0 + Math.exp((x * (eps_m + -1.0)))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1e-270: tmp = (1.0 + (1.0 / math.pow(math.e, (x * eps_m)))) / 2.0 elif x <= 9.5e+241: tmp = (1.0 + math.exp((x * (eps_m + -1.0)))) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1e-270) tmp = Float64(Float64(1.0 + Float64(1.0 / (exp(1) ^ Float64(x * eps_m)))) / 2.0); elseif (x <= 9.5e+241) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps_m + -1.0)))) / 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 <= -1e-270) tmp = (1.0 + (1.0 / (2.71828182845904523536 ^ (x * eps_m)))) / 2.0; elseif (x <= 9.5e+241) tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 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, -1e-270], N[(N[(1.0 + N[(1.0 / N[Power[E, N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 9.5e+241], N[(N[(1.0 + N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-270}:\\
\;\;\;\;\frac{1 + \frac{1}{{e}^{\left(x \cdot eps\_m\right)}}}{2}\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+241}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(eps\_m + -1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1e-270Initial program 80.8%
Simplified68.1%
Taylor expanded in eps around inf 99.2%
Taylor expanded in eps around inf 99.3%
Taylor expanded in x around 0 61.4%
*-un-lft-identity61.4%
exp-prod61.4%
add-log-exp61.4%
add-sqr-sqrt61.4%
log-prod61.4%
unpow-prod-up61.4%
pow1/261.4%
log-pow61.4%
add-log-exp61.4%
pow1/261.4%
log-pow61.4%
add-log-exp61.4%
Applied egg-rr61.4%
pow-sqr61.4%
exp-1-e61.4%
associate-*r*61.4%
metadata-eval61.4%
*-lft-identity61.4%
Simplified61.4%
if -1e-270 < x < 9.50000000000000019e241Initial program 71.7%
Simplified69.0%
Taylor expanded in eps around inf 99.1%
Taylor expanded in eps around inf 85.0%
rec-exp85.0%
distribute-rgt-neg-in85.0%
Applied egg-rr85.0%
Taylor expanded in eps around 0 61.9%
if 9.50000000000000019e241 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 64.2%
mul-1-neg64.2%
mul-1-neg64.2%
rec-exp64.2%
sub-neg64.2%
div-sub64.2%
rec-exp64.2%
mul-1-neg64.2%
+-inverses64.2%
Simplified64.2%
Final simplification61.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 8300000.0) (/ (+ 1.0 (exp (* eps_m (- x)))) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 8300000.0) {
tmp = (1.0 + exp((eps_m * -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 <= 8300000.0d0) then
tmp = (1.0d0 + exp((eps_m * -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 <= 8300000.0) {
tmp = (1.0 + Math.exp((eps_m * -x))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 8300000.0: tmp = (1.0 + math.exp((eps_m * -x))) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 8300000.0) tmp = Float64(Float64(1.0 + exp(Float64(eps_m * 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 <= 8300000.0) tmp = (1.0 + exp((eps_m * -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, 8300000.0], N[(N[(1.0 + N[Exp[N[(eps$95$m * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8300000:\\
\;\;\;\;\frac{1 + e^{eps\_m \cdot \left(-x\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 8.3e6Initial program 67.7%
Simplified58.7%
Taylor expanded in eps around inf 98.9%
Taylor expanded in eps around inf 98.9%
rec-exp98.9%
distribute-rgt-neg-in98.9%
Applied egg-rr98.9%
Taylor expanded in x around 0 75.2%
if 8.3e6 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 49.5%
mul-1-neg49.5%
mul-1-neg49.5%
rec-exp49.5%
sub-neg49.5%
div-sub49.5%
rec-exp49.5%
mul-1-neg49.5%
+-inverses49.5%
Simplified49.5%
Final simplification67.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 8300000.0) (/ (+ 1.0 (exp (- x))) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 8300000.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 <= 8300000.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 <= 8300000.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 <= 8300000.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 <= 8300000.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 <= 8300000.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, 8300000.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 8300000:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 8.3e6Initial program 67.7%
Simplified58.7%
Taylor expanded in eps around inf 98.9%
Taylor expanded in eps around inf 98.9%
rec-exp98.9%
distribute-rgt-neg-in98.9%
Applied egg-rr98.9%
Taylor expanded in eps around 0 74.5%
mul-1-neg74.5%
Simplified74.5%
if 8.3e6 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 49.5%
mul-1-neg49.5%
mul-1-neg49.5%
rec-exp49.5%
sub-neg49.5%
div-sub49.5%
rec-exp49.5%
mul-1-neg49.5%
+-inverses49.5%
Simplified49.5%
Final simplification66.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 0.0102) (/ (+ 1.0 (- 1.0 (* x eps_m))) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 0.0102) {
tmp = (1.0 + (1.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 <= 0.0102d0) then
tmp = (1.0d0 + (1.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 <= 0.0102) {
tmp = (1.0 + (1.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 <= 0.0102: tmp = (1.0 + (1.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 <= 0.0102) tmp = Float64(Float64(1.0 + Float64(1.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 <= 0.0102) tmp = (1.0 + (1.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, 0.0102], N[(N[(1.0 + N[(1.0 - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0102:\\
\;\;\;\;\frac{1 + \left(1 - x \cdot eps\_m\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 0.010200000000000001Initial program 67.0%
Simplified57.8%
Taylor expanded in eps around inf 98.8%
Taylor expanded in eps around inf 98.9%
Taylor expanded in x around 0 76.3%
Taylor expanded in eps around 0 59.1%
mul-1-neg59.1%
unsub-neg59.1%
Simplified59.1%
if 0.010200000000000001 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 47.2%
mul-1-neg47.2%
mul-1-neg47.2%
rec-exp47.2%
sub-neg47.2%
div-sub47.2%
rec-exp47.2%
mul-1-neg47.2%
+-inverses47.2%
Simplified47.2%
Final simplification55.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 8300000.0) 1.0 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 8300000.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 <= 8300000.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 <= 8300000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 8300000.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 8300000.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 <= 8300000.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, 8300000.0], 1.0, 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8300000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 8.3e6Initial program 67.7%
Simplified67.7%
Taylor expanded in x around 0 52.2%
if 8.3e6 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 49.5%
mul-1-neg49.5%
mul-1-neg49.5%
rec-exp49.5%
sub-neg49.5%
div-sub49.5%
rec-exp49.5%
mul-1-neg49.5%
+-inverses49.5%
Simplified49.5%
Final simplification51.4%
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 77.5%
Simplified67.9%
Taylor expanded in eps around 0 16.5%
mul-1-neg16.5%
mul-1-neg16.5%
rec-exp16.5%
sub-neg16.5%
div-sub16.5%
rec-exp16.5%
mul-1-neg16.5%
+-inverses16.7%
Simplified16.7%
Final simplification16.7%
herbie shell --seed 2024047
(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))