
(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.4e-6) (* 0.5 (* (exp (- x)) (+ 2.0 (* x 2.0)))) (/ (+ (exp (* x eps_m)) (exp (* x (- eps_m)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.4e-6) {
tmp = 0.5 * (exp(-x) * (2.0 + (x * 2.0)));
} else {
tmp = (exp((x * eps_m)) + exp((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.4d-6) then
tmp = 0.5d0 * (exp(-x) * (2.0d0 + (x * 2.0d0)))
else
tmp = (exp((x * eps_m)) + exp((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.4e-6) {
tmp = 0.5 * (Math.exp(-x) * (2.0 + (x * 2.0)));
} else {
tmp = (Math.exp((x * eps_m)) + Math.exp((x * -eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.4e-6: tmp = 0.5 * (math.exp(-x) * (2.0 + (x * 2.0))) else: tmp = (math.exp((x * eps_m)) + math.exp((x * -eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.4e-6) tmp = Float64(0.5 * Float64(exp(Float64(-x)) * Float64(2.0 + Float64(x * 2.0)))); else tmp = Float64(Float64(exp(Float64(x * eps_m)) + exp(Float64(x * Float64(-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.4e-6) tmp = 0.5 * (exp(-x) * (2.0 + (x * 2.0))); else tmp = (exp((x * eps_m)) + exp((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.4e-6], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] * N[(2.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + N[Exp[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.4 \cdot 10^{-6}:\\
\;\;\;\;0.5 \cdot \left(e^{-x} \cdot \left(2 + x \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 1.39999999999999994e-6Initial program 62.1%
Simplified55.6%
Taylor expanded in eps around 0 29.9%
Simplified69.0%
Taylor expanded in eps around 0 69.0%
if 1.39999999999999994e-6 < eps Initial program 100.0%
Simplified86.4%
Taylor expanded in eps around inf 99.9%
inv-pow99.9%
exp-sum99.9%
unpow-prod-down99.9%
inv-pow99.9%
exp-neg99.9%
add-sqr-sqrt44.4%
sqrt-unprod75.0%
sqr-neg75.0%
sqrt-unprod30.6%
add-sqr-sqrt55.6%
exp-prod29.7%
Applied egg-rr29.7%
unpow-129.7%
associate-*r/29.7%
*-rgt-identity29.7%
exp-prod55.6%
div-exp100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in eps around inf 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in eps around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
*-commutative100.0%
Simplified100.0%
Final simplification77.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -2e-247) (/ (+ (exp (- x)) (exp (- x (* x eps_m)))) 2.0) (if (<= x 3.7e+84) (/ (+ 1.0 (exp (* x (+ eps_m -1.0)))) 2.0) 0.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -2e-247) {
tmp = (exp(-x) + exp((x - (x * eps_m)))) / 2.0;
} else if (x <= 3.7e+84) {
tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-2d-247)) then
tmp = (exp(-x) + exp((x - (x * eps_m)))) / 2.0d0
else if (x <= 3.7d+84) then
tmp = (1.0d0 + exp((x * (eps_m + (-1.0d0))))) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -2e-247) {
tmp = (Math.exp(-x) + Math.exp((x - (x * eps_m)))) / 2.0;
} else if (x <= 3.7e+84) {
tmp = (1.0 + Math.exp((x * (eps_m + -1.0)))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -2e-247: tmp = (math.exp(-x) + math.exp((x - (x * eps_m)))) / 2.0 elif x <= 3.7e+84: tmp = (1.0 + math.exp((x * (eps_m + -1.0)))) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -2e-247) tmp = Float64(Float64(exp(Float64(-x)) + exp(Float64(x - Float64(x * eps_m)))) / 2.0); elseif (x <= 3.7e+84) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps_m + -1.0)))) / 2.0); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -2e-247) tmp = (exp(-x) + exp((x - (x * eps_m)))) / 2.0; elseif (x <= 3.7e+84) tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -2e-247], N[(N[(N[Exp[(-x)], $MachinePrecision] + N[Exp[N[(x - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 3.7e+84], N[(N[(1.0 + N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-247}:\\
\;\;\;\;\frac{e^{-x} + e^{x - x \cdot eps\_m}}{2}\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{+84}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(eps\_m + -1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -2e-247Initial program 72.9%
Simplified63.5%
Taylor expanded in eps around inf 98.2%
inv-pow98.2%
exp-sum76.7%
unpow-prod-down76.7%
inv-pow76.7%
exp-neg76.7%
add-sqr-sqrt76.7%
sqrt-unprod76.7%
sqr-neg76.7%
sqrt-unprod0.0%
add-sqr-sqrt83.9%
exp-prod71.7%
Applied egg-rr71.7%
unpow-171.7%
associate-*r/71.7%
*-rgt-identity71.7%
exp-prod83.9%
div-exp98.9%
*-commutative98.9%
Simplified98.9%
Taylor expanded in eps around 0 87.4%
neg-mul-187.4%
Simplified87.4%
if -2e-247 < x < 3.7e84Initial program 60.6%
Simplified52.1%
Taylor expanded in eps around inf 98.1%
Taylor expanded in x around 0 72.5%
if 3.7e84 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 58.7%
mul-1-neg58.7%
mul-1-neg58.7%
rec-exp58.7%
sub-neg58.7%
div-sub58.7%
rec-exp58.7%
mul-1-neg58.7%
+-inverses58.7%
Simplified58.7%
Final simplification75.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ (exp (* x (+ eps_m -1.0))) (/ 1.0 (exp (+ x (* x eps_m))))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp((x * (eps_m + -1.0))) + (1.0 / exp((x + (x * eps_m))))) / 2.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = (exp((x * (eps_m + (-1.0d0)))) + (1.0d0 / exp((x + (x * eps_m))))) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (Math.exp((x * (eps_m + -1.0))) + (1.0 / Math.exp((x + (x * eps_m))))) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (math.exp((x * (eps_m + -1.0))) + (1.0 / math.exp((x + (x * eps_m))))) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(exp(Float64(x * Float64(eps_m + -1.0))) + Float64(1.0 / exp(Float64(x + Float64(x * eps_m))))) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (exp((x * (eps_m + -1.0))) + (1.0 / exp((x + (x * eps_m))))) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(1.0 / N[Exp[N[(x + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{e^{x \cdot \left(eps\_m + -1\right)} + \frac{1}{e^{x + x \cdot eps\_m}}}{2}
\end{array}
Initial program 72.7%
Simplified65.6%
Taylor expanded in eps around inf 98.5%
Final simplification98.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (* x (+ eps_m -1.0)))))
(if (<= eps_m 1.0)
(* 0.5 (* (exp (- x)) (+ 2.0 (* x 2.0))))
(if (<= eps_m 7.2e+227)
(/ (+ t_0 (- 1.0 x)) 2.0)
(/ (+ t_0 (+ 1.0 (* x (- -1.0 eps_m)))) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp((x * (eps_m + -1.0)));
double tmp;
if (eps_m <= 1.0) {
tmp = 0.5 * (exp(-x) * (2.0 + (x * 2.0)));
} else if (eps_m <= 7.2e+227) {
tmp = (t_0 + (1.0 - x)) / 2.0;
} else {
tmp = (t_0 + (1.0 + (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) :: t_0
real(8) :: tmp
t_0 = exp((x * (eps_m + (-1.0d0))))
if (eps_m <= 1.0d0) then
tmp = 0.5d0 * (exp(-x) * (2.0d0 + (x * 2.0d0)))
else if (eps_m <= 7.2d+227) then
tmp = (t_0 + (1.0d0 - x)) / 2.0d0
else
tmp = (t_0 + (1.0d0 + (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 t_0 = Math.exp((x * (eps_m + -1.0)));
double tmp;
if (eps_m <= 1.0) {
tmp = 0.5 * (Math.exp(-x) * (2.0 + (x * 2.0)));
} else if (eps_m <= 7.2e+227) {
tmp = (t_0 + (1.0 - x)) / 2.0;
} else {
tmp = (t_0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp((x * (eps_m + -1.0))) tmp = 0 if eps_m <= 1.0: tmp = 0.5 * (math.exp(-x) * (2.0 + (x * 2.0))) elif eps_m <= 7.2e+227: tmp = (t_0 + (1.0 - x)) / 2.0 else: tmp = (t_0 + (1.0 + (x * (-1.0 - eps_m)))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(x * Float64(eps_m + -1.0))) tmp = 0.0 if (eps_m <= 1.0) tmp = Float64(0.5 * Float64(exp(Float64(-x)) * Float64(2.0 + Float64(x * 2.0)))); elseif (eps_m <= 7.2e+227) tmp = Float64(Float64(t_0 + Float64(1.0 - x)) / 2.0); else tmp = Float64(Float64(t_0 + Float64(1.0 + Float64(x * Float64(-1.0 - eps_m)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp((x * (eps_m + -1.0))); tmp = 0.0; if (eps_m <= 1.0) tmp = 0.5 * (exp(-x) * (2.0 + (x * 2.0))); elseif (eps_m <= 7.2e+227) tmp = (t_0 + (1.0 - x)) / 2.0; else tmp = (t_0 + (1.0 + (x * (-1.0 - eps_m)))) / 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[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eps$95$m, 1.0], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] * N[(2.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps$95$m, 7.2e+227], N[(N[(t$95$0 + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 + N[(1.0 + N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(eps\_m + -1\right)}\\
\mathbf{if}\;eps\_m \leq 1:\\
\;\;\;\;0.5 \cdot \left(e^{-x} \cdot \left(2 + x \cdot 2\right)\right)\\
\mathbf{elif}\;eps\_m \leq 7.2 \cdot 10^{+227}:\\
\;\;\;\;\frac{t\_0 + \left(1 - x\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 + \left(1 + x \cdot \left(-1 - eps\_m\right)\right)}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 62.3%
Simplified55.8%
Taylor expanded in eps around 0 30.3%
Simplified69.1%
Taylor expanded in eps around 0 69.1%
if 1 < eps < 7.19999999999999983e227Initial program 100.0%
Simplified90.9%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around 0 87.4%
rec-exp87.4%
Simplified87.4%
Taylor expanded in x around 0 72.9%
neg-mul-172.9%
unsub-neg72.9%
Simplified72.9%
if 7.19999999999999983e227 < eps Initial program 100.0%
Simplified73.1%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 62.8%
associate-*r*62.8%
neg-mul-162.8%
Simplified62.8%
Final simplification69.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 1.0) (* 0.5 (* (exp (- x)) (+ 2.0 (* x 2.0)))) (/ (+ (exp (* x (+ eps_m -1.0))) (- 1.0 x)) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.0) {
tmp = 0.5 * (exp(-x) * (2.0 + (x * 2.0)));
} else {
tmp = (exp((x * (eps_m + -1.0))) + (1.0 - 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 (eps_m <= 1.0d0) then
tmp = 0.5d0 * (exp(-x) * (2.0d0 + (x * 2.0d0)))
else
tmp = (exp((x * (eps_m + (-1.0d0)))) + (1.0d0 - 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 (eps_m <= 1.0) {
tmp = 0.5 * (Math.exp(-x) * (2.0 + (x * 2.0)));
} else {
tmp = (Math.exp((x * (eps_m + -1.0))) + (1.0 - x)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.0: tmp = 0.5 * (math.exp(-x) * (2.0 + (x * 2.0))) else: tmp = (math.exp((x * (eps_m + -1.0))) + (1.0 - x)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.0) tmp = Float64(0.5 * Float64(exp(Float64(-x)) * Float64(2.0 + Float64(x * 2.0)))); else tmp = Float64(Float64(exp(Float64(x * Float64(eps_m + -1.0))) + Float64(1.0 - x)) / 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 = 0.5 * (exp(-x) * (2.0 + (x * 2.0))); else tmp = (exp((x * (eps_m + -1.0))) + (1.0 - x)) / 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[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] * N[(2.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1:\\
\;\;\;\;0.5 \cdot \left(e^{-x} \cdot \left(2 + x \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(eps\_m + -1\right)} + \left(1 - x\right)}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 62.3%
Simplified55.8%
Taylor expanded in eps around 0 30.3%
Simplified69.1%
Taylor expanded in eps around 0 69.1%
if 1 < eps Initial program 100.0%
Simplified86.4%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around 0 85.1%
rec-exp85.1%
Simplified85.1%
Taylor expanded in x around 0 66.4%
neg-mul-166.4%
unsub-neg66.4%
Simplified66.4%
Final simplification68.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 1.0) (* 0.5 (* (exp (- x)) (+ 2.0 (* x 2.0)))) (/ (+ 1.0 (exp (* x (+ eps_m -1.0)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.0) {
tmp = 0.5 * (exp(-x) * (2.0 + (x * 2.0)));
} else {
tmp = (1.0 + exp((x * (eps_m + -1.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 = 0.5d0 * (exp(-x) * (2.0d0 + (x * 2.0d0)))
else
tmp = (1.0d0 + exp((x * (eps_m + (-1.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 = 0.5 * (Math.exp(-x) * (2.0 + (x * 2.0)));
} else {
tmp = (1.0 + Math.exp((x * (eps_m + -1.0)))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.0: tmp = 0.5 * (math.exp(-x) * (2.0 + (x * 2.0))) else: tmp = (1.0 + math.exp((x * (eps_m + -1.0)))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.0) tmp = Float64(0.5 * Float64(exp(Float64(-x)) * Float64(2.0 + Float64(x * 2.0)))); else tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps_m + -1.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 = 0.5 * (exp(-x) * (2.0 + (x * 2.0))); else tmp = (1.0 + exp((x * (eps_m + -1.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[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] * N[(2.0 + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1:\\
\;\;\;\;0.5 \cdot \left(e^{-x} \cdot \left(2 + x \cdot 2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(eps\_m + -1\right)}}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 62.3%
Simplified55.8%
Taylor expanded in eps around 0 30.3%
Simplified69.1%
Taylor expanded in eps around 0 69.1%
if 1 < eps Initial program 100.0%
Simplified86.4%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 66.0%
Final simplification68.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 2.4e+79) (/ (+ 1.0 (exp (* x (+ eps_m -1.0)))) 2.0) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2.4e+79) {
tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 2.4d+79) then
tmp = (1.0d0 + exp((x * (eps_m + (-1.0d0))))) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 2.4e+79) {
tmp = (1.0 + Math.exp((x * (eps_m + -1.0)))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 2.4e+79: tmp = (1.0 + math.exp((x * (eps_m + -1.0)))) / 2.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2.4e+79) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps_m + -1.0)))) / 2.0); else tmp = 0.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 2.4e+79) tmp = (1.0 + exp((x * (eps_m + -1.0)))) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2.4e+79], N[(N[(1.0 + N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{+79}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(eps\_m + -1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2.39999999999999986e79Initial program 66.1%
Simplified57.2%
Taylor expanded in eps around inf 98.2%
Taylor expanded in x around 0 73.8%
if 2.39999999999999986e79 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 58.7%
mul-1-neg58.7%
mul-1-neg58.7%
rec-exp58.7%
sub-neg58.7%
div-sub58.7%
rec-exp58.7%
mul-1-neg58.7%
+-inverses58.7%
Simplified58.7%
Final simplification70.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 1e+81) (* (exp x) (+ x 1.0)) 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 1e+81) {
tmp = exp(x) * (x + 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 <= 1d+81) then
tmp = exp(x) * (x + 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 <= 1e+81) {
tmp = Math.exp(x) * (x + 1.0);
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 1e+81: tmp = math.exp(x) * (x + 1.0) else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 1e+81) tmp = Float64(exp(x) * Float64(x + 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 <= 1e+81) tmp = exp(x) * (x + 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, 1e+81], N[(N[Exp[x], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+81}:\\
\;\;\;\;e^{x} \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 9.99999999999999921e80Initial program 66.1%
Simplified51.3%
Taylor expanded in eps around 0 22.5%
Simplified57.3%
Taylor expanded in eps around 0 57.3%
distribute-lft-in57.4%
distribute-lft-in57.4%
*-commutative57.4%
add-sqr-sqrt26.5%
sqrt-unprod58.3%
sqr-neg58.3%
unpow258.3%
sqrt-pow157.6%
metadata-eval57.6%
pow157.6%
*-commutative57.6%
Applied egg-rr57.7%
associate-*r*57.7%
metadata-eval57.7%
*-lft-identity57.7%
associate-*r*57.7%
*-commutative57.7%
+-commutative57.7%
associate-*l*57.7%
associate-*r*57.7%
metadata-eval57.7%
*-lft-identity57.7%
*-lft-identity57.7%
distribute-rgt-out57.7%
Simplified57.7%
if 9.99999999999999921e80 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 58.7%
mul-1-neg58.7%
mul-1-neg58.7%
rec-exp58.7%
sub-neg58.7%
div-sub58.7%
rec-exp58.7%
mul-1-neg58.7%
+-inverses58.7%
Simplified58.7%
Final simplification57.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 720000000000.0) 1.0 0.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 720000000000.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 <= 720000000000.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 <= 720000000000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 720000000000.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 720000000000.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 <= 720000000000.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, 720000000000.0], 1.0, 0.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 720000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 7.2e11Initial program 63.1%
Simplified46.9%
Taylor expanded in eps around 0 20.7%
Simplified58.7%
Taylor expanded in eps around 0 58.7%
Taylor expanded in x around 0 58.4%
if 7.2e11 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 54.5%
mul-1-neg54.5%
mul-1-neg54.5%
rec-exp54.5%
sub-neg54.5%
div-sub54.5%
rec-exp54.5%
mul-1-neg54.5%
+-inverses54.5%
Simplified54.5%
Final simplification57.4%
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.7%
Simplified60.8%
Taylor expanded in eps around 0 29.6%
Simplified57.6%
Taylor expanded in eps around 0 57.6%
Taylor expanded in x around 0 43.9%
herbie shell --seed 2024111
(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))