
(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 10 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 64.5%
Simplified54.8%
Taylor expanded in eps around inf 97.8%
Taylor expanded in eps around 0 80.8%
*-commutative80.8%
neg-mul-180.8%
Simplified80.8%
if 1 < eps Initial program 100.0%
Simplified81.9%
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%
*-commutative100.0%
distribute-lft-neg-out100.0%
cosh-undef100.0%
*-commutative100.0%
Applied egg-rr100.0%
Final simplification85.2%
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.7%
Simplified61.1%
Taylor expanded in eps around inf 98.3%
Final simplification98.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 7.2e+223) (/ (* 2.0 (exp (- x))) 2.0) (/ (exp (* x (- -1.0 eps_m))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 7.2e+223) {
tmp = (2.0 * exp(-x)) / 2.0;
} else {
tmp = exp((x * (-1.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 <= 7.2d+223) then
tmp = (2.0d0 * exp(-x)) / 2.0d0
else
tmp = exp((x * ((-1.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 <= 7.2e+223) {
tmp = (2.0 * Math.exp(-x)) / 2.0;
} else {
tmp = Math.exp((x * (-1.0 - eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 7.2e+223: tmp = (2.0 * math.exp(-x)) / 2.0 else: tmp = math.exp((x * (-1.0 - eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 7.2e+223) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0); else tmp = Float64(exp(Float64(x * Float64(-1.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 <= 7.2e+223) tmp = (2.0 * exp(-x)) / 2.0; else tmp = exp((x * (-1.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, 7.2e+223], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[Exp[N[(x * N[(-1.0 - 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 7.2 \cdot 10^{+223}:\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 7.19999999999999982e223Initial program 70.8%
Simplified58.3%
Taylor expanded in eps around inf 98.2%
Taylor expanded in eps around 0 75.7%
*-commutative75.7%
neg-mul-175.7%
Simplified75.7%
if 7.19999999999999982e223 < eps Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around 0 76.9%
Taylor expanded in eps around inf 76.8%
associate-*r*76.8%
+-commutative76.8%
mul-1-neg76.8%
distribute-lft-neg-in76.8%
neg-mul-176.8%
+-commutative76.8%
*-lft-identity76.8%
metadata-eval76.8%
cancel-sign-sub-inv76.8%
mul-1-neg76.8%
cancel-sign-sub-inv76.8%
metadata-eval76.8%
*-lft-identity76.8%
+-commutative76.8%
distribute-rgt-neg-in76.8%
+-commutative76.8%
mul-1-neg76.8%
distribute-lft-in76.8%
metadata-eval76.8%
mul-1-neg76.8%
unsub-neg76.8%
Simplified76.8%
Final simplification75.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 7.8e+223) (/ (* 2.0 (exp (- x))) 2.0) (/ (+ 2.0 (* x (/ (+ 1.0 (* eps_m (+ -1.0 (* eps_m -2.0)))) eps_m))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 7.8e+223) {
tmp = (2.0 * exp(-x)) / 2.0;
} else {
tmp = (2.0 + (x * ((1.0 + (eps_m * (-1.0 + (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 <= 7.8d+223) then
tmp = (2.0d0 * exp(-x)) / 2.0d0
else
tmp = (2.0d0 + (x * ((1.0d0 + (eps_m * ((-1.0d0) + (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 <= 7.8e+223) {
tmp = (2.0 * Math.exp(-x)) / 2.0;
} else {
tmp = (2.0 + (x * ((1.0 + (eps_m * (-1.0 + (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 <= 7.8e+223: tmp = (2.0 * math.exp(-x)) / 2.0 else: tmp = (2.0 + (x * ((1.0 + (eps_m * (-1.0 + (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 <= 7.8e+223) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0); else tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(1.0 + Float64(eps_m * Float64(-1.0 + 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 <= 7.8e+223) tmp = (2.0 * exp(-x)) / 2.0; else tmp = (2.0 + (x * ((1.0 + (eps_m * (-1.0 + (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, 7.8e+223], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(x * N[(N[(1.0 + N[(eps$95$m * N[(-1.0 + N[(eps$95$m * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 7.8 \cdot 10^{+223}:\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + x \cdot \frac{1 + eps\_m \cdot \left(-1 + eps\_m \cdot -2\right)}{eps\_m}}{2}\\
\end{array}
\end{array}
if eps < 7.7999999999999997e223Initial program 70.8%
Simplified58.3%
Taylor expanded in eps around inf 98.2%
Taylor expanded in eps around 0 75.7%
*-commutative75.7%
neg-mul-175.7%
Simplified75.7%
if 7.7999999999999997e223 < eps Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 3.1%
associate-*r*3.1%
neg-mul-13.1%
+-commutative3.1%
sub-neg3.1%
metadata-eval3.1%
+-commutative3.1%
Simplified3.1%
distribute-rgt-in3.1%
*-un-lft-identity3.1%
inv-pow3.1%
pow-plus3.1%
metadata-eval3.1%
metadata-eval3.1%
add-sqr-sqrt3.0%
sqrt-unprod23.5%
sqr-neg23.5%
sqrt-unprod0.0%
add-sqr-sqrt42.8%
neg-sub042.8%
Applied egg-rr42.8%
neg-sub042.8%
+-commutative42.8%
distribute-neg-in42.8%
metadata-eval42.8%
unsub-neg42.8%
Simplified42.8%
Taylor expanded in eps around 0 76.5%
Final simplification75.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -7e-12) (/ (+ 2.0 (/ (+ x (* eps_m (- (* -2.0 (* x eps_m)) x))) eps_m)) 2.0) (if (<= x 480.0) 1.0 0.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -7e-12) {
tmp = (2.0 + ((x + (eps_m * ((-2.0 * (x * eps_m)) - x))) / eps_m)) / 2.0;
} else if (x <= 480.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 <= (-7d-12)) then
tmp = (2.0d0 + ((x + (eps_m * (((-2.0d0) * (x * eps_m)) - x))) / eps_m)) / 2.0d0
else if (x <= 480.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 <= -7e-12) {
tmp = (2.0 + ((x + (eps_m * ((-2.0 * (x * eps_m)) - x))) / eps_m)) / 2.0;
} else if (x <= 480.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -7e-12: tmp = (2.0 + ((x + (eps_m * ((-2.0 * (x * eps_m)) - x))) / eps_m)) / 2.0 elif x <= 480.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -7e-12) tmp = Float64(Float64(2.0 + Float64(Float64(x + Float64(eps_m * Float64(Float64(-2.0 * Float64(x * eps_m)) - x))) / eps_m)) / 2.0); elseif (x <= 480.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 <= -7e-12) tmp = (2.0 + ((x + (eps_m * ((-2.0 * (x * eps_m)) - x))) / eps_m)) / 2.0; elseif (x <= 480.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, -7e-12], N[(N[(2.0 + N[(N[(x + N[(eps$95$m * N[(N[(-2.0 * N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 480.0], 1.0, 0.0]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{-12}:\\
\;\;\;\;\frac{2 + \frac{x + eps\_m \cdot \left(-2 \cdot \left(x \cdot eps\_m\right) - x\right)}{eps\_m}}{2}\\
\mathbf{elif}\;x \leq 480:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -7.0000000000000001e-12Initial program 91.3%
Simplified91.3%
Taylor expanded in eps around inf 91.3%
Taylor expanded in x around 0 2.9%
associate-*r*2.9%
neg-mul-12.9%
+-commutative2.9%
sub-neg2.9%
metadata-eval2.9%
+-commutative2.9%
Simplified2.9%
distribute-rgt-in2.9%
*-un-lft-identity2.9%
inv-pow2.9%
pow-plus2.9%
metadata-eval2.9%
metadata-eval2.9%
add-sqr-sqrt3.3%
sqrt-unprod0.4%
sqr-neg0.4%
sqrt-unprod0.1%
add-sqr-sqrt24.7%
neg-sub024.7%
Applied egg-rr24.7%
neg-sub024.7%
+-commutative24.7%
distribute-neg-in24.7%
metadata-eval24.7%
unsub-neg24.7%
Simplified24.7%
Taylor expanded in eps around 0 30.7%
if -7.0000000000000001e-12 < x < 480Initial program 51.6%
Simplified51.6%
Taylor expanded in eps around inf 51.6%
Taylor expanded in x around 0 54.8%
associate-*r*54.8%
neg-mul-154.8%
+-commutative54.8%
sub-neg54.8%
metadata-eval54.8%
+-commutative54.8%
Simplified54.8%
Taylor expanded in eps around inf 79.2%
Taylor expanded in x around 0 79.5%
if 480 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 53.4%
Taylor expanded in x around 0 53.4%
Final simplification63.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -6.5e-12) (/ (+ 2.0 (* x (/ (+ 1.0 (* eps_m (+ -1.0 (* eps_m -2.0)))) eps_m))) 2.0) (if (<= x 500.0) 1.0 0.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -6.5e-12) {
tmp = (2.0 + (x * ((1.0 + (eps_m * (-1.0 + (eps_m * -2.0)))) / eps_m))) / 2.0;
} else if (x <= 500.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 <= (-6.5d-12)) then
tmp = (2.0d0 + (x * ((1.0d0 + (eps_m * ((-1.0d0) + (eps_m * (-2.0d0))))) / eps_m))) / 2.0d0
else if (x <= 500.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 <= -6.5e-12) {
tmp = (2.0 + (x * ((1.0 + (eps_m * (-1.0 + (eps_m * -2.0)))) / eps_m))) / 2.0;
} else if (x <= 500.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -6.5e-12: tmp = (2.0 + (x * ((1.0 + (eps_m * (-1.0 + (eps_m * -2.0)))) / eps_m))) / 2.0 elif x <= 500.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -6.5e-12) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(1.0 + Float64(eps_m * Float64(-1.0 + Float64(eps_m * -2.0)))) / eps_m))) / 2.0); elseif (x <= 500.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 <= -6.5e-12) tmp = (2.0 + (x * ((1.0 + (eps_m * (-1.0 + (eps_m * -2.0)))) / eps_m))) / 2.0; elseif (x <= 500.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, -6.5e-12], N[(N[(2.0 + N[(x * N[(N[(1.0 + N[(eps$95$m * N[(-1.0 + N[(eps$95$m * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 500.0], 1.0, 0.0]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.5 \cdot 10^{-12}:\\
\;\;\;\;\frac{2 + x \cdot \frac{1 + eps\_m \cdot \left(-1 + eps\_m \cdot -2\right)}{eps\_m}}{2}\\
\mathbf{elif}\;x \leq 500:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -6.5000000000000002e-12Initial program 91.3%
Simplified91.3%
Taylor expanded in eps around inf 91.3%
Taylor expanded in x around 0 2.9%
associate-*r*2.9%
neg-mul-12.9%
+-commutative2.9%
sub-neg2.9%
metadata-eval2.9%
+-commutative2.9%
Simplified2.9%
distribute-rgt-in2.9%
*-un-lft-identity2.9%
inv-pow2.9%
pow-plus2.9%
metadata-eval2.9%
metadata-eval2.9%
add-sqr-sqrt3.3%
sqrt-unprod0.4%
sqr-neg0.4%
sqrt-unprod0.1%
add-sqr-sqrt24.7%
neg-sub024.7%
Applied egg-rr24.7%
neg-sub024.7%
+-commutative24.7%
distribute-neg-in24.7%
metadata-eval24.7%
unsub-neg24.7%
Simplified24.7%
Taylor expanded in eps around 0 26.7%
if -6.5000000000000002e-12 < x < 500Initial program 51.6%
Simplified51.6%
Taylor expanded in eps around inf 51.6%
Taylor expanded in x around 0 54.8%
associate-*r*54.8%
neg-mul-154.8%
+-commutative54.8%
sub-neg54.8%
metadata-eval54.8%
+-commutative54.8%
Simplified54.8%
Taylor expanded in eps around inf 79.2%
Taylor expanded in x around 0 79.5%
if 500 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 53.4%
Taylor expanded in x around 0 53.4%
Final simplification62.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 12.4) (/ (+ 2.0 (* x (* eps_m -2.0))) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 12.4) {
tmp = (2.0 + (x * (eps_m * -2.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 <= 12.4d0) then
tmp = (2.0d0 + (x * (eps_m * (-2.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 <= 12.4) {
tmp = (2.0 + (x * (eps_m * -2.0))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 12.4: tmp = (2.0 + (x * (eps_m * -2.0))) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 12.4) tmp = Float64(Float64(2.0 + Float64(x * Float64(eps_m * -2.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 <= 12.4) tmp = (2.0 + (x * (eps_m * -2.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, 12.4], N[(N[(2.0 + N[(x * N[(eps$95$m * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 12.4:\\
\;\;\;\;\frac{2 + x \cdot \left(eps\_m \cdot -2\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 12.4000000000000004Initial program 61.4%
Simplified61.4%
Taylor expanded in eps around inf 61.4%
Taylor expanded in x around 0 41.9%
associate-*r*41.9%
neg-mul-141.9%
+-commutative41.9%
sub-neg41.9%
metadata-eval41.9%
+-commutative41.9%
Simplified41.9%
distribute-rgt-in41.9%
*-un-lft-identity41.9%
inv-pow41.9%
pow-plus41.9%
metadata-eval41.9%
metadata-eval41.9%
add-sqr-sqrt29.1%
sqrt-unprod41.5%
sqr-neg41.5%
sqrt-unprod12.3%
add-sqr-sqrt46.5%
neg-sub046.5%
Applied egg-rr46.5%
neg-sub046.5%
+-commutative46.5%
distribute-neg-in46.5%
metadata-eval46.5%
unsub-neg46.5%
Simplified46.5%
Taylor expanded in eps around inf 65.1%
*-commutative65.1%
Simplified65.1%
if 12.4000000000000004 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 52.8%
Taylor expanded in x around 0 52.8%
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 61.4%
Simplified44.9%
Taylor expanded in eps around inf 97.6%
Taylor expanded in eps around inf 97.6%
associate-*r*97.6%
neg-mul-197.6%
Simplified97.6%
Taylor expanded in x around 0 60.7%
*-commutative60.7%
distribute-rgt1-in60.7%
metadata-eval60.7%
mul0-lft60.7%
metadata-eval60.7%
mul-1-neg60.7%
unsub-neg60.7%
Simplified60.7%
if 2 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 52.8%
Taylor expanded in x around 0 52.8%
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 61.6%
Simplified61.6%
Taylor expanded in eps around inf 61.6%
Taylor expanded in x around 0 41.6%
associate-*r*41.6%
neg-mul-141.6%
+-commutative41.6%
sub-neg41.6%
metadata-eval41.6%
+-commutative41.6%
Simplified41.6%
Taylor expanded in eps around inf 59.4%
Taylor expanded in x around 0 60.1%
if 550 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 53.4%
Taylor expanded in x around 0 53.4%
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.7%
Simplified61.1%
Taylor expanded in eps around 0 17.0%
Taylor expanded in x around 0 17.2%
herbie shell --seed 2024177
(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))