
(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 0.008) (* (exp (- x)) (+ x 1.0)) (/ (+ (exp (* x eps_m)) (exp (* x (- eps_m)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.008) {
tmp = exp(-x) * (x + 1.0);
} else {
tmp = (exp((x * 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 <= 0.008d0) then
tmp = exp(-x) * (x + 1.0d0)
else
tmp = (exp((x * 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 <= 0.008) {
tmp = Math.exp(-x) * (x + 1.0);
} else {
tmp = (Math.exp((x * 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 <= 0.008: tmp = math.exp(-x) * (x + 1.0) else: tmp = (math.exp((x * 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 <= 0.008) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); else tmp = Float64(Float64(exp(Float64(x * 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) tmp = 0.0; if (eps_m <= 0.008) tmp = exp(-x) * (x + 1.0); else tmp = (exp((x * 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, 0.008], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $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 0.008:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 0.0080000000000000002Initial program 68.4%
Simplified61.4%
Taylor expanded in eps around 0 34.9%
associate-+r+67.4%
mul-1-neg67.4%
sub-neg67.4%
+-inverses67.4%
distribute-lft-out67.4%
distribute-rgt1-in67.4%
mul-1-neg67.4%
Simplified67.4%
Taylor expanded in eps around 0 67.4%
if 0.0080000000000000002 < eps Initial program 100.0%
Simplified89.7%
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%
*-commutative100.0%
fmm-def100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-rgt-identity100.0%
exp-neg100.0%
*-rgt-identity100.0%
remove-double-neg100.0%
mul-1-neg100.0%
fmm-def100.0%
*-commutative100.0%
distribute-rgt-out--100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
Simplified100.0%
Final simplification77.7%
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 78.4%
Simplified71.2%
Taylor expanded in eps around inf 99.5%
Final simplification99.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -1e-220) (/ (+ 1.0 (exp (* x (- -1.0 eps_m)))) 2.0) (/ (+ (exp (* x (+ eps_m -1.0))) (/ 1.0 (+ 1.0 (* x (+ eps_m 1.0))))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1e-220) {
tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0;
} else {
tmp = (exp((x * (eps_m + -1.0))) + (1.0 / (1.0 + (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 <= (-1d-220)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps_m)))) / 2.0d0
else
tmp = (exp((x * (eps_m + (-1.0d0)))) + (1.0d0 / (1.0d0 + (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 <= -1e-220) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
} else {
tmp = (Math.exp((x * (eps_m + -1.0))) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1e-220: tmp = (1.0 + math.exp((x * (-1.0 - eps_m)))) / 2.0 else: tmp = (math.exp((x * (eps_m + -1.0))) + (1.0 / (1.0 + (x * (eps_m + 1.0))))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1e-220) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0); else 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); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -1e-220) tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 2.0; else tmp = (exp((x * (eps_m + -1.0))) + (1.0 / (1.0 + (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, -1e-220], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 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]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-220}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(eps\_m + -1\right)} + \frac{1}{1 + x \cdot \left(eps\_m + 1\right)}}{2}\\
\end{array}
\end{array}
if x < -9.99999999999999992e-221Initial program 82.4%
Simplified71.1%
Taylor expanded in eps around inf 99.3%
Taylor expanded in x around 0 59.4%
Taylor expanded in x around -inf 59.4%
*-commutative99.4%
fmm-def99.4%
mul-1-neg99.4%
remove-double-neg99.4%
*-rgt-identity99.4%
exp-neg99.4%
*-rgt-identity99.4%
remove-double-neg99.4%
mul-1-neg99.4%
fmm-def99.4%
*-commutative99.4%
distribute-rgt-out--99.4%
Simplified59.4%
if -9.99999999999999992e-221 < x Initial program 76.4%
Simplified71.2%
Taylor expanded in eps around inf 99.6%
Taylor expanded in x around 0 63.2%
Final simplification61.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= eps_m 0.008)
(* t_0 (+ x 1.0))
(if (<= eps_m 1.35e+173)
(/ (+ 1.0 t_0) 2.0)
(/
(+ 2.0 (* x (- (/ (+ 1.0 (* eps_m (+ eps_m 1.0))) eps_m) eps_m)))
2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (eps_m <= 0.008) {
tmp = t_0 * (x + 1.0);
} else if (eps_m <= 1.35e+173) {
tmp = (1.0 + t_0) / 2.0;
} else {
tmp = (2.0 + (x * (((1.0 + (eps_m * (eps_m + 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) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (eps_m <= 0.008d0) then
tmp = t_0 * (x + 1.0d0)
else if (eps_m <= 1.35d+173) then
tmp = (1.0d0 + t_0) / 2.0d0
else
tmp = (2.0d0 + (x * (((1.0d0 + (eps_m * (eps_m + 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 t_0 = Math.exp(-x);
double tmp;
if (eps_m <= 0.008) {
tmp = t_0 * (x + 1.0);
} else if (eps_m <= 1.35e+173) {
tmp = (1.0 + t_0) / 2.0;
} else {
tmp = (2.0 + (x * (((1.0 + (eps_m * (eps_m + 1.0))) / eps_m) - eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp(-x) tmp = 0 if eps_m <= 0.008: tmp = t_0 * (x + 1.0) elif eps_m <= 1.35e+173: tmp = (1.0 + t_0) / 2.0 else: tmp = (2.0 + (x * (((1.0 + (eps_m * (eps_m + 1.0))) / eps_m) - eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (eps_m <= 0.008) tmp = Float64(t_0 * Float64(x + 1.0)); elseif (eps_m <= 1.35e+173) tmp = Float64(Float64(1.0 + t_0) / 2.0); else tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(1.0 + Float64(eps_m * Float64(eps_m + 1.0))) / eps_m) - eps_m))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp(-x); tmp = 0.0; if (eps_m <= 0.008) tmp = t_0 * (x + 1.0); elseif (eps_m <= 1.35e+173) tmp = (1.0 + t_0) / 2.0; else tmp = (2.0 + (x * (((1.0 + (eps_m * (eps_m + 1.0))) / eps_m) - 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[Exp[(-x)], $MachinePrecision]}, If[LessEqual[eps$95$m, 0.008], N[(t$95$0 * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps$95$m, 1.35e+173], N[(N[(1.0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(x * N[(N[(N[(1.0 + N[(eps$95$m * N[(eps$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision] - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;eps\_m \leq 0.008:\\
\;\;\;\;t\_0 \cdot \left(x + 1\right)\\
\mathbf{elif}\;eps\_m \leq 1.35 \cdot 10^{+173}:\\
\;\;\;\;\frac{1 + t\_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + x \cdot \left(\frac{1 + eps\_m \cdot \left(eps\_m + 1\right)}{eps\_m} - eps\_m\right)}{2}\\
\end{array}
\end{array}
if eps < 0.0080000000000000002Initial program 68.4%
Simplified61.4%
Taylor expanded in eps around 0 34.9%
associate-+r+67.4%
mul-1-neg67.4%
sub-neg67.4%
+-inverses67.4%
distribute-lft-out67.4%
distribute-rgt1-in67.4%
mul-1-neg67.4%
Simplified67.4%
Taylor expanded in eps around 0 67.4%
if 0.0080000000000000002 < eps < 1.3500000000000001e173Initial program 100.0%
Simplified88.8%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 64.6%
Taylor expanded in eps around 0 62.7%
rec-exp62.7%
Simplified62.7%
if 1.3500000000000001e173 < eps Initial program 100.0%
Simplified91.3%
Taylor expanded in x around 0 8.6%
Taylor expanded in eps around inf 8.6%
Taylor expanded in eps around 0 44.9%
Final simplification63.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -8e-275) (/ (+ 1.0 (exp (* x (- -1.0 eps_m)))) 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 <= -8e-275) {
tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 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 <= (-8d-275)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps_m)))) / 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 <= -8e-275) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps_m)))) / 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 <= -8e-275: tmp = (1.0 + math.exp((x * (-1.0 - eps_m)))) / 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 <= -8e-275) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps_m)))) / 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 <= -8e-275) tmp = (1.0 + exp((x * (-1.0 - eps_m)))) / 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, -8e-275], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $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 -8 \cdot 10^{-275}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot eps\_m}}{2}\\
\end{array}
\end{array}
if x < -7.99999999999999947e-275Initial program 80.8%
Simplified69.6%
Taylor expanded in eps around inf 99.4%
Taylor expanded in x around 0 61.9%
Taylor expanded in x around -inf 61.9%
*-commutative99.4%
fmm-def99.4%
mul-1-neg99.4%
remove-double-neg99.4%
*-rgt-identity99.4%
exp-neg99.4%
*-rgt-identity99.4%
remove-double-neg99.4%
mul-1-neg99.4%
fmm-def99.4%
*-commutative99.4%
distribute-rgt-out--99.4%
Simplified61.9%
if -7.99999999999999947e-275 < x Initial program 77.0%
Simplified72.1%
Taylor expanded in eps around inf 99.5%
Taylor expanded in eps around inf 78.3%
*-commutative78.3%
Simplified78.3%
Taylor expanded in x around 0 61.4%
Final simplification61.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 0.008) (* (exp (- x)) (+ x 1.0)) (/ (+ 1.0 (exp (* x eps_m))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.008) {
tmp = exp(-x) * (x + 1.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 (eps_m <= 0.008d0) then
tmp = exp(-x) * (x + 1.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 (eps_m <= 0.008) {
tmp = Math.exp(-x) * (x + 1.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 eps_m <= 0.008: tmp = math.exp(-x) * (x + 1.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 (eps_m <= 0.008) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.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 (eps_m <= 0.008) tmp = exp(-x) * (x + 1.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[eps$95$m, 0.008], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $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}\;eps\_m \leq 0.008:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot eps\_m}}{2}\\
\end{array}
\end{array}
if eps < 0.0080000000000000002Initial program 68.4%
Simplified61.4%
Taylor expanded in eps around 0 34.9%
associate-+r+67.4%
mul-1-neg67.4%
sub-neg67.4%
+-inverses67.4%
distribute-lft-out67.4%
distribute-rgt1-in67.4%
mul-1-neg67.4%
Simplified67.4%
Taylor expanded in eps around 0 67.4%
if 0.0080000000000000002 < eps Initial program 100.0%
Simplified89.7%
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 0 68.2%
Final simplification67.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 0.008)
(* (exp (- x)) (+ x 1.0))
(if (<= eps_m 2.6e+264)
(/
(/
(* eps_m (* 2.0 (* (+ x 1.0) (+ 1.0 (* x (+ -1.0 (* x 0.5)))))))
eps_m)
2.0)
(/
(*
x
(+
(+ eps_m (/ -1.0 eps_m))
(- (/ (+ 1.0 (* 2.0 (/ eps_m x))) eps_m) eps_m)))
2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.008) {
tmp = exp(-x) * (x + 1.0);
} else if (eps_m <= 2.6e+264) {
tmp = ((eps_m * (2.0 * ((x + 1.0) * (1.0 + (x * (-1.0 + (x * 0.5))))))) / eps_m) / 2.0;
} else {
tmp = (x * ((eps_m + (-1.0 / eps_m)) + (((1.0 + (2.0 * (eps_m / x))) / 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 <= 0.008d0) then
tmp = exp(-x) * (x + 1.0d0)
else if (eps_m <= 2.6d+264) then
tmp = ((eps_m * (2.0d0 * ((x + 1.0d0) * (1.0d0 + (x * ((-1.0d0) + (x * 0.5d0))))))) / eps_m) / 2.0d0
else
tmp = (x * ((eps_m + ((-1.0d0) / eps_m)) + (((1.0d0 + (2.0d0 * (eps_m / x))) / 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 <= 0.008) {
tmp = Math.exp(-x) * (x + 1.0);
} else if (eps_m <= 2.6e+264) {
tmp = ((eps_m * (2.0 * ((x + 1.0) * (1.0 + (x * (-1.0 + (x * 0.5))))))) / eps_m) / 2.0;
} else {
tmp = (x * ((eps_m + (-1.0 / eps_m)) + (((1.0 + (2.0 * (eps_m / x))) / eps_m) - eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 0.008: tmp = math.exp(-x) * (x + 1.0) elif eps_m <= 2.6e+264: tmp = ((eps_m * (2.0 * ((x + 1.0) * (1.0 + (x * (-1.0 + (x * 0.5))))))) / eps_m) / 2.0 else: tmp = (x * ((eps_m + (-1.0 / eps_m)) + (((1.0 + (2.0 * (eps_m / x))) / eps_m) - eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 0.008) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); elseif (eps_m <= 2.6e+264) tmp = Float64(Float64(Float64(eps_m * Float64(2.0 * Float64(Float64(x + 1.0) * Float64(1.0 + Float64(x * Float64(-1.0 + Float64(x * 0.5))))))) / eps_m) / 2.0); else tmp = Float64(Float64(x * Float64(Float64(eps_m + Float64(-1.0 / eps_m)) + Float64(Float64(Float64(1.0 + Float64(2.0 * Float64(eps_m / x))) / 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 <= 0.008) tmp = exp(-x) * (x + 1.0); elseif (eps_m <= 2.6e+264) tmp = ((eps_m * (2.0 * ((x + 1.0) * (1.0 + (x * (-1.0 + (x * 0.5))))))) / eps_m) / 2.0; else tmp = (x * ((eps_m + (-1.0 / eps_m)) + (((1.0 + (2.0 * (eps_m / x))) / 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, 0.008], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps$95$m, 2.6e+264], N[(N[(N[(eps$95$m * N[(2.0 * N[(N[(x + 1.0), $MachinePrecision] * N[(1.0 + N[(x * N[(-1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * N[(N[(eps$95$m + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(1.0 + N[(2.0 * N[(eps$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $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 0.008:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{elif}\;eps\_m \leq 2.6 \cdot 10^{+264}:\\
\;\;\;\;\frac{\frac{eps\_m \cdot \left(2 \cdot \left(\left(x + 1\right) \cdot \left(1 + x \cdot \left(-1 + x \cdot 0.5\right)\right)\right)\right)}{eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(\left(eps\_m + \frac{-1}{eps\_m}\right) + \left(\frac{1 + 2 \cdot \frac{eps\_m}{x}}{eps\_m} - eps\_m\right)\right)}{2}\\
\end{array}
\end{array}
if eps < 0.0080000000000000002Initial program 68.4%
Simplified61.4%
Taylor expanded in eps around 0 34.9%
associate-+r+67.4%
mul-1-neg67.4%
sub-neg67.4%
+-inverses67.4%
distribute-lft-out67.4%
distribute-rgt1-in67.4%
mul-1-neg67.4%
Simplified67.4%
Taylor expanded in eps around 0 67.4%
if 0.0080000000000000002 < eps < 2.6e264Initial program 100.0%
Simplified70.7%
Taylor expanded in eps around 0 34.2%
associate-+r+34.2%
mul-1-neg34.2%
sub-neg34.2%
+-inverses34.2%
distribute-lft-out34.2%
distribute-rgt1-in34.2%
mul-1-neg34.2%
Simplified34.2%
Taylor expanded in x around 0 57.6%
if 2.6e264 < eps Initial program 100.0%
Simplified85.1%
Taylor expanded in x around 0 3.1%
Taylor expanded in x around inf 1.6%
associate--l+1.6%
sub-neg1.6%
metadata-eval1.6%
*-commutative1.6%
distribute-lft-in1.6%
*-rgt-identity1.6%
*-commutative1.6%
distribute-rgt-in1.6%
rgt-mult-inverse1.6%
neg-mul-11.6%
sub-neg1.6%
associate-+r+1.6%
sub-neg1.6%
associate-+r+1.6%
metadata-eval1.6%
distribute-neg-frac1.6%
metadata-eval1.6%
Simplified1.6%
Taylor expanded in eps around 0 47.0%
Final simplification63.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 21.5) (/ (- 2.0 (* x eps_m)) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 21.5) {
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 <= 21.5d0) 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 <= 21.5) {
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 <= 21.5: 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 <= 21.5) 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 <= 21.5) 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, 21.5], 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 21.5:\\
\;\;\;\;\frac{2 - x \cdot eps\_m}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 21.5Initial program 68.8%
Simplified58.3%
Taylor expanded in x around 0 56.7%
Taylor expanded in eps around 0 61.3%
Taylor expanded in x around 0 61.3%
associate-*r*61.3%
neg-mul-161.3%
Simplified61.3%
if 21.5 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 52.7%
div-sub52.7%
mul-1-neg52.7%
rec-exp52.7%
+-inverses52.7%
metadata-eval52.7%
Simplified52.7%
Final simplification58.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 2.0) (/ (- 2.0 x) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2.0) {
tmp = (2.0 - 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 <= 2.0d0) then
tmp = (2.0d0 - 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 <= 2.0) {
tmp = (2.0 - x) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 2.0: tmp = (2.0 - x) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2.0) tmp = Float64(Float64(2.0 - 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 <= 2.0) tmp = (2.0 - 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, 2.0], N[(N[(2.0 - x), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\frac{2 - x}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2Initial program 68.8%
Simplified58.3%
Taylor expanded in eps around inf 99.2%
Taylor expanded in eps around inf 99.3%
*-commutative99.3%
Simplified99.3%
Taylor expanded in x around 0 56.9%
mul-1-neg56.9%
unsub-neg56.9%
Simplified56.9%
if 2 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 52.7%
div-sub52.7%
mul-1-neg52.7%
rec-exp52.7%
+-inverses52.7%
metadata-eval52.7%
Simplified52.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 550.0) 1.0 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 550.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 <= 550.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 <= 550.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 550.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 550.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 <= 550.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, 550.0], 1.0, 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 550:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 550Initial program 69.0%
Simplified69.0%
Taylor expanded in x around 0 56.4%
if 550 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 53.3%
div-sub53.3%
mul-1-neg53.3%
rec-exp53.3%
+-inverses53.3%
metadata-eval53.3%
Simplified53.3%
Final simplification55.5%
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 78.4%
Simplified71.2%
Taylor expanded in eps around 0 17.7%
div-sub17.7%
mul-1-neg17.7%
rec-exp17.7%
+-inverses17.9%
metadata-eval17.9%
Simplified17.9%
herbie shell --seed 2024157
(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))