
(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 8 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 1.0) (/ (* 2.0 (exp (- x))) 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 <= 1.0) {
tmp = (2.0 * exp(-x)) / 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 <= 1.0d0) then
tmp = (2.0d0 * exp(-x)) / 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 <= 1.0) {
tmp = (2.0 * Math.exp(-x)) / 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 <= 1.0: tmp = (2.0 * math.exp(-x)) / 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 <= 1.0) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 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 <= 1.0) tmp = (2.0 * exp(-x)) / 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, 1.0], N[(N[(2.0 * N[Exp[(-x)], $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 1:\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot \cosh \left(x \cdot eps\_m\right)}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 62.6%
Simplified56.3%
Taylor expanded in eps around inf 99.5%
Taylor expanded in eps around 0 79.6%
neg-mul-179.6%
Simplified79.6%
if 1 < eps Initial program 100.0%
Simplified82.8%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
+-commutative100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
cosh-undef100.0%
Applied egg-rr100.0%
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.4%
Simplified63.3%
Taylor expanded in eps around inf 99.6%
Final simplification99.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 46.0)
(/ (* 2.0 (exp (- x))) 2.0)
(if (<= eps_m 2.2e+115)
(/ (+ 1.0 (exp x)) 2.0)
(if (<= eps_m 6.6e+125)
(+ 1.0 (* x (- (* x (+ 0.25 (* x -0.08333333333333333))) 0.5)))
(/ (+ 2.0 (/ (+ x (* eps_m (* x (+ eps_m -2.0)))) eps_m)) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 46.0) {
tmp = (2.0 * exp(-x)) / 2.0;
} else if (eps_m <= 2.2e+115) {
tmp = (1.0 + exp(x)) / 2.0;
} else if (eps_m <= 6.6e+125) {
tmp = 1.0 + (x * ((x * (0.25 + (x * -0.08333333333333333))) - 0.5));
} else {
tmp = (2.0 + ((x + (eps_m * (x * (eps_m + -2.0)))) / 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 <= 46.0d0) then
tmp = (2.0d0 * exp(-x)) / 2.0d0
else if (eps_m <= 2.2d+115) then
tmp = (1.0d0 + exp(x)) / 2.0d0
else if (eps_m <= 6.6d+125) then
tmp = 1.0d0 + (x * ((x * (0.25d0 + (x * (-0.08333333333333333d0)))) - 0.5d0))
else
tmp = (2.0d0 + ((x + (eps_m * (x * (eps_m + (-2.0d0))))) / 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 <= 46.0) {
tmp = (2.0 * Math.exp(-x)) / 2.0;
} else if (eps_m <= 2.2e+115) {
tmp = (1.0 + Math.exp(x)) / 2.0;
} else if (eps_m <= 6.6e+125) {
tmp = 1.0 + (x * ((x * (0.25 + (x * -0.08333333333333333))) - 0.5));
} else {
tmp = (2.0 + ((x + (eps_m * (x * (eps_m + -2.0)))) / eps_m)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 46.0: tmp = (2.0 * math.exp(-x)) / 2.0 elif eps_m <= 2.2e+115: tmp = (1.0 + math.exp(x)) / 2.0 elif eps_m <= 6.6e+125: tmp = 1.0 + (x * ((x * (0.25 + (x * -0.08333333333333333))) - 0.5)) else: tmp = (2.0 + ((x + (eps_m * (x * (eps_m + -2.0)))) / eps_m)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 46.0) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0); elseif (eps_m <= 2.2e+115) tmp = Float64(Float64(1.0 + exp(x)) / 2.0); elseif (eps_m <= 6.6e+125) tmp = Float64(1.0 + Float64(x * Float64(Float64(x * Float64(0.25 + Float64(x * -0.08333333333333333))) - 0.5))); else tmp = Float64(Float64(2.0 + Float64(Float64(x + Float64(eps_m * Float64(x * Float64(eps_m + -2.0)))) / 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 <= 46.0) tmp = (2.0 * exp(-x)) / 2.0; elseif (eps_m <= 2.2e+115) tmp = (1.0 + exp(x)) / 2.0; elseif (eps_m <= 6.6e+125) tmp = 1.0 + (x * ((x * (0.25 + (x * -0.08333333333333333))) - 0.5)); else tmp = (2.0 + ((x + (eps_m * (x * (eps_m + -2.0)))) / 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, 46.0], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps$95$m, 2.2e+115], N[(N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps$95$m, 6.6e+125], N[(1.0 + N[(x * N[(N[(x * N[(0.25 + N[(x * -0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 + N[(N[(x + N[(eps$95$m * N[(x * N[(eps$95$m + -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 46:\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{elif}\;eps\_m \leq 2.2 \cdot 10^{+115}:\\
\;\;\;\;\frac{1 + e^{x}}{2}\\
\mathbf{elif}\;eps\_m \leq 6.6 \cdot 10^{+125}:\\
\;\;\;\;1 + x \cdot \left(x \cdot \left(0.25 + x \cdot -0.08333333333333333\right) - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \frac{x + eps\_m \cdot \left(x \cdot \left(eps\_m + -2\right)\right)}{eps\_m}}{2}\\
\end{array}
\end{array}
if eps < 46Initial program 62.8%
Simplified56.5%
Taylor expanded in eps around inf 99.5%
Taylor expanded in eps around 0 79.7%
neg-mul-179.7%
Simplified79.7%
if 46 < eps < 2.2e115Initial program 100.0%
Simplified68.6%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
Simplified100.0%
Taylor expanded in eps around 0 54.4%
neg-mul-154.4%
Simplified54.4%
frac-2neg54.4%
distribute-frac-neg54.4%
add-sqr-sqrt35.3%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod64.7%
add-sqr-sqrt82.9%
metadata-eval82.9%
Applied egg-rr82.9%
distribute-neg-frac282.9%
metadata-eval82.9%
Simplified82.9%
if 2.2e115 < eps < 6.60000000000000011e125Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
Simplified100.0%
Taylor expanded in eps around 0 100.0%
neg-mul-1100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
if 6.60000000000000011e125 < eps Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 43.3%
*-commutative43.3%
+-commutative43.3%
distribute-rgt-in43.3%
add-sqr-sqrt33.8%
sqrt-unprod84.9%
sqr-neg84.9%
sqrt-unprod64.3%
add-sqr-sqrt70.7%
*-un-lft-identity70.7%
unsub-neg70.7%
Applied egg-rr70.7%
Taylor expanded in x around 0 41.1%
mul-1-neg41.1%
distribute-rgt-neg-in41.1%
sub-neg41.1%
metadata-eval41.1%
sub-neg41.1%
metadata-eval41.1%
distribute-rgt-neg-in41.1%
+-commutative41.1%
neg-mul-141.1%
+-commutative41.1%
distribute-rgt-in41.1%
metadata-eval41.1%
associate-*l/41.1%
metadata-eval41.1%
Simplified41.1%
Taylor expanded in eps around 0 63.5%
distribute-rgt-out63.5%
Simplified63.5%
Final simplification77.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -5e-82) (+ 1.0 (* x (- (* x (+ 0.25 (* x -0.08333333333333333))) 0.5))) (/ (+ 1.0 (exp x)) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -5e-82) {
tmp = 1.0 + (x * ((x * (0.25 + (x * -0.08333333333333333))) - 0.5));
} else {
tmp = (1.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) :: tmp
if (x <= (-5d-82)) then
tmp = 1.0d0 + (x * ((x * (0.25d0 + (x * (-0.08333333333333333d0)))) - 0.5d0))
else
tmp = (1.0d0 + 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 tmp;
if (x <= -5e-82) {
tmp = 1.0 + (x * ((x * (0.25 + (x * -0.08333333333333333))) - 0.5));
} else {
tmp = (1.0 + Math.exp(x)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -5e-82: tmp = 1.0 + (x * ((x * (0.25 + (x * -0.08333333333333333))) - 0.5)) else: tmp = (1.0 + math.exp(x)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -5e-82) tmp = Float64(1.0 + Float64(x * Float64(Float64(x * Float64(0.25 + Float64(x * -0.08333333333333333))) - 0.5))); else tmp = Float64(Float64(1.0 + exp(x)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -5e-82) tmp = 1.0 + (x * ((x * (0.25 + (x * -0.08333333333333333))) - 0.5)); else tmp = (1.0 + exp(x)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -5e-82], N[(1.0 + N[(x * N[(N[(x * N[(0.25 + N[(x * -0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-82}:\\
\;\;\;\;1 + x \cdot \left(x \cdot \left(0.25 + x \cdot -0.08333333333333333\right) - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x}}{2}\\
\end{array}
\end{array}
if x < -4.9999999999999998e-82Initial program 73.7%
Simplified72.0%
Taylor expanded in eps around inf 98.7%
Taylor expanded in eps around inf 98.8%
associate-*r*98.8%
neg-mul-198.8%
Simplified98.8%
Taylor expanded in eps around 0 88.7%
neg-mul-188.7%
Simplified88.7%
Taylor expanded in x around 0 80.8%
if -4.9999999999999998e-82 < x Initial program 72.0%
Simplified61.2%
Taylor expanded in eps around inf 99.8%
Taylor expanded in eps around inf 84.4%
associate-*r*84.4%
neg-mul-184.4%
Simplified84.4%
Taylor expanded in eps around 0 45.0%
neg-mul-145.0%
Simplified45.0%
frac-2neg45.0%
distribute-frac-neg45.0%
add-sqr-sqrt21.5%
sqrt-unprod66.6%
sqr-neg66.6%
sqrt-unprod45.1%
add-sqr-sqrt66.6%
metadata-eval66.6%
Applied egg-rr66.6%
distribute-neg-frac266.6%
metadata-eval66.6%
Simplified66.6%
Final simplification69.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (or (<= x 4500.0) (not (<= x 3.8e+146))) (+ 1.0 (* x (- (* x 0.25) 0.5))) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if ((x <= 4500.0) || !(x <= 3.8e+146)) {
tmp = 1.0 + (x * ((x * 0.25) - 0.5));
} 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 <= 4500.0d0) .or. (.not. (x <= 3.8d+146))) then
tmp = 1.0d0 + (x * ((x * 0.25d0) - 0.5d0))
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 <= 4500.0) || !(x <= 3.8e+146)) {
tmp = 1.0 + (x * ((x * 0.25) - 0.5));
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if (x <= 4500.0) or not (x <= 3.8e+146): tmp = 1.0 + (x * ((x * 0.25) - 0.5)) else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if ((x <= 4500.0) || !(x <= 3.8e+146)) tmp = Float64(1.0 + Float64(x * Float64(Float64(x * 0.25) - 0.5))); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if ((x <= 4500.0) || ~((x <= 3.8e+146))) tmp = 1.0 + (x * ((x * 0.25) - 0.5)); else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[Or[LessEqual[x, 4500.0], N[Not[LessEqual[x, 3.8e+146]], $MachinePrecision]], N[(1.0 + N[(x * N[(N[(x * 0.25), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4500 \lor \neg \left(x \leq 3.8 \cdot 10^{+146}\right):\\
\;\;\;\;1 + x \cdot \left(x \cdot 0.25 - 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 4500 or 3.79999999999999979e146 < x Initial program 66.6%
Simplified55.6%
Taylor expanded in eps around inf 99.5%
Taylor expanded in eps around inf 94.5%
associate-*r*94.5%
neg-mul-194.5%
Simplified94.5%
Taylor expanded in eps around 0 63.6%
neg-mul-163.6%
Simplified63.6%
Taylor expanded in x around 0 67.8%
if 4500 < x < 3.79999999999999979e146Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 55.3%
Taylor expanded in x around 0 55.3%
Final simplification65.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 2.5) (+ 1.0 (* x (- (* x (+ 0.25 (* x -0.08333333333333333))) 0.5))) (if (<= x 3.8e+146) 0.0 (+ 1.0 (* x (- (* x 0.25) 0.5))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2.5) {
tmp = 1.0 + (x * ((x * (0.25 + (x * -0.08333333333333333))) - 0.5));
} else if (x <= 3.8e+146) {
tmp = 0.0;
} else {
tmp = 1.0 + (x * ((x * 0.25) - 0.5));
}
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.5d0) then
tmp = 1.0d0 + (x * ((x * (0.25d0 + (x * (-0.08333333333333333d0)))) - 0.5d0))
else if (x <= 3.8d+146) then
tmp = 0.0d0
else
tmp = 1.0d0 + (x * ((x * 0.25d0) - 0.5d0))
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.5) {
tmp = 1.0 + (x * ((x * (0.25 + (x * -0.08333333333333333))) - 0.5));
} else if (x <= 3.8e+146) {
tmp = 0.0;
} else {
tmp = 1.0 + (x * ((x * 0.25) - 0.5));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 2.5: tmp = 1.0 + (x * ((x * (0.25 + (x * -0.08333333333333333))) - 0.5)) elif x <= 3.8e+146: tmp = 0.0 else: tmp = 1.0 + (x * ((x * 0.25) - 0.5)) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2.5) tmp = Float64(1.0 + Float64(x * Float64(Float64(x * Float64(0.25 + Float64(x * -0.08333333333333333))) - 0.5))); elseif (x <= 3.8e+146) tmp = 0.0; else tmp = Float64(1.0 + Float64(x * Float64(Float64(x * 0.25) - 0.5))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 2.5) tmp = 1.0 + (x * ((x * (0.25 + (x * -0.08333333333333333))) - 0.5)); elseif (x <= 3.8e+146) tmp = 0.0; else tmp = 1.0 + (x * ((x * 0.25) - 0.5)); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2.5], N[(1.0 + N[(x * N[(N[(x * N[(0.25 + N[(x * -0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.8e+146], 0.0, N[(1.0 + N[(x * N[(N[(x * 0.25), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.5:\\
\;\;\;\;1 + x \cdot \left(x \cdot \left(0.25 + x \cdot -0.08333333333333333\right) - 0.5\right)\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+146}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;1 + x \cdot \left(x \cdot 0.25 - 0.5\right)\\
\end{array}
\end{array}
if x < 2.5Initial program 57.4%
Simplified43.3%
Taylor expanded in eps around inf 99.4%
Taylor expanded in eps around inf 99.4%
associate-*r*99.4%
neg-mul-199.4%
Simplified99.4%
Taylor expanded in eps around 0 80.4%
neg-mul-180.4%
Simplified80.4%
Taylor expanded in x around 0 78.1%
if 2.5 < x < 3.79999999999999979e146Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 54.1%
Taylor expanded in x around 0 54.1%
if 3.79999999999999979e146 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 76.0%
associate-*r*76.0%
neg-mul-176.0%
Simplified76.0%
Taylor expanded in eps around 0 3.1%
neg-mul-13.1%
Simplified3.1%
Taylor expanded in x around 0 54.5%
Final simplification69.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 4500.0) 1.0 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 4500.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 <= 4500.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 <= 4500.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 4500.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 4500.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 <= 4500.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, 4500.0], 1.0, 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4500:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 4500Initial program 57.6%
Simplified43.7%
Taylor expanded in eps around inf 99.4%
Taylor expanded in eps around inf 99.4%
associate-*r*99.4%
neg-mul-199.4%
Simplified99.4%
Taylor expanded in x around 0 63.9%
distribute-rgt1-in63.9%
metadata-eval63.9%
mul0-lft63.9%
metadata-eval63.9%
*-commutative63.9%
neg-mul-163.9%
unsub-neg63.9%
Simplified63.9%
Taylor expanded in x around 0 64.1%
if 4500 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 49.1%
Taylor expanded in x around 0 49.1%
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 72.4%
Simplified63.3%
Taylor expanded in eps around 0 18.6%
Taylor expanded in x around 0 18.7%
herbie shell --seed 2024155
(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))