
(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 7 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 (<= x 2.5) (/ (* 2.0 (cosh (* x eps_m))) 2.0) (/ (+ (exp (* x (+ -1.0 eps_m))) (exp (- x))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2.5) {
tmp = (2.0 * cosh((x * eps_m))) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps_m))) + 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 <= 2.5d0) then
tmp = (2.0d0 * cosh((x * eps_m))) / 2.0d0
else
tmp = (exp((x * ((-1.0d0) + eps_m))) + 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 <= 2.5) {
tmp = (2.0 * Math.cosh((x * eps_m))) / 2.0;
} else {
tmp = (Math.exp((x * (-1.0 + eps_m))) + Math.exp(-x)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 2.5: tmp = (2.0 * math.cosh((x * eps_m))) / 2.0 else: tmp = (math.exp((x * (-1.0 + eps_m))) + math.exp(-x)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2.5) tmp = Float64(Float64(2.0 * cosh(Float64(x * eps_m))) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) + exp(Float64(-x))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 2.5) tmp = (2.0 * cosh((x * eps_m))) / 2.0; else tmp = (exp((x * (-1.0 + eps_m))) + exp(-x)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2.5], N[(N[(2.0 * N[Cosh[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.5:\\
\;\;\;\;\frac{2 \cdot \cosh \left(x \cdot eps\_m\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps\_m\right)} + e^{-x}}{2}\\
\end{array}
\end{array}
if x < 2.5Initial program 65.8%
Simplified47.5%
Taylor expanded in eps around inf 98.0%
Taylor expanded in eps around inf 98.1%
associate-*r*98.1%
neg-mul-198.1%
Simplified98.1%
Taylor expanded in eps around inf 98.8%
*-commutative98.8%
Simplified98.8%
+-commutative98.8%
distribute-lft-neg-out98.8%
*-commutative98.8%
cosh-undef98.8%
Applied egg-rr98.8%
if 2.5 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around 0 70.0%
neg-mul-170.0%
Simplified70.0%
Final simplification91.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 75.0%
Simplified61.7%
Taylor expanded in eps around inf 98.6%
Final simplification98.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 4.5e-100)
1.0
(if (<= eps_m 0.027)
(/
(*
x
(+
(/ (- 2.0 (* x (* (+ -1.0 (/ 1.0 eps_m)) (- -1.0 eps_m)))) x)
(* (+ -1.0 eps_m) (+ 1.0 (/ 1.0 eps_m)))))
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 <= 4.5e-100) {
tmp = 1.0;
} else if (eps_m <= 0.027) {
tmp = (x * (((2.0 - (x * ((-1.0 + (1.0 / eps_m)) * (-1.0 - eps_m)))) / x) + ((-1.0 + eps_m) * (1.0 + (1.0 / eps_m))))) / 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 <= 4.5d-100) then
tmp = 1.0d0
else if (eps_m <= 0.027d0) then
tmp = (x * (((2.0d0 - (x * (((-1.0d0) + (1.0d0 / eps_m)) * ((-1.0d0) - eps_m)))) / x) + (((-1.0d0) + eps_m) * (1.0d0 + (1.0d0 / eps_m))))) / 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 <= 4.5e-100) {
tmp = 1.0;
} else if (eps_m <= 0.027) {
tmp = (x * (((2.0 - (x * ((-1.0 + (1.0 / eps_m)) * (-1.0 - eps_m)))) / x) + ((-1.0 + eps_m) * (1.0 + (1.0 / eps_m))))) / 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 <= 4.5e-100: tmp = 1.0 elif eps_m <= 0.027: tmp = (x * (((2.0 - (x * ((-1.0 + (1.0 / eps_m)) * (-1.0 - eps_m)))) / x) + ((-1.0 + eps_m) * (1.0 + (1.0 / eps_m))))) / 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 <= 4.5e-100) tmp = 1.0; elseif (eps_m <= 0.027) tmp = Float64(Float64(x * Float64(Float64(Float64(2.0 - Float64(x * Float64(Float64(-1.0 + Float64(1.0 / eps_m)) * Float64(-1.0 - eps_m)))) / x) + Float64(Float64(-1.0 + eps_m) * Float64(1.0 + Float64(1.0 / eps_m))))) / 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 <= 4.5e-100) tmp = 1.0; elseif (eps_m <= 0.027) tmp = (x * (((2.0 - (x * ((-1.0 + (1.0 / eps_m)) * (-1.0 - eps_m)))) / x) + ((-1.0 + eps_m) * (1.0 + (1.0 / eps_m))))) / 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, 4.5e-100], 1.0, If[LessEqual[eps$95$m, 0.027], N[(N[(x * N[(N[(N[(2.0 - N[(x * N[(N[(-1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(N[(-1.0 + eps$95$m), $MachinePrecision] * N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $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 4.5 \cdot 10^{-100}:\\
\;\;\;\;1\\
\mathbf{elif}\;eps\_m \leq 0.027:\\
\;\;\;\;\frac{x \cdot \left(\frac{2 - x \cdot \left(\left(-1 + \frac{1}{eps\_m}\right) \cdot \left(-1 - eps\_m\right)\right)}{x} + \left(-1 + eps\_m\right) \cdot \left(1 + \frac{1}{eps\_m}\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot \cosh \left(x \cdot eps\_m\right)}{2}\\
\end{array}
\end{array}
if eps < 4.5000000000000001e-100Initial program 67.9%
Simplified67.9%
Taylor expanded in x around 0 34.4%
Taylor expanded in x around 0 20.0%
Taylor expanded in eps around inf 51.1%
associate-*r/51.1%
metadata-eval51.1%
Simplified51.1%
Taylor expanded in eps around 0 46.3%
if 4.5000000000000001e-100 < eps < 0.0269999999999999997Initial program 54.8%
Simplified54.8%
Taylor expanded in x around 0 2.5%
Taylor expanded in x around -inf 3.2%
Taylor expanded in x around 0 84.0%
+-commutative84.0%
sub-neg84.0%
metadata-eval84.0%
+-commutative84.0%
Simplified84.0%
if 0.0269999999999999997 < eps Initial program 100.0%
Simplified74.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%
Final simplification61.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -0.000116) (/ (/ (+ x (* eps_m (- 2.0 (* x eps_m)))) eps_m) 2.0) (if (<= x 550.0) 1.0 0.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -0.000116) {
tmp = ((x + (eps_m * (2.0 - (x * eps_m)))) / eps_m) / 2.0;
} else 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 <= (-0.000116d0)) then
tmp = ((x + (eps_m * (2.0d0 - (x * eps_m)))) / eps_m) / 2.0d0
else 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 <= -0.000116) {
tmp = ((x + (eps_m * (2.0 - (x * eps_m)))) / eps_m) / 2.0;
} else 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 <= -0.000116: tmp = ((x + (eps_m * (2.0 - (x * eps_m)))) / eps_m) / 2.0 elif 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 <= -0.000116) tmp = Float64(Float64(Float64(x + Float64(eps_m * Float64(2.0 - Float64(x * eps_m)))) / eps_m) / 2.0); elseif (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 <= -0.000116) tmp = ((x + (eps_m * (2.0 - (x * eps_m)))) / eps_m) / 2.0; elseif (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, -0.000116], N[(N[(N[(x + N[(eps$95$m * N[(2.0 - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 550.0], 1.0, 0.0]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.000116:\\
\;\;\;\;\frac{\frac{x + eps\_m \cdot \left(2 - x \cdot eps\_m\right)}{eps\_m}}{2}\\
\mathbf{elif}\;x \leq 550:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1.16e-4Initial program 97.4%
Simplified97.4%
Taylor expanded in x around 0 38.8%
Taylor expanded in x around 0 19.8%
+-commutative19.8%
sub-neg19.8%
metadata-eval19.8%
+-commutative19.8%
Simplified19.8%
Taylor expanded in eps around 0 29.4%
mul-1-neg29.4%
*-commutative29.4%
distribute-rgt-neg-in29.4%
Simplified29.4%
if -1.16e-4 < x < 550Initial program 57.7%
Simplified57.7%
Taylor expanded in x around 0 44.0%
Taylor expanded in x around 0 29.1%
Taylor expanded in eps around inf 70.5%
associate-*r/70.5%
metadata-eval70.5%
Simplified70.5%
Taylor expanded in eps around 0 71.7%
if 550 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 66.1%
associate-*r*66.1%
neg-mul-166.1%
Simplified66.1%
Taylor expanded in eps around inf 49.0%
*-commutative49.0%
Simplified49.0%
flip-+0.2%
div-sub0.2%
Applied egg-rr0.0%
+-inverses52.9%
Simplified52.9%
Final simplification60.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 250.0) (/ (- 2.0 (* x eps_m)) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 250.0) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 250.0d0) then
tmp = (2.0d0 - (x * eps_m)) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 250.0) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 250.0: tmp = (2.0 - (x * eps_m)) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 250.0) tmp = Float64(Float64(2.0 - Float64(x * eps_m)) / 2.0); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 250.0) tmp = (2.0 - (x * eps_m)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 250.0], N[(N[(2.0 - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 250:\\
\;\;\;\;\frac{2 - x \cdot eps\_m}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 250Initial program 65.8%
Simplified65.8%
Taylor expanded in x around 0 42.1%
Taylor expanded in x around 0 43.7%
+-commutative43.7%
sub-neg43.7%
metadata-eval43.7%
+-commutative43.7%
Simplified43.7%
Taylor expanded in eps around inf 60.3%
mul-1-neg60.3%
*-commutative60.3%
distribute-rgt-neg-in60.3%
Simplified60.3%
if 250 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 66.1%
associate-*r*66.1%
neg-mul-166.1%
Simplified66.1%
Taylor expanded in eps around inf 49.0%
*-commutative49.0%
Simplified49.0%
flip-+0.2%
div-sub0.2%
Applied egg-rr0.0%
+-inverses52.9%
Simplified52.9%
Final simplification58.3%
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 65.8%
Simplified65.8%
Taylor expanded in x around 0 44.6%
Taylor expanded in x around 0 29.0%
Taylor expanded in eps around inf 62.0%
associate-*r/62.0%
metadata-eval62.0%
Simplified62.0%
Taylor expanded in eps around 0 57.8%
if 550 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 66.1%
associate-*r*66.1%
neg-mul-166.1%
Simplified66.1%
Taylor expanded in eps around inf 49.0%
*-commutative49.0%
Simplified49.0%
flip-+0.2%
div-sub0.2%
Applied egg-rr0.0%
+-inverses52.9%
Simplified52.9%
Final simplification56.5%
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 75.0%
Simplified75.0%
Taylor expanded in x around 0 40.8%
Taylor expanded in x around 0 24.3%
Taylor expanded in eps around inf 48.6%
associate-*r/48.6%
metadata-eval48.6%
Simplified48.6%
Taylor expanded in eps around 0 43.0%
herbie shell --seed 2024191
(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))