
(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.0066) (/ (* (exp (- x)) (+ 2.0 (* x 2.0))) 2.0) (/ (* 2.0 (cosh (* x eps_m))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.0066) {
tmp = (exp(-x) * (2.0 + (x * 2.0))) / 2.0;
} else {
tmp = (2.0 * cosh((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.0066d0) then
tmp = (exp(-x) * (2.0d0 + (x * 2.0d0))) / 2.0d0
else
tmp = (2.0d0 * cosh((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.0066) {
tmp = (Math.exp(-x) * (2.0 + (x * 2.0))) / 2.0;
} else {
tmp = (2.0 * Math.cosh((x * eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 0.0066: tmp = (math.exp(-x) * (2.0 + (x * 2.0))) / 2.0 else: tmp = (2.0 * math.cosh((x * eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 0.0066) tmp = Float64(Float64(exp(Float64(-x)) * Float64(2.0 + Float64(x * 2.0))) / 2.0); else tmp = Float64(Float64(2.0 * cosh(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.0066) tmp = (exp(-x) * (2.0 + (x * 2.0))) / 2.0; else tmp = (2.0 * cosh((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.0066], N[(N[(N[Exp[(-x)], $MachinePrecision] * N[(2.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 * N[Cosh[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.0066:\\
\;\;\;\;\frac{e^{-x} \cdot \left(2 + x \cdot 2\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot \cosh \left(x \cdot eps\_m\right)}{2}\\
\end{array}
\end{array}
if eps < 0.0066Initial program 59.1%
Simplified50.8%
Taylor expanded in eps around 0 31.0%
Simplified72.5%
Taylor expanded in eps around 0 72.5%
if 0.0066 < eps Initial program 100.0%
Simplified86.3%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
*-un-lft-identity100.0%
*-commutative100.0%
rec-exp100.0%
cosh-undef100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
Final simplification80.6%
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 71.2%
Simplified65.2%
Taylor expanded in eps around inf 98.5%
Final simplification98.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 760.0)
(/ (* 2.0 (cosh (* x eps_m))) 2.0)
(if (<= x 6.6e+101)
0.0
(if (<= x 2.65e+246) (/ (+ 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 <= 760.0) {
tmp = (2.0 * cosh((x * eps_m))) / 2.0;
} else if (x <= 6.6e+101) {
tmp = 0.0;
} else if (x <= 2.65e+246) {
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 <= 760.0d0) then
tmp = (2.0d0 * cosh((x * eps_m))) / 2.0d0
else if (x <= 6.6d+101) then
tmp = 0.0d0
else if (x <= 2.65d+246) 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 <= 760.0) {
tmp = (2.0 * Math.cosh((x * eps_m))) / 2.0;
} else if (x <= 6.6e+101) {
tmp = 0.0;
} else if (x <= 2.65e+246) {
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 <= 760.0: tmp = (2.0 * math.cosh((x * eps_m))) / 2.0 elif x <= 6.6e+101: tmp = 0.0 elif x <= 2.65e+246: 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 <= 760.0) tmp = Float64(Float64(2.0 * cosh(Float64(x * eps_m))) / 2.0); elseif (x <= 6.6e+101) tmp = 0.0; elseif (x <= 2.65e+246) 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 <= 760.0) tmp = (2.0 * cosh((x * eps_m))) / 2.0; elseif (x <= 6.6e+101) tmp = 0.0; elseif (x <= 2.65e+246) 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, 760.0], N[(N[(2.0 * N[Cosh[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.6e+101], 0.0, If[LessEqual[x, 2.65e+246], 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 760:\\
\;\;\;\;\frac{2 \cdot \cosh \left(x \cdot eps\_m\right)}{2}\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{+101}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 2.65 \cdot 10^{+246}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(eps\_m + -1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 760Initial program 62.6%
Simplified54.8%
Taylor expanded in eps around inf 98.1%
Taylor expanded in eps around inf 98.1%
*-commutative98.1%
Simplified98.1%
Taylor expanded in eps around inf 98.3%
*-un-lft-identity98.3%
*-commutative98.3%
rec-exp98.3%
cosh-undef98.3%
Applied egg-rr98.3%
*-lft-identity98.3%
Simplified98.3%
if 760 < x < 6.60000000000000022e101 or 2.64999999999999988e246 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 77.8%
mul-1-neg77.8%
mul-1-neg77.8%
rec-exp77.8%
sub-neg77.8%
div-sub77.8%
mul-1-neg77.8%
rec-exp77.8%
+-inverses77.8%
Simplified77.8%
if 6.60000000000000022e101 < x < 2.64999999999999988e246Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 37.7%
Final simplification89.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (or (<= x 950.0) (and (not (<= x 2.9e+94)) (<= x 1e+252))) (/ (* 2.0 (cosh (* x eps_m))) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if ((x <= 950.0) || (!(x <= 2.9e+94) && (x <= 1e+252))) {
tmp = (2.0 * cosh((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 <= 950.0d0) .or. (.not. (x <= 2.9d+94)) .and. (x <= 1d+252)) then
tmp = (2.0d0 * cosh((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 <= 950.0) || (!(x <= 2.9e+94) && (x <= 1e+252))) {
tmp = (2.0 * Math.cosh((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 <= 950.0) or (not (x <= 2.9e+94) and (x <= 1e+252)): tmp = (2.0 * math.cosh((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 <= 950.0) || (!(x <= 2.9e+94) && (x <= 1e+252))) tmp = Float64(Float64(2.0 * cosh(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 <= 950.0) || (~((x <= 2.9e+94)) && (x <= 1e+252))) tmp = (2.0 * cosh((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[Or[LessEqual[x, 950.0], And[N[Not[LessEqual[x, 2.9e+94]], $MachinePrecision], LessEqual[x, 1e+252]]], N[(N[(2.0 * N[Cosh[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 950 \lor \neg \left(x \leq 2.9 \cdot 10^{+94}\right) \land x \leq 10^{+252}:\\
\;\;\;\;\frac{2 \cdot \cosh \left(x \cdot eps\_m\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 950 or 2.8999999999999998e94 < x < 1.0000000000000001e252Initial program 67.3%
Simplified60.4%
Taylor expanded in eps around inf 98.3%
Taylor expanded in eps around inf 94.8%
*-commutative94.8%
Simplified94.8%
Taylor expanded in eps around inf 94.2%
*-un-lft-identity94.2%
*-commutative94.2%
rec-exp94.2%
cosh-undef94.2%
Applied egg-rr94.2%
*-lft-identity94.2%
Simplified94.2%
if 950 < x < 2.8999999999999998e94 or 1.0000000000000001e252 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 77.8%
mul-1-neg77.8%
mul-1-neg77.8%
rec-exp77.8%
sub-neg77.8%
div-sub77.8%
mul-1-neg77.8%
rec-exp77.8%
+-inverses77.8%
Simplified77.8%
Final simplification92.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 2.0) (/ (+ 2.0 (* x (- -1.0 eps_m))) 2.0) (if (<= x 1.02e+95) 0.0 (if (<= x 1e+253) (/ (* 2.0 (exp 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 * (-1.0 - eps_m))) / 2.0;
} else if (x <= 1.02e+95) {
tmp = 0.0;
} else if (x <= 1e+253) {
tmp = (2.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 <= 2.0d0) then
tmp = (2.0d0 + (x * ((-1.0d0) - eps_m))) / 2.0d0
else if (x <= 1.02d+95) then
tmp = 0.0d0
else if (x <= 1d+253) then
tmp = (2.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 <= 2.0) {
tmp = (2.0 + (x * (-1.0 - eps_m))) / 2.0;
} else if (x <= 1.02e+95) {
tmp = 0.0;
} else if (x <= 1e+253) {
tmp = (2.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 <= 2.0: tmp = (2.0 + (x * (-1.0 - eps_m))) / 2.0 elif x <= 1.02e+95: tmp = 0.0 elif x <= 1e+253: tmp = (2.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 <= 2.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(-1.0 - eps_m))) / 2.0); elseif (x <= 1.02e+95) tmp = 0.0; elseif (x <= 1e+253) tmp = Float64(Float64(2.0 * exp(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 * (-1.0 - eps_m))) / 2.0; elseif (x <= 1.02e+95) tmp = 0.0; elseif (x <= 1e+253) tmp = (2.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, 2.0], N[(N[(2.0 + N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.02e+95], 0.0, If[LessEqual[x, 1e+253], N[(N[(2.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 2:\\
\;\;\;\;\frac{2 + x \cdot \left(-1 - eps\_m\right)}{2}\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{+95}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 10^{+253}:\\
\;\;\;\;\frac{2 \cdot e^{x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2Initial program 62.9%
Simplified55.1%
Taylor expanded in eps around inf 98.5%
Taylor expanded in eps around inf 98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around 0 76.4%
Taylor expanded in x around 0 62.6%
associate-*r*62.6%
neg-mul-162.6%
Simplified62.6%
if 2 < x < 1.0200000000000001e95 or 9.9999999999999994e252 < x Initial program 97.0%
Simplified97.0%
Taylor expanded in eps around 0 75.5%
mul-1-neg75.5%
mul-1-neg75.5%
rec-exp75.4%
sub-neg75.4%
div-sub75.4%
mul-1-neg75.4%
rec-exp75.5%
+-inverses75.5%
Simplified75.5%
if 1.0200000000000001e95 < x < 9.9999999999999994e252Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 36.7%
associate--r+36.7%
associate-*r*36.7%
mul-1-neg36.7%
cancel-sign-sub36.7%
distribute-rgt1-in36.7%
distribute-rgt-out--36.7%
mul-1-neg36.7%
mul-1-neg36.7%
Simplified36.7%
add-sqr-sqrt36.7%
sqrt-unprod3.8%
sqr-neg3.8%
sqrt-unprod0.0%
add-sqr-sqrt36.7%
cancel-sign-sub-inv36.7%
add-sqr-sqrt0.0%
sqrt-unprod64.8%
sqr-neg64.8%
sqrt-unprod64.8%
add-sqr-sqrt64.8%
associate--l+64.8%
metadata-eval64.8%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
sqr-neg0.0%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
Applied egg-rr0.0%
*-commutative0.0%
distribute-rgt-out--0.0%
*-commutative0.0%
sub-neg0.0%
+-commutative0.0%
associate-+l+64.8%
neg-mul-164.8%
distribute-rgt1-in64.8%
metadata-eval64.8%
mul0-lft64.8%
metadata-eval64.8%
Simplified64.8%
Final simplification64.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 480.0) (/ (+ 1.0 (exp (- x))) 2.0) (if (<= x 2e+98) 0.0 (if (<= x 1e+252) (/ (* 2.0 (exp x)) 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)) / 2.0;
} else if (x <= 2e+98) {
tmp = 0.0;
} else if (x <= 1e+252) {
tmp = (2.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 <= 480.0d0) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else if (x <= 2d+98) then
tmp = 0.0d0
else if (x <= 1d+252) then
tmp = (2.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 <= 480.0) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if (x <= 2e+98) {
tmp = 0.0;
} else if (x <= 1e+252) {
tmp = (2.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 <= 480.0: tmp = (1.0 + math.exp(-x)) / 2.0 elif x <= 2e+98: tmp = 0.0 elif x <= 1e+252: tmp = (2.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 <= 480.0) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif (x <= 2e+98) tmp = 0.0; elseif (x <= 1e+252) tmp = Float64(Float64(2.0 * exp(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 <= 480.0) tmp = (1.0 + exp(-x)) / 2.0; elseif (x <= 2e+98) tmp = 0.0; elseif (x <= 1e+252) tmp = (2.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, 480.0], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2e+98], 0.0, If[LessEqual[x, 1e+252], N[(N[(2.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 480:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{+98}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 10^{+252}:\\
\;\;\;\;\frac{2 \cdot e^{x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 480Initial program 62.6%
Simplified54.8%
Taylor expanded in eps around inf 98.1%
Taylor expanded in eps around inf 98.1%
*-commutative98.1%
Simplified98.1%
Taylor expanded in x around 0 76.0%
Taylor expanded in eps around 0 83.0%
rec-exp83.0%
Simplified83.0%
if 480 < x < 2e98 or 1.0000000000000001e252 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 77.8%
mul-1-neg77.8%
mul-1-neg77.8%
rec-exp77.8%
sub-neg77.8%
div-sub77.8%
mul-1-neg77.8%
rec-exp77.8%
+-inverses77.8%
Simplified77.8%
if 2e98 < x < 1.0000000000000001e252Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 36.7%
associate--r+36.7%
associate-*r*36.7%
mul-1-neg36.7%
cancel-sign-sub36.7%
distribute-rgt1-in36.7%
distribute-rgt-out--36.7%
mul-1-neg36.7%
mul-1-neg36.7%
Simplified36.7%
add-sqr-sqrt36.7%
sqrt-unprod3.8%
sqr-neg3.8%
sqrt-unprod0.0%
add-sqr-sqrt36.7%
cancel-sign-sub-inv36.7%
add-sqr-sqrt0.0%
sqrt-unprod64.8%
sqr-neg64.8%
sqrt-unprod64.8%
add-sqr-sqrt64.8%
associate--l+64.8%
metadata-eval64.8%
add-sqr-sqrt0.0%
sqrt-unprod0.0%
sqr-neg0.0%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
Applied egg-rr0.0%
*-commutative0.0%
distribute-rgt-out--0.0%
*-commutative0.0%
sub-neg0.0%
+-commutative0.0%
associate-+l+64.8%
neg-mul-164.8%
distribute-rgt1-in64.8%
metadata-eval64.8%
mul0-lft64.8%
metadata-eval64.8%
Simplified64.8%
Final simplification80.4%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 2.0)
(/ (+ 2.0 (* x (- -1.0 eps_m))) 2.0)
(if (<= x 7.2e+97)
0.0
(if (<= x 9e+247)
(/ (/ (- (* eps_m (- (* x eps_m) -2.0)) x) eps_m) 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 * (-1.0 - eps_m))) / 2.0;
} else if (x <= 7.2e+97) {
tmp = 0.0;
} else if (x <= 9e+247) {
tmp = (((eps_m * ((x * eps_m) - -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 <= 2.0d0) then
tmp = (2.0d0 + (x * ((-1.0d0) - eps_m))) / 2.0d0
else if (x <= 7.2d+97) then
tmp = 0.0d0
else if (x <= 9d+247) then
tmp = (((eps_m * ((x * eps_m) - (-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 <= 2.0) {
tmp = (2.0 + (x * (-1.0 - eps_m))) / 2.0;
} else if (x <= 7.2e+97) {
tmp = 0.0;
} else if (x <= 9e+247) {
tmp = (((eps_m * ((x * eps_m) - -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 <= 2.0: tmp = (2.0 + (x * (-1.0 - eps_m))) / 2.0 elif x <= 7.2e+97: tmp = 0.0 elif x <= 9e+247: tmp = (((eps_m * ((x * eps_m) - -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 <= 2.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(-1.0 - eps_m))) / 2.0); elseif (x <= 7.2e+97) tmp = 0.0; elseif (x <= 9e+247) tmp = Float64(Float64(Float64(Float64(eps_m * Float64(Float64(x * eps_m) - -2.0)) - 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 <= 2.0) tmp = (2.0 + (x * (-1.0 - eps_m))) / 2.0; elseif (x <= 7.2e+97) tmp = 0.0; elseif (x <= 9e+247) tmp = (((eps_m * ((x * eps_m) - -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, 2.0], N[(N[(2.0 + N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 7.2e+97], 0.0, If[LessEqual[x, 9e+247], N[(N[(N[(N[(eps$95$m * N[(N[(x * eps$95$m), $MachinePrecision] - -2.0), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / eps$95$m), $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 \cdot \left(-1 - eps\_m\right)}{2}\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{+97}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+247}:\\
\;\;\;\;\frac{\frac{eps\_m \cdot \left(x \cdot eps\_m - -2\right) - x}{eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2Initial program 62.9%
Simplified55.1%
Taylor expanded in eps around inf 98.5%
Taylor expanded in eps around inf 98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around 0 76.4%
Taylor expanded in x around 0 62.6%
associate-*r*62.6%
neg-mul-162.6%
Simplified62.6%
if 2 < x < 7.19999999999999932e97 or 9.00000000000000004e247 < x Initial program 97.0%
Simplified97.0%
Taylor expanded in eps around 0 75.5%
mul-1-neg75.5%
mul-1-neg75.5%
rec-exp75.4%
sub-neg75.4%
div-sub75.4%
mul-1-neg75.4%
rec-exp75.5%
+-inverses75.5%
Simplified75.5%
if 7.19999999999999932e97 < x < 9.00000000000000004e247Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 37.4%
Taylor expanded in x around 0 19.9%
mul-1-neg19.9%
unsub-neg19.9%
associate-*r*19.9%
distribute-rgt-in19.9%
*-lft-identity19.9%
associate-*l/19.9%
*-lft-identity19.9%
Simplified19.9%
Taylor expanded in eps around 0 29.6%
distribute-rgt1-in29.6%
metadata-eval29.6%
*-commutative29.6%
mul0-lft29.6%
associate-+r-29.6%
mul0-lft29.6%
*-commutative29.6%
Simplified29.6%
+-commutative29.6%
associate-+l-29.6%
mul0-lft29.6%
metadata-eval29.6%
Applied egg-rr29.6%
Final simplification60.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 2.0) (/ (+ 2.0 (* x (- -1.0 eps_m))) 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 * (-1.0 - 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 <= 2.0d0) then
tmp = (2.0d0 + (x * ((-1.0d0) - 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 <= 2.0) {
tmp = (2.0 + (x * (-1.0 - eps_m))) / 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 * (-1.0 - eps_m))) / 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 + Float64(x * Float64(-1.0 - 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 <= 2.0) tmp = (2.0 + (x * (-1.0 - 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, 2.0], N[(N[(2.0 + N[(x * N[(-1.0 - 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 2:\\
\;\;\;\;\frac{2 + x \cdot \left(-1 - eps\_m\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2Initial program 62.9%
Simplified55.1%
Taylor expanded in eps around inf 98.5%
Taylor expanded in eps around inf 98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in x around 0 76.4%
Taylor expanded in x around 0 62.6%
associate-*r*62.6%
neg-mul-162.6%
Simplified62.6%
if 2 < x Initial program 98.4%
Simplified98.4%
Taylor expanded in eps around 0 57.4%
mul-1-neg57.4%
mul-1-neg57.4%
rec-exp57.3%
sub-neg57.3%
div-sub57.3%
mul-1-neg57.3%
rec-exp57.4%
+-inverses57.4%
Simplified57.4%
Final simplification61.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -1.0) (/ (* x eps_m) (- 2.0)) (if (<= x 560.0) 1.0 0.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.0) {
tmp = (x * eps_m) / -2.0;
} else if (x <= 560.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 <= (-1.0d0)) then
tmp = (x * eps_m) / -2.0d0
else if (x <= 560.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 <= -1.0) {
tmp = (x * eps_m) / -2.0;
} else if (x <= 560.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1.0: tmp = (x * eps_m) / -2.0 elif x <= 560.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(x * eps_m) / Float64(-2.0)); elseif (x <= 560.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 <= -1.0) tmp = (x * eps_m) / -2.0; elseif (x <= 560.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, -1.0], N[(N[(x * eps$95$m), $MachinePrecision] / (-2.0)), $MachinePrecision], If[LessEqual[x, 560.0], 1.0, 0.0]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x \cdot eps\_m}{-2}\\
\mathbf{elif}\;x \leq 560:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1Initial program 97.9%
Simplified97.9%
Taylor expanded in x around 0 47.5%
Taylor expanded in eps around inf 14.2%
associate-*r*14.2%
mul-1-neg14.2%
Simplified14.2%
if -1 < x < 560Initial program 51.2%
Simplified51.2%
Taylor expanded in x around 0 78.5%
if 560 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 58.3%
mul-1-neg58.3%
mul-1-neg58.3%
rec-exp58.3%
sub-neg58.3%
div-sub58.3%
mul-1-neg58.3%
rec-exp58.3%
+-inverses58.3%
Simplified58.3%
Final simplification61.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 520.0) 1.0 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 520.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 <= 520.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 <= 520.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 520.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 520.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 <= 520.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, 520.0], 1.0, 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 520:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 520Initial program 62.6%
Simplified62.6%
Taylor expanded in x around 0 60.1%
if 520 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 58.3%
mul-1-neg58.3%
mul-1-neg58.3%
rec-exp58.3%
sub-neg58.3%
div-sub58.3%
mul-1-neg58.3%
rec-exp58.3%
+-inverses58.3%
Simplified58.3%
Final simplification59.7%
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.2%
Simplified56.8%
Taylor expanded in eps around 0 15.1%
mul-1-neg15.1%
mul-1-neg15.1%
rec-exp15.1%
sub-neg15.1%
div-sub15.1%
mul-1-neg15.1%
rec-exp15.1%
+-inverses15.4%
Simplified15.4%
Final simplification15.4%
herbie shell --seed 2024077
(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))