
(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 9 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
(let* ((t_0 (exp (* x (+ -1.0 eps_m)))))
(if (<= x 3.8)
(/ (+ t_0 (exp (* x (- eps_m)))) 2.0)
(/ (+ t_0 (exp (- x))) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp((x * (-1.0 + eps_m)));
double tmp;
if (x <= 3.8) {
tmp = (t_0 + exp((x * -eps_m))) / 2.0;
} else {
tmp = (t_0 + exp(-x)) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = exp((x * ((-1.0d0) + eps_m)))
if (x <= 3.8d0) then
tmp = (t_0 + exp((x * -eps_m))) / 2.0d0
else
tmp = (t_0 + exp(-x)) / 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 * (-1.0 + eps_m)));
double tmp;
if (x <= 3.8) {
tmp = (t_0 + Math.exp((x * -eps_m))) / 2.0;
} else {
tmp = (t_0 + Math.exp(-x)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp((x * (-1.0 + eps_m))) tmp = 0 if x <= 3.8: tmp = (t_0 + math.exp((x * -eps_m))) / 2.0 else: tmp = (t_0 + math.exp(-x)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(x * Float64(-1.0 + eps_m))) tmp = 0.0 if (x <= 3.8) tmp = Float64(Float64(t_0 + exp(Float64(x * Float64(-eps_m)))) / 2.0); else tmp = Float64(Float64(t_0 + exp(Float64(-x))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp((x * (-1.0 + eps_m))); tmp = 0.0; if (x <= 3.8) tmp = (t_0 + exp((x * -eps_m))) / 2.0; else tmp = (t_0 + exp(-x)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 3.8], N[(N[(t$95$0 + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(-1 + eps\_m\right)}\\
\mathbf{if}\;x \leq 3.8:\\
\;\;\;\;\frac{t\_0 + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 + e^{-x}}{2}\\
\end{array}
\end{array}
if x < 3.7999999999999998Initial program 62.8%
Simplified46.9%
Taylor expanded in eps around inf 99.1%
Taylor expanded in eps around inf 99.1%
*-commutative99.1%
Simplified99.1%
Taylor expanded in x around inf 99.1%
associate-*r*99.1%
mul-1-neg99.1%
Simplified99.1%
if 3.7999999999999998 < x Initial program 98.5%
Simplified98.6%
Taylor expanded in eps around inf 98.7%
Taylor expanded in eps around 0 70.4%
Final simplification91.7%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -1.15e-282)
(/ (+ (exp (* x (- eps_m))) t_0) 2.0)
(/ (+ (exp (* x (+ -1.0 eps_m))) t_0) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (x <= -1.15e-282) {
tmp = (exp((x * -eps_m)) + t_0) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps_m))) + t_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) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (x <= (-1.15d-282)) then
tmp = (exp((x * -eps_m)) + t_0) / 2.0d0
else
tmp = (exp((x * ((-1.0d0) + eps_m))) + t_0) / 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 (x <= -1.15e-282) {
tmp = (Math.exp((x * -eps_m)) + t_0) / 2.0;
} else {
tmp = (Math.exp((x * (-1.0 + eps_m))) + t_0) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp(-x) tmp = 0 if x <= -1.15e-282: tmp = (math.exp((x * -eps_m)) + t_0) / 2.0 else: tmp = (math.exp((x * (-1.0 + eps_m))) + t_0) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -1.15e-282) tmp = Float64(Float64(exp(Float64(x * Float64(-eps_m))) + t_0) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) + t_0) / 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 (x <= -1.15e-282) tmp = (exp((x * -eps_m)) + t_0) / 2.0; else tmp = (exp((x * (-1.0 + eps_m))) + t_0) / 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[x, -1.15e-282], N[(N[(N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{-282}:\\
\;\;\;\;\frac{e^{x \cdot \left(-eps\_m\right)} + t\_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps\_m\right)} + t\_0}{2}\\
\end{array}
\end{array}
if x < -1.1499999999999999e-282Initial program 65.7%
Simplified55.3%
Taylor expanded in eps around inf 99.1%
Taylor expanded in eps around inf 99.1%
*-commutative99.1%
Simplified99.1%
Taylor expanded in x around inf 99.1%
associate-*r*99.1%
mul-1-neg99.1%
Simplified99.1%
Taylor expanded in eps around 0 85.6%
neg-mul-185.6%
Simplified85.6%
if -1.1499999999999999e-282 < x Initial program 78.2%
Simplified65.0%
Taylor expanded in eps around inf 98.9%
Taylor expanded in eps around 0 81.2%
Final simplification83.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ (exp (* x (- -1.0 eps_m))) (exp (* x (+ -1.0 eps_m)))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp((x * (-1.0 - eps_m))) + 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 * ((-1.0d0) - eps_m))) + 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 * (-1.0 - eps_m))) + Math.exp((x * (-1.0 + eps_m)))) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (math.exp((x * (-1.0 - eps_m))) + 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(-1.0 - eps_m))) + exp(Float64(x * Float64(-1.0 + eps_m)))) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (exp((x * (-1.0 - eps_m))) + 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[(-1.0 - eps$95$m), $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(-1 - eps\_m\right)} + e^{x \cdot \left(-1 + eps\_m\right)}}{2}
\end{array}
Initial program 72.0%
Simplified60.2%
Taylor expanded in eps around inf 99.0%
Final simplification99.0%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 1.0)
(/ (/ 2.0 (exp x)) 2.0)
(if (or (<= eps_m 6.8e+192) (not (<= eps_m 8.6e+252)))
(/ (+ 2.0 (* x (* x (* eps_m eps_m)))) 2.0)
(/ (+ 2.0 (pow (* x eps_m) 2.0)) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.0) {
tmp = (2.0 / exp(x)) / 2.0;
} else if ((eps_m <= 6.8e+192) || !(eps_m <= 8.6e+252)) {
tmp = (2.0 + (x * (x * (eps_m * eps_m)))) / 2.0;
} else {
tmp = (2.0 + pow((x * eps_m), 2.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 (eps_m <= 1.0d0) then
tmp = (2.0d0 / exp(x)) / 2.0d0
else if ((eps_m <= 6.8d+192) .or. (.not. (eps_m <= 8.6d+252))) then
tmp = (2.0d0 + (x * (x * (eps_m * eps_m)))) / 2.0d0
else
tmp = (2.0d0 + ((x * eps_m) ** 2.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 (eps_m <= 1.0) {
tmp = (2.0 / Math.exp(x)) / 2.0;
} else if ((eps_m <= 6.8e+192) || !(eps_m <= 8.6e+252)) {
tmp = (2.0 + (x * (x * (eps_m * eps_m)))) / 2.0;
} else {
tmp = (2.0 + Math.pow((x * eps_m), 2.0)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.0: tmp = (2.0 / math.exp(x)) / 2.0 elif (eps_m <= 6.8e+192) or not (eps_m <= 8.6e+252): tmp = (2.0 + (x * (x * (eps_m * eps_m)))) / 2.0 else: tmp = (2.0 + math.pow((x * eps_m), 2.0)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.0) tmp = Float64(Float64(2.0 / exp(x)) / 2.0); elseif ((eps_m <= 6.8e+192) || !(eps_m <= 8.6e+252)) tmp = Float64(Float64(2.0 + Float64(x * Float64(x * Float64(eps_m * eps_m)))) / 2.0); else tmp = Float64(Float64(2.0 + (Float64(x * eps_m) ^ 2.0)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 1.0) tmp = (2.0 / exp(x)) / 2.0; elseif ((eps_m <= 6.8e+192) || ~((eps_m <= 8.6e+252))) tmp = (2.0 + (x * (x * (eps_m * eps_m)))) / 2.0; else tmp = (2.0 + ((x * eps_m) ^ 2.0)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.0], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[eps$95$m, 6.8e+192], N[Not[LessEqual[eps$95$m, 8.6e+252]], $MachinePrecision]], N[(N[(2.0 + N[(x * N[(x * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[Power[N[(x * eps$95$m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1:\\
\;\;\;\;\frac{\frac{2}{e^{x}}}{2}\\
\mathbf{elif}\;eps\_m \leq 6.8 \cdot 10^{+192} \lor \neg \left(eps\_m \leq 8.6 \cdot 10^{+252}\right):\\
\;\;\;\;\frac{2 + x \cdot \left(x \cdot \left(eps\_m \cdot eps\_m\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + {\left(x \cdot eps\_m\right)}^{2}}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 61.4%
Simplified52.9%
Taylor expanded in eps around inf 98.6%
Taylor expanded in eps around 0 77.8%
neg-mul-177.8%
exp-neg77.8%
associate-*r/77.8%
metadata-eval77.8%
Simplified77.8%
if 1 < eps < 6.79999999999999992e192 or 8.6000000000000004e252 < eps Initial program 100.0%
Simplified79.5%
Taylor expanded in x around 0 76.6%
Taylor expanded in eps around inf 76.6%
unpow276.6%
Applied egg-rr76.6%
if 6.79999999999999992e192 < eps < 8.6000000000000004e252Initial program 100.0%
Simplified79.0%
Taylor expanded in x around 0 77.2%
Taylor expanded in eps around inf 77.2%
Taylor expanded in x around 0 76.5%
*-commutative76.5%
unpow276.5%
unpow276.5%
swap-sqr94.5%
unpow294.5%
Simplified94.5%
Final simplification78.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 1.3) (/ (/ 2.0 (exp x)) 2.0) (/ (+ 2.0 (* x (* x (* eps_m eps_m)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.3) {
tmp = (2.0 / exp(x)) / 2.0;
} else {
tmp = (2.0 + (x * (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 <= 1.3d0) then
tmp = (2.0d0 / exp(x)) / 2.0d0
else
tmp = (2.0d0 + (x * (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 <= 1.3) {
tmp = (2.0 / Math.exp(x)) / 2.0;
} else {
tmp = (2.0 + (x * (x * (eps_m * eps_m)))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.3: tmp = (2.0 / math.exp(x)) / 2.0 else: tmp = (2.0 + (x * (x * (eps_m * eps_m)))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.3) tmp = Float64(Float64(2.0 / exp(x)) / 2.0); else tmp = Float64(Float64(2.0 + Float64(x * Float64(x * Float64(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 <= 1.3) tmp = (2.0 / exp(x)) / 2.0; else tmp = (2.0 + (x * (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, 1.3], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(x * N[(x * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1.3:\\
\;\;\;\;\frac{\frac{2}{e^{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + x \cdot \left(x \cdot \left(eps\_m \cdot eps\_m\right)\right)}{2}\\
\end{array}
\end{array}
if eps < 1.30000000000000004Initial program 61.4%
Simplified52.9%
Taylor expanded in eps around inf 98.6%
Taylor expanded in eps around 0 77.8%
neg-mul-177.8%
exp-neg77.8%
associate-*r/77.8%
metadata-eval77.8%
Simplified77.8%
if 1.30000000000000004 < eps Initial program 100.0%
Simplified79.4%
Taylor expanded in x around 0 76.7%
Taylor expanded in eps around inf 76.7%
unpow276.7%
Applied egg-rr76.7%
Final simplification77.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 210.0) 1.0 (/ (+ (* x (+ -1.0 eps_m)) 2.0) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 210.0) {
tmp = 1.0;
} else {
tmp = ((x * (-1.0 + eps_m)) + 2.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 <= 210.0d0) then
tmp = 1.0d0
else
tmp = ((x * ((-1.0d0) + eps_m)) + 2.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 <= 210.0) {
tmp = 1.0;
} else {
tmp = ((x * (-1.0 + eps_m)) + 2.0) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 210.0: tmp = 1.0 else: tmp = ((x * (-1.0 + eps_m)) + 2.0) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 210.0) tmp = 1.0; else tmp = Float64(Float64(Float64(x * Float64(-1.0 + eps_m)) + 2.0) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 210.0) tmp = 1.0; else tmp = ((x * (-1.0 + eps_m)) + 2.0) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 210.0], 1.0, N[(N[(N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 210:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(-1 + eps\_m\right) + 2}{2}\\
\end{array}
\end{array}
if x < 210Initial program 62.4%
Simplified62.4%
Taylor expanded in x around 0 60.4%
if 210 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 62.5%
*-commutative62.5%
Simplified62.5%
Taylor expanded in x around 0 25.5%
Taylor expanded in x around 0 13.9%
Final simplification48.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ 2.0 (* x (* x (* eps_m eps_m)))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (2.0 + (x * (x * (eps_m * 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 = (2.0d0 + (x * (x * (eps_m * eps_m)))) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (2.0 + (x * (x * (eps_m * eps_m)))) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (2.0 + (x * (x * (eps_m * eps_m)))) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(2.0 + Float64(x * Float64(x * Float64(eps_m * eps_m)))) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (2.0 + (x * (x * (eps_m * eps_m)))) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(2.0 + N[(x * N[(x * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{2 + x \cdot \left(x \cdot \left(eps\_m \cdot eps\_m\right)\right)}{2}
\end{array}
Initial program 72.0%
Simplified60.2%
Taylor expanded in x around 0 77.5%
Taylor expanded in eps around inf 77.9%
unpow277.9%
Applied egg-rr77.9%
Final simplification77.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ 2.0 (* x (- x 2.0))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (2.0 + (x * (x - 2.0))) / 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 = (2.0d0 + (x * (x - 2.0d0))) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (2.0 + (x * (x - 2.0))) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (2.0 + (x * (x - 2.0))) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(2.0 + Float64(x * Float64(x - 2.0))) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (2.0 + (x * (x - 2.0))) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(2.0 + N[(x * N[(x - 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{2 + x \cdot \left(x - 2\right)}{2}
\end{array}
Initial program 72.0%
Simplified60.2%
Taylor expanded in eps around inf 99.0%
Taylor expanded in eps around 0 71.2%
neg-mul-171.2%
exp-neg71.2%
associate-*r/71.2%
metadata-eval71.2%
Simplified71.2%
Taylor expanded in x around 0 60.6%
Final simplification60.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 1.0)
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 1.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = 1.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 1.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return 1.0
eps_m = abs(eps) function code(x, eps_m) return 1.0 end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 1.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := 1.0
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
1
\end{array}
Initial program 72.0%
Simplified72.0%
Taylor expanded in x around 0 45.8%
Final simplification45.8%
herbie shell --seed 2024060
(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))