
(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 (if (<= eps_m 8e-6) (/ (/ (fma x 2.0 2.0) (exp x)) 2.0) (/ (+ (pow E (* 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 <= 8e-6) {
tmp = (fma(x, 2.0, 2.0) / exp(x)) / 2.0;
} else {
tmp = (pow(((double) M_E), (x * (-1.0 - eps_m))) + exp((x * eps_m))) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 8e-6) tmp = Float64(Float64(fma(x, 2.0, 2.0) / exp(x)) / 2.0); else tmp = Float64(Float64((exp(1) ^ Float64(x * Float64(-1.0 - eps_m))) + exp(Float64(x * eps_m))) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 8e-6], N[(N[(N[(x * 2.0 + 2.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Power[E, 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 8 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x, 2, 2\right)}{e^{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{{e}^{\left(x \cdot \left(-1 - eps\_m\right)\right)} + e^{x \cdot eps\_m}}{2}\\
\end{array}
\end{array}
if eps < 7.99999999999999964e-6Initial program 61.3%
Simplified52.8%
Taylor expanded in eps around 0 27.7%
Simplified67.5%
Taylor expanded in eps around 0 67.5%
*-commutative67.5%
+-commutative67.5%
*-commutative67.5%
fma-undefine67.5%
exp-neg67.5%
associate-*r/67.5%
*-rgt-identity67.5%
Simplified67.5%
if 7.99999999999999964e-6 < eps Initial program 99.8%
Simplified88.9%
Taylor expanded in eps around inf 100.0%
*-un-lft-identity100.0%
exp-prod100.0%
+-commutative100.0%
*-commutative100.0%
fma-define100.0%
Applied egg-rr100.0%
pow-flip100.0%
exp-1-e100.0%
Applied egg-rr100.0%
fma-undefine100.0%
distribute-neg-in100.0%
distribute-rgt-neg-out100.0%
mul-1-neg100.0%
*-commutative100.0%
+-commutative100.0%
distribute-rgt-out100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification76.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 8e-6) (/ (/ (fma x 2.0 2.0) (exp x)) 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 <= 8e-6) {
tmp = (fma(x, 2.0, 2.0) / exp(x)) / 2.0;
} else {
tmp = (exp((x * (-1.0 - eps_m))) + exp((x * eps_m))) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 8e-6) tmp = Float64(Float64(fma(x, 2.0, 2.0) / exp(x)) / 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 = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 8e-6], N[(N[(N[(x * 2.0 + 2.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $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 8 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x, 2, 2\right)}{e^{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 - eps\_m\right)} + e^{x \cdot eps\_m}}{2}\\
\end{array}
\end{array}
if eps < 7.99999999999999964e-6Initial program 61.3%
Simplified52.8%
Taylor expanded in eps around 0 27.7%
Simplified67.5%
Taylor expanded in eps around 0 67.5%
*-commutative67.5%
+-commutative67.5%
*-commutative67.5%
fma-undefine67.5%
exp-neg67.5%
associate-*r/67.5%
*-rgt-identity67.5%
Simplified67.5%
if 7.99999999999999964e-6 < eps Initial program 99.8%
Simplified88.9%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around -inf 100.0%
*-commutative100.0%
fma-neg100.0%
mul-1-neg100.0%
remove-double-neg100.0%
fma-undefine100.0%
*-commutative100.0%
exp-sum100.0%
*-commutative100.0%
exp-prod85.9%
pow-plus85.9%
+-commutative85.9%
exp-prod100.0%
exp-neg100.0%
distribute-rgt-neg-in100.0%
distribute-neg-in100.0%
metadata-eval100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification76.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ (exp (* x (+ eps_m -1.0))) (pow E (* 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))) + pow(((double) M_E), (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.pow(Math.E, (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.pow(math.e, (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(1) ^ 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))) + (2.71828182845904523536 ^ (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[Power[E, 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}^{\left(x \cdot \left(-1 - eps\_m\right)\right)}}{2}
\end{array}
Initial program 71.6%
Simplified64.5%
Taylor expanded in eps around inf 98.7%
*-un-lft-identity98.7%
exp-prod98.7%
+-commutative98.7%
*-commutative98.7%
fma-define98.7%
Applied egg-rr98.7%
pow-flip98.7%
exp-1-e98.7%
Applied egg-rr98.7%
fma-undefine98.7%
distribute-neg-in98.7%
distribute-rgt-neg-out98.7%
mul-1-neg98.7%
*-commutative98.7%
+-commutative98.7%
distribute-rgt-out98.7%
sub-neg98.7%
Simplified98.7%
Final simplification98.7%
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 71.6%
Simplified64.5%
Taylor expanded in eps around inf 98.7%
Taylor expanded in x around -inf 98.7%
*-commutative98.7%
fma-neg98.7%
mul-1-neg98.7%
remove-double-neg98.7%
fma-undefine98.7%
*-commutative98.7%
exp-sum80.0%
*-commutative80.0%
exp-prod71.7%
pow-plus93.2%
+-commutative93.2%
exp-prod98.7%
exp-neg98.7%
distribute-rgt-neg-in98.7%
distribute-neg-in98.7%
metadata-eval98.7%
unsub-neg98.7%
Simplified98.7%
Final simplification98.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 8e-6) (/ (/ (fma x 2.0 2.0) (exp x)) 2.0) (/ (* eps_m (+ x (/ (+ 1.0 (exp (* x (- -1.0 eps_m)))) eps_m))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 8e-6) {
tmp = (fma(x, 2.0, 2.0) / exp(x)) / 2.0;
} else {
tmp = (eps_m * (x + ((1.0 + exp((x * (-1.0 - eps_m)))) / eps_m))) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 8e-6) tmp = Float64(Float64(fma(x, 2.0, 2.0) / exp(x)) / 2.0); else tmp = Float64(Float64(eps_m * Float64(x + Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps_m)))) / eps_m))) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 8e-6], N[(N[(N[(x * 2.0 + 2.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(eps$95$m * N[(x + N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 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 8 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x, 2, 2\right)}{e^{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{eps\_m \cdot \left(x + \frac{1 + e^{x \cdot \left(-1 - eps\_m\right)}}{eps\_m}\right)}{2}\\
\end{array}
\end{array}
if eps < 7.99999999999999964e-6Initial program 61.3%
Simplified52.8%
Taylor expanded in eps around 0 27.7%
Simplified67.5%
Taylor expanded in eps around 0 67.5%
*-commutative67.5%
+-commutative67.5%
*-commutative67.5%
fma-undefine67.5%
exp-neg67.5%
associate-*r/67.5%
*-rgt-identity67.5%
Simplified67.5%
if 7.99999999999999964e-6 < eps Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 70.3%
+-commutative70.3%
associate-+r+70.3%
mul-1-neg70.3%
distribute-rgt-neg-in70.3%
*-commutative70.3%
distribute-rgt-neg-in70.3%
distribute-neg-in70.3%
metadata-eval70.3%
distribute-neg-frac70.3%
metadata-eval70.3%
Simplified70.3%
Taylor expanded in eps around inf 82.1%
Simplified82.1%
Final simplification71.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 8e-6) (/ (* (exp (- x)) (+ 2.0 (* x 2.0))) 2.0) (/ (* eps_m (+ x (/ (+ 1.0 (exp (* x (- -1.0 eps_m)))) eps_m))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 8e-6) {
tmp = (exp(-x) * (2.0 + (x * 2.0))) / 2.0;
} else {
tmp = (eps_m * (x + ((1.0 + exp((x * (-1.0 - eps_m)))) / 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 <= 8d-6) then
tmp = (exp(-x) * (2.0d0 + (x * 2.0d0))) / 2.0d0
else
tmp = (eps_m * (x + ((1.0d0 + exp((x * ((-1.0d0) - eps_m)))) / 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 <= 8e-6) {
tmp = (Math.exp(-x) * (2.0 + (x * 2.0))) / 2.0;
} else {
tmp = (eps_m * (x + ((1.0 + Math.exp((x * (-1.0 - eps_m)))) / eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 8e-6: tmp = (math.exp(-x) * (2.0 + (x * 2.0))) / 2.0 else: tmp = (eps_m * (x + ((1.0 + math.exp((x * (-1.0 - eps_m)))) / eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 8e-6) tmp = Float64(Float64(exp(Float64(-x)) * Float64(2.0 + Float64(x * 2.0))) / 2.0); else tmp = Float64(Float64(eps_m * Float64(x + Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps_m)))) / 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 <= 8e-6) tmp = (exp(-x) * (2.0 + (x * 2.0))) / 2.0; else tmp = (eps_m * (x + ((1.0 + exp((x * (-1.0 - eps_m)))) / 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, 8e-6], N[(N[(N[Exp[(-x)], $MachinePrecision] * N[(2.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(eps$95$m * N[(x + N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 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 8 \cdot 10^{-6}:\\
\;\;\;\;\frac{e^{-x} \cdot \left(2 + x \cdot 2\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{eps\_m \cdot \left(x + \frac{1 + e^{x \cdot \left(-1 - eps\_m\right)}}{eps\_m}\right)}{2}\\
\end{array}
\end{array}
if eps < 7.99999999999999964e-6Initial program 61.3%
Simplified52.8%
Taylor expanded in eps around 0 27.7%
Simplified67.5%
Taylor expanded in eps around 0 67.5%
if 7.99999999999999964e-6 < eps Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 70.3%
+-commutative70.3%
associate-+r+70.3%
mul-1-neg70.3%
distribute-rgt-neg-in70.3%
*-commutative70.3%
distribute-rgt-neg-in70.3%
distribute-neg-in70.3%
metadata-eval70.3%
distribute-neg-frac70.3%
metadata-eval70.3%
Simplified70.3%
Taylor expanded in eps around inf 82.1%
Simplified82.1%
Final simplification71.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -2.8e-249) (/ (+ 1.0 (exp (* 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 <= -2.8e-249) {
tmp = (1.0 + exp((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 <= (-2.8d-249)) then
tmp = (1.0d0 + exp((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 <= -2.8e-249) {
tmp = (1.0 + Math.exp((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 <= -2.8e-249: tmp = (1.0 + math.exp((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 <= -2.8e-249) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-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 <= -2.8e-249) tmp = (1.0 + exp((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, -2.8e-249], N[(N[(1.0 + N[Exp[N[(x * (-eps$95$m)), $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 -2.8 \cdot 10^{-249}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(eps\_m + -1\right)}}{2}\\
\end{array}
\end{array}
if x < -2.7999999999999999e-249Initial program 71.9%
Simplified71.9%
Taylor expanded in x around 0 40.2%
Taylor expanded in eps around inf 67.9%
cancel-sign-sub-inv67.9%
metadata-eval67.9%
*-lft-identity67.9%
mul-1-neg67.9%
distribute-rgt-neg-in67.9%
distribute-neg-in67.9%
metadata-eval67.9%
unsub-neg67.9%
Simplified67.9%
Taylor expanded in eps around inf 68.8%
mul-1-neg68.8%
distribute-lft-neg-out68.8%
*-commutative68.8%
Simplified68.8%
if -2.7999999999999999e-249 < x Initial program 71.3%
Simplified66.5%
Taylor expanded in eps around inf 99.2%
*-un-lft-identity99.2%
exp-prod99.2%
+-commutative99.2%
*-commutative99.2%
fma-define99.2%
Applied egg-rr99.2%
pow-flip99.2%
exp-1-e99.2%
Applied egg-rr99.2%
fma-undefine99.2%
distribute-neg-in99.2%
distribute-rgt-neg-out99.2%
mul-1-neg99.2%
*-commutative99.2%
+-commutative99.2%
distribute-rgt-out99.2%
sub-neg99.2%
Simplified99.2%
Taylor expanded in x around 0 60.4%
Final simplification64.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 480.0) (/ (+ 1.0 (exp (* x (- eps_m)))) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 480.0) {
tmp = (1.0 + exp((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 <= 480.0d0) then
tmp = (1.0d0 + exp((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 <= 480.0) {
tmp = (1.0 + Math.exp((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 <= 480.0: tmp = (1.0 + math.exp((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 <= 480.0) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-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 <= 480.0) tmp = (1.0 + exp((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, 480.0], N[(N[(1.0 + N[Exp[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 480:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 480Initial program 61.5%
Simplified61.5%
Taylor expanded in x around 0 38.8%
Taylor expanded in eps around inf 76.5%
cancel-sign-sub-inv76.5%
metadata-eval76.5%
*-lft-identity76.5%
mul-1-neg76.5%
distribute-rgt-neg-in76.5%
distribute-neg-in76.5%
metadata-eval76.5%
unsub-neg76.5%
Simplified76.5%
Taylor expanded in eps around inf 77.4%
mul-1-neg77.4%
distribute-lft-neg-out77.4%
*-commutative77.4%
Simplified77.4%
if 480 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 45.6%
mul-1-neg45.6%
mul-1-neg45.6%
rec-exp45.6%
sub-neg45.6%
div-sub45.6%
mul-1-neg45.6%
rec-exp45.6%
+-inverses45.6%
Simplified45.6%
Final simplification69.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 580.0) (/ (+ 1.0 (exp (- x))) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 580.0) {
tmp = (1.0 + exp(-x)) / 2.0;
} else {
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 <= 580.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 <= 580.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 <= 580.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 <= 580.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 <= 580.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, 580.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 580:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 580Initial program 61.5%
Simplified61.5%
Taylor expanded in x around 0 41.4%
+-commutative41.4%
associate-+r+41.4%
mul-1-neg41.4%
distribute-rgt-neg-in41.4%
*-commutative41.4%
distribute-rgt-neg-in41.4%
distribute-neg-in41.4%
metadata-eval41.4%
distribute-neg-frac41.4%
metadata-eval41.4%
Simplified41.4%
Taylor expanded in eps around inf 82.3%
Simplified82.3%
Taylor expanded in eps around 0 79.5%
mul-1-neg79.5%
Simplified79.5%
if 580 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 45.6%
mul-1-neg45.6%
mul-1-neg45.6%
rec-exp45.6%
sub-neg45.6%
div-sub45.6%
mul-1-neg45.6%
rec-exp45.6%
+-inverses45.6%
Simplified45.6%
Final simplification70.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 72.0) (/ (- 2.0 (* x eps_m)) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 72.0) {
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 <= 72.0d0) 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 <= 72.0) {
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 <= 72.0: 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 <= 72.0) 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 <= 72.0) 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, 72.0], 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 72:\\
\;\;\;\;\frac{2 - x \cdot eps\_m}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 72Initial program 61.3%
Simplified61.3%
Taylor expanded in x around 0 38.4%
Taylor expanded in x around 0 40.8%
Taylor expanded in eps around inf 61.6%
associate-*r*61.6%
neg-mul-161.6%
Simplified61.6%
if 72 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 45.0%
mul-1-neg45.0%
mul-1-neg45.0%
rec-exp45.0%
sub-neg45.0%
div-sub45.0%
mul-1-neg45.0%
rec-exp45.0%
+-inverses45.0%
Simplified45.0%
Final simplification57.2%
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 61.5%
Simplified61.5%
Taylor expanded in x around 0 57.4%
if 470 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 45.6%
mul-1-neg45.6%
mul-1-neg45.6%
rec-exp45.6%
sub-neg45.6%
div-sub45.6%
mul-1-neg45.6%
rec-exp45.6%
+-inverses45.6%
Simplified45.6%
Final simplification54.3%
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 71.6%
Simplified61.5%
Taylor expanded in eps around 0 13.5%
mul-1-neg13.5%
mul-1-neg13.5%
rec-exp13.5%
sub-neg13.5%
div-sub13.5%
mul-1-neg13.5%
rec-exp13.5%
+-inverses13.8%
Simplified13.8%
Final simplification13.8%
herbie shell --seed 2024076
(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))