
(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 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (* x (+ -1.0 eps_m)))))
(if (<= x -3.8e-188)
(/ (+ t_0 (exp (* x (- eps_m)))) 2.0)
(/ (+ t_0 (exp (- x))) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp((x * (-1.0 + eps_m)));
double tmp;
if (x <= -3.8e-188) {
tmp = (t_0 + exp((x * -eps_m))) / 2.0;
} else {
tmp = (t_0 + exp(-x)) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = exp((x * ((-1.0d0) + eps_m)))
if (x <= (-3.8d-188)) then
tmp = (t_0 + exp((x * -eps_m))) / 2.0d0
else
tmp = (t_0 + exp(-x)) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = Math.exp((x * (-1.0 + eps_m)));
double tmp;
if (x <= -3.8e-188) {
tmp = (t_0 + Math.exp((x * -eps_m))) / 2.0;
} else {
tmp = (t_0 + Math.exp(-x)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp((x * (-1.0 + eps_m))) tmp = 0 if x <= -3.8e-188: tmp = (t_0 + math.exp((x * -eps_m))) / 2.0 else: tmp = (t_0 + math.exp(-x)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(x * Float64(-1.0 + eps_m))) tmp = 0.0 if (x <= -3.8e-188) tmp = Float64(Float64(t_0 + exp(Float64(x * Float64(-eps_m)))) / 2.0); else tmp = Float64(Float64(t_0 + exp(Float64(-x))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp((x * (-1.0 + eps_m))); tmp = 0.0; if (x <= -3.8e-188) tmp = (t_0 + exp((x * -eps_m))) / 2.0; else tmp = (t_0 + exp(-x)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3.8e-188], N[(N[(t$95$0 + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(-1 + eps\_m\right)}\\
\mathbf{if}\;x \leq -3.8 \cdot 10^{-188}:\\
\;\;\;\;\frac{t\_0 + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 + e^{-x}}{2}\\
\end{array}
\end{array}
if x < -3.8e-188Initial program 66.2%
Simplified61.3%
Taylor expanded in eps around inf 96.2%
Taylor expanded in eps around inf 96.3%
*-commutative96.3%
Simplified96.3%
if -3.8e-188 < x Initial program 68.1%
Simplified57.6%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around 0 82.4%
Final simplification87.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -3.8e-188)
(/ (+ (exp (* x (- eps_m))) t_0) 2.0)
(/ (+ (exp (* x (+ -1.0 eps_m))) t_0) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (x <= -3.8e-188) {
tmp = (exp((x * -eps_m)) + t_0) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps_m))) + t_0) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (x <= (-3.8d-188)) then
tmp = (exp((x * -eps_m)) + t_0) / 2.0d0
else
tmp = (exp((x * ((-1.0d0) + eps_m))) + t_0) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = Math.exp(-x);
double tmp;
if (x <= -3.8e-188) {
tmp = (Math.exp((x * -eps_m)) + t_0) / 2.0;
} else {
tmp = (Math.exp((x * (-1.0 + eps_m))) + t_0) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp(-x) tmp = 0 if x <= -3.8e-188: tmp = (math.exp((x * -eps_m)) + t_0) / 2.0 else: tmp = (math.exp((x * (-1.0 + eps_m))) + t_0) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -3.8e-188) tmp = Float64(Float64(exp(Float64(x * Float64(-eps_m))) + t_0) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) + t_0) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp(-x); tmp = 0.0; if (x <= -3.8e-188) tmp = (exp((x * -eps_m)) + t_0) / 2.0; else tmp = (exp((x * (-1.0 + eps_m))) + t_0) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -3.8e-188], N[(N[(N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -3.8 \cdot 10^{-188}:\\
\;\;\;\;\frac{e^{x \cdot \left(-eps\_m\right)} + t\_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps\_m\right)} + t\_0}{2}\\
\end{array}
\end{array}
if x < -3.8e-188Initial program 66.2%
Simplified61.3%
Taylor expanded in eps around inf 96.2%
Taylor expanded in eps around inf 96.3%
*-commutative96.3%
Simplified96.3%
Taylor expanded in eps around 0 82.8%
neg-mul-182.8%
Simplified82.8%
if -3.8e-188 < x Initial program 68.1%
Simplified57.6%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around 0 82.4%
Final simplification82.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x 2.05e-230)
(/ (+ (exp (* x (- eps_m))) t_0) 2.0)
(if (<= x 1020000000000.0)
(/
(+
2.0
(*
x
(+
(/ 1.0 eps_m)
(*
(fma eps_m eps_m -1.0)
(/ (+ 1.0 (/ 1.0 eps_m)) (+ 1.0 eps_m))))))
2.0)
(if (or (<= x 8e+127) (not (<= x 1e+274)))
(/ (* 2.0 t_0) 2.0)
(/ (exp x) 2.0))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (x <= 2.05e-230) {
tmp = (exp((x * -eps_m)) + t_0) / 2.0;
} else if (x <= 1020000000000.0) {
tmp = (2.0 + (x * ((1.0 / eps_m) + (fma(eps_m, eps_m, -1.0) * ((1.0 + (1.0 / eps_m)) / (1.0 + eps_m)))))) / 2.0;
} else if ((x <= 8e+127) || !(x <= 1e+274)) {
tmp = (2.0 * t_0) / 2.0;
} else {
tmp = exp(x) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= 2.05e-230) tmp = Float64(Float64(exp(Float64(x * Float64(-eps_m))) + t_0) / 2.0); elseif (x <= 1020000000000.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(1.0 / eps_m) + Float64(fma(eps_m, eps_m, -1.0) * Float64(Float64(1.0 + Float64(1.0 / eps_m)) / Float64(1.0 + eps_m)))))) / 2.0); elseif ((x <= 8e+127) || !(x <= 1e+274)) tmp = Float64(Float64(2.0 * t_0) / 2.0); else tmp = Float64(exp(x) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, 2.05e-230], N[(N[(N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1020000000000.0], N[(N[(2.0 + N[(x * N[(N[(1.0 / eps$95$m), $MachinePrecision] + N[(N[(eps$95$m * eps$95$m + -1.0), $MachinePrecision] * N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 8e+127], N[Not[LessEqual[x, 1e+274]], $MachinePrecision]], N[(N[(2.0 * t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[Exp[x], $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq 2.05 \cdot 10^{-230}:\\
\;\;\;\;\frac{e^{x \cdot \left(-eps\_m\right)} + t\_0}{2}\\
\mathbf{elif}\;x \leq 1020000000000:\\
\;\;\;\;\frac{2 + x \cdot \left(\frac{1}{eps\_m} + \mathsf{fma}\left(eps\_m, eps\_m, -1\right) \cdot \frac{1 + \frac{1}{eps\_m}}{1 + eps\_m}\right)}{2}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+127} \lor \neg \left(x \leq 10^{+274}\right):\\
\;\;\;\;\frac{2 \cdot t\_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x}}{2}\\
\end{array}
\end{array}
if x < 2.0500000000000001e-230Initial program 62.2%
Simplified47.9%
Taylor expanded in eps around inf 97.3%
Taylor expanded in eps around inf 97.3%
*-commutative97.3%
Simplified97.3%
Taylor expanded in eps around 0 87.5%
neg-mul-187.5%
Simplified87.5%
if 2.0500000000000001e-230 < x < 1.02e12Initial program 44.4%
Simplified39.9%
Taylor expanded in x around 0 68.2%
flip--72.6%
+-commutative72.6%
associate-*r/72.6%
metadata-eval72.6%
fma-neg72.6%
metadata-eval72.6%
Applied egg-rr72.6%
*-commutative72.6%
associate-/l*72.5%
+-commutative72.5%
Simplified72.5%
Taylor expanded in eps around 0 72.4%
if 1.02e12 < x < 7.99999999999999964e127 or 9.99999999999999921e273 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around 0 74.7%
Taylor expanded in eps around 0 60.6%
mul-1-neg60.6%
Simplified60.6%
if 7.99999999999999964e127 < x < 9.99999999999999921e273Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 42.3%
Simplified42.3%
Taylor expanded in x around inf 42.3%
exp-neg42.3%
associate-*r/42.3%
*-rgt-identity42.3%
Simplified42.3%
cancel-sign-sub-inv42.3%
div-inv42.3%
exp-neg42.3%
metadata-eval42.3%
*-un-lft-identity42.3%
distribute-rgt-out42.3%
add-sqr-sqrt0.0%
sqrt-unprod59.3%
sqr-neg59.3%
sqrt-unprod59.3%
add-sqr-sqrt59.3%
+-commutative59.3%
Applied egg-rr59.3%
Taylor expanded in x around 0 59.3%
Final simplification77.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 67.4%
Simplified59.0%
Taylor expanded in eps around inf 98.6%
Final simplification98.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (/ (* 2.0 (exp (- x))) 2.0)))
(if (<= x -2.3e-6)
t_0
(if (<= x -4e-188)
(/
(-
2.0
(*
x
(-
(* (+ -1.0 eps_m) (+ -1.0 (/ -1.0 eps_m)))
(/
(* (fma eps_m eps_m -1.0) (- -1.0 (/ -1.0 eps_m)))
(+ -1.0 eps_m)))))
2.0)
(if (<= x 2.2e-231)
(/ (+ 2.0 (* x eps_m)) 2.0)
(if (<= x 840000000000.0)
(/
(+
2.0
(*
x
(+
(/ 1.0 eps_m)
(*
(fma eps_m eps_m -1.0)
(/ (+ 1.0 (/ 1.0 eps_m)) (+ 1.0 eps_m))))))
2.0)
(if (or (<= x 5e+126) (not (<= x 1.1e+274)))
t_0
(/ (exp x) 2.0))))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (2.0 * exp(-x)) / 2.0;
double tmp;
if (x <= -2.3e-6) {
tmp = t_0;
} else if (x <= -4e-188) {
tmp = (2.0 - (x * (((-1.0 + eps_m) * (-1.0 + (-1.0 / eps_m))) - ((fma(eps_m, eps_m, -1.0) * (-1.0 - (-1.0 / eps_m))) / (-1.0 + eps_m))))) / 2.0;
} else if (x <= 2.2e-231) {
tmp = (2.0 + (x * eps_m)) / 2.0;
} else if (x <= 840000000000.0) {
tmp = (2.0 + (x * ((1.0 / eps_m) + (fma(eps_m, eps_m, -1.0) * ((1.0 + (1.0 / eps_m)) / (1.0 + eps_m)))))) / 2.0;
} else if ((x <= 5e+126) || !(x <= 1.1e+274)) {
tmp = t_0;
} else {
tmp = exp(x) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0) tmp = 0.0 if (x <= -2.3e-6) tmp = t_0; elseif (x <= -4e-188) tmp = Float64(Float64(2.0 - Float64(x * Float64(Float64(Float64(-1.0 + eps_m) * Float64(-1.0 + Float64(-1.0 / eps_m))) - Float64(Float64(fma(eps_m, eps_m, -1.0) * Float64(-1.0 - Float64(-1.0 / eps_m))) / Float64(-1.0 + eps_m))))) / 2.0); elseif (x <= 2.2e-231) tmp = Float64(Float64(2.0 + Float64(x * eps_m)) / 2.0); elseif (x <= 840000000000.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(1.0 / eps_m) + Float64(fma(eps_m, eps_m, -1.0) * Float64(Float64(1.0 + Float64(1.0 / eps_m)) / Float64(1.0 + eps_m)))))) / 2.0); elseif ((x <= 5e+126) || !(x <= 1.1e+274)) tmp = t_0; else tmp = Float64(exp(x) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, -2.3e-6], t$95$0, If[LessEqual[x, -4e-188], N[(N[(2.0 - N[(x * N[(N[(N[(-1.0 + eps$95$m), $MachinePrecision] * N[(-1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(eps$95$m * eps$95$m + -1.0), $MachinePrecision] * N[(-1.0 - N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.2e-231], N[(N[(2.0 + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 840000000000.0], N[(N[(2.0 + N[(x * N[(N[(1.0 / eps$95$m), $MachinePrecision] + N[(N[(eps$95$m * eps$95$m + -1.0), $MachinePrecision] * N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 5e+126], N[Not[LessEqual[x, 1.1e+274]], $MachinePrecision]], t$95$0, N[(N[Exp[x], $MachinePrecision] / 2.0), $MachinePrecision]]]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \frac{2 \cdot e^{-x}}{2}\\
\mathbf{if}\;x \leq -2.3 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -4 \cdot 10^{-188}:\\
\;\;\;\;\frac{2 - x \cdot \left(\left(-1 + eps\_m\right) \cdot \left(-1 + \frac{-1}{eps\_m}\right) - \frac{\mathsf{fma}\left(eps\_m, eps\_m, -1\right) \cdot \left(-1 - \frac{-1}{eps\_m}\right)}{-1 + eps\_m}\right)}{2}\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-231}:\\
\;\;\;\;\frac{2 + x \cdot eps\_m}{2}\\
\mathbf{elif}\;x \leq 840000000000:\\
\;\;\;\;\frac{2 + x \cdot \left(\frac{1}{eps\_m} + \mathsf{fma}\left(eps\_m, eps\_m, -1\right) \cdot \frac{1 + \frac{1}{eps\_m}}{1 + eps\_m}\right)}{2}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+126} \lor \neg \left(x \leq 1.1 \cdot 10^{+274}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x}}{2}\\
\end{array}
\end{array}
if x < -2.3e-6 or 8.4e11 < x < 4.99999999999999977e126 or 1.1e274 < x Initial program 96.1%
Simplified96.2%
Taylor expanded in eps around inf 95.4%
Taylor expanded in eps around 0 83.9%
Taylor expanded in eps around 0 75.3%
mul-1-neg75.3%
Simplified75.3%
if -2.3e-6 < x < -3.9999999999999998e-188Initial program 44.1%
Simplified35.1%
Taylor expanded in x around 0 68.3%
flip--34.4%
clear-num34.4%
metadata-eval34.4%
inv-pow34.4%
inv-pow34.4%
pow-prod-up32.6%
metadata-eval32.6%
Applied egg-rr32.6%
+-commutative32.6%
flip-+37.7%
metadata-eval37.7%
fma-neg37.7%
metadata-eval37.7%
associate-*l/37.7%
clear-num37.7%
metadata-eval37.7%
metadata-eval37.7%
pow-prod-up39.5%
inv-pow39.5%
inv-pow39.5%
flip--73.4%
sub-neg73.4%
metadata-eval73.4%
Applied egg-rr73.4%
if -3.9999999999999998e-188 < x < 2.20000000000000009e-231Initial program 51.6%
Simplified12.4%
Taylor expanded in x around 0 97.3%
Taylor expanded in eps around 0 97.2%
Taylor expanded in eps around 0 97.2%
if 2.20000000000000009e-231 < x < 8.4e11Initial program 44.4%
Simplified39.9%
Taylor expanded in x around 0 68.2%
flip--72.6%
+-commutative72.6%
associate-*r/72.6%
metadata-eval72.6%
fma-neg72.6%
metadata-eval72.6%
Applied egg-rr72.6%
*-commutative72.6%
associate-/l*72.5%
+-commutative72.5%
Simplified72.5%
Taylor expanded in eps around 0 72.4%
if 4.99999999999999977e126 < x < 1.1e274Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 42.3%
Simplified42.3%
Taylor expanded in x around inf 42.3%
exp-neg42.3%
associate-*r/42.3%
*-rgt-identity42.3%
Simplified42.3%
cancel-sign-sub-inv42.3%
div-inv42.3%
exp-neg42.3%
metadata-eval42.3%
*-un-lft-identity42.3%
distribute-rgt-out42.3%
add-sqr-sqrt0.0%
sqrt-unprod59.3%
sqr-neg59.3%
sqrt-unprod59.3%
add-sqr-sqrt59.3%
+-commutative59.3%
Applied egg-rr59.3%
Taylor expanded in x around 0 59.3%
Final simplification75.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (/ (* 2.0 (exp (- x))) 2.0)))
(if (<= x 5e-232)
t_0
(if (<= x 540000000000.0)
(/
(+
2.0
(*
x
(+
(/ 1.0 eps_m)
(*
(fma eps_m eps_m -1.0)
(/ (+ 1.0 (/ 1.0 eps_m)) (+ 1.0 eps_m))))))
2.0)
(if (or (<= x 5e+126) (not (<= x 1e+274))) t_0 (/ (exp x) 2.0))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (2.0 * exp(-x)) / 2.0;
double tmp;
if (x <= 5e-232) {
tmp = t_0;
} else if (x <= 540000000000.0) {
tmp = (2.0 + (x * ((1.0 / eps_m) + (fma(eps_m, eps_m, -1.0) * ((1.0 + (1.0 / eps_m)) / (1.0 + eps_m)))))) / 2.0;
} else if ((x <= 5e+126) || !(x <= 1e+274)) {
tmp = t_0;
} else {
tmp = exp(x) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0) tmp = 0.0 if (x <= 5e-232) tmp = t_0; elseif (x <= 540000000000.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(1.0 / eps_m) + Float64(fma(eps_m, eps_m, -1.0) * Float64(Float64(1.0 + Float64(1.0 / eps_m)) / Float64(1.0 + eps_m)))))) / 2.0); elseif ((x <= 5e+126) || !(x <= 1e+274)) tmp = t_0; else tmp = Float64(exp(x) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, 5e-232], t$95$0, If[LessEqual[x, 540000000000.0], N[(N[(2.0 + N[(x * N[(N[(1.0 / eps$95$m), $MachinePrecision] + N[(N[(eps$95$m * eps$95$m + -1.0), $MachinePrecision] * N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 5e+126], N[Not[LessEqual[x, 1e+274]], $MachinePrecision]], t$95$0, N[(N[Exp[x], $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \frac{2 \cdot e^{-x}}{2}\\
\mathbf{if}\;x \leq 5 \cdot 10^{-232}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 540000000000:\\
\;\;\;\;\frac{2 + x \cdot \left(\frac{1}{eps\_m} + \mathsf{fma}\left(eps\_m, eps\_m, -1\right) \cdot \frac{1 + \frac{1}{eps\_m}}{1 + eps\_m}\right)}{2}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+126} \lor \neg \left(x \leq 10^{+274}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x}}{2}\\
\end{array}
\end{array}
if x < 4.9999999999999999e-232 or 5.4e11 < x < 4.99999999999999977e126 or 9.99999999999999921e273 < x Initial program 70.2%
Simplified58.9%
Taylor expanded in eps around inf 97.8%
Taylor expanded in eps around 0 88.3%
Taylor expanded in eps around 0 77.9%
mul-1-neg77.9%
Simplified77.9%
if 4.9999999999999999e-232 < x < 5.4e11Initial program 44.4%
Simplified39.9%
Taylor expanded in x around 0 68.2%
flip--72.6%
+-commutative72.6%
associate-*r/72.6%
metadata-eval72.6%
fma-neg72.6%
metadata-eval72.6%
Applied egg-rr72.6%
*-commutative72.6%
associate-/l*72.5%
+-commutative72.5%
Simplified72.5%
Taylor expanded in eps around 0 72.4%
if 4.99999999999999977e126 < x < 9.99999999999999921e273Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 42.3%
Simplified42.3%
Taylor expanded in x around inf 42.3%
exp-neg42.3%
associate-*r/42.3%
*-rgt-identity42.3%
Simplified42.3%
cancel-sign-sub-inv42.3%
div-inv42.3%
exp-neg42.3%
metadata-eval42.3%
*-un-lft-identity42.3%
distribute-rgt-out42.3%
add-sqr-sqrt0.0%
sqrt-unprod59.3%
sqr-neg59.3%
sqrt-unprod59.3%
add-sqr-sqrt59.3%
+-commutative59.3%
Applied egg-rr59.3%
Taylor expanded in x around 0 59.3%
Final simplification74.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 3.2e-18)
(/
(+ 2.0 (* x (- (/ -1.0 eps_m) (* (- -1.0 eps_m) (- -1.0 (/ -1.0 eps_m))))))
2.0)
(if (or (<= x 5e+63) (not (<= x 9e+273)))
(/ (/ 0.0 eps_m) 2.0)
(/ (exp x) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 3.2e-18) {
tmp = (2.0 + (x * ((-1.0 / eps_m) - ((-1.0 - eps_m) * (-1.0 - (-1.0 / eps_m)))))) / 2.0;
} else if ((x <= 5e+63) || !(x <= 9e+273)) {
tmp = (0.0 / eps_m) / 2.0;
} else {
tmp = 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 <= 3.2d-18) then
tmp = (2.0d0 + (x * (((-1.0d0) / eps_m) - (((-1.0d0) - eps_m) * ((-1.0d0) - ((-1.0d0) / eps_m)))))) / 2.0d0
else if ((x <= 5d+63) .or. (.not. (x <= 9d+273))) then
tmp = (0.0d0 / eps_m) / 2.0d0
else
tmp = 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 <= 3.2e-18) {
tmp = (2.0 + (x * ((-1.0 / eps_m) - ((-1.0 - eps_m) * (-1.0 - (-1.0 / eps_m)))))) / 2.0;
} else if ((x <= 5e+63) || !(x <= 9e+273)) {
tmp = (0.0 / eps_m) / 2.0;
} else {
tmp = Math.exp(x) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 3.2e-18: tmp = (2.0 + (x * ((-1.0 / eps_m) - ((-1.0 - eps_m) * (-1.0 - (-1.0 / eps_m)))))) / 2.0 elif (x <= 5e+63) or not (x <= 9e+273): tmp = (0.0 / eps_m) / 2.0 else: tmp = math.exp(x) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 3.2e-18) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(-1.0 / eps_m) - Float64(Float64(-1.0 - eps_m) * Float64(-1.0 - Float64(-1.0 / eps_m)))))) / 2.0); elseif ((x <= 5e+63) || !(x <= 9e+273)) tmp = Float64(Float64(0.0 / eps_m) / 2.0); else tmp = Float64(exp(x) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 3.2e-18) tmp = (2.0 + (x * ((-1.0 / eps_m) - ((-1.0 - eps_m) * (-1.0 - (-1.0 / eps_m)))))) / 2.0; elseif ((x <= 5e+63) || ~((x <= 9e+273))) tmp = (0.0 / eps_m) / 2.0; else tmp = exp(x) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 3.2e-18], N[(N[(2.0 + N[(x * N[(N[(-1.0 / eps$95$m), $MachinePrecision] - N[(N[(-1.0 - eps$95$m), $MachinePrecision] * N[(-1.0 - N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 5e+63], N[Not[LessEqual[x, 9e+273]], $MachinePrecision]], N[(N[(0.0 / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[Exp[x], $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{2 + x \cdot \left(\frac{-1}{eps\_m} - \left(-1 - eps\_m\right) \cdot \left(-1 - \frac{-1}{eps\_m}\right)\right)}{2}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+63} \lor \neg \left(x \leq 9 \cdot 10^{+273}\right):\\
\;\;\;\;\frac{\frac{0}{eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x}}{2}\\
\end{array}
\end{array}
if x < 3.1999999999999999e-18Initial program 55.2%
Simplified43.6%
Taylor expanded in x around 0 61.1%
flip--65.4%
+-commutative65.4%
associate-*r/65.4%
metadata-eval65.4%
fma-neg65.4%
metadata-eval65.4%
Applied egg-rr65.4%
*-commutative65.4%
associate-/l*65.8%
+-commutative65.8%
Simplified65.8%
Taylor expanded in eps around 0 64.4%
if 3.1999999999999999e-18 < x < 5.00000000000000011e63 or 8.99999999999999987e273 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 56.7%
Taylor expanded in x around 0 56.7%
if 5.00000000000000011e63 < x < 8.99999999999999987e273Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 45.3%
Simplified45.3%
Taylor expanded in x around inf 45.3%
exp-neg45.3%
associate-*r/45.3%
*-rgt-identity45.3%
Simplified45.3%
cancel-sign-sub-inv45.3%
div-inv45.3%
exp-neg45.3%
metadata-eval45.3%
*-un-lft-identity45.3%
distribute-rgt-out45.3%
add-sqr-sqrt0.0%
sqrt-unprod56.3%
sqr-neg56.3%
sqrt-unprod56.3%
add-sqr-sqrt56.3%
+-commutative56.3%
Applied egg-rr56.3%
Taylor expanded in x around 0 56.3%
Final simplification62.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (or (<= x 1e+127) (not (<= x 1.2e+274))) (/ (* 2.0 (exp (- x))) 2.0) (/ (exp x) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if ((x <= 1e+127) || !(x <= 1.2e+274)) {
tmp = (2.0 * exp(-x)) / 2.0;
} else {
tmp = 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 <= 1d+127) .or. (.not. (x <= 1.2d+274))) then
tmp = (2.0d0 * exp(-x)) / 2.0d0
else
tmp = 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 <= 1e+127) || !(x <= 1.2e+274)) {
tmp = (2.0 * Math.exp(-x)) / 2.0;
} else {
tmp = Math.exp(x) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if (x <= 1e+127) or not (x <= 1.2e+274): tmp = (2.0 * math.exp(-x)) / 2.0 else: tmp = math.exp(x) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if ((x <= 1e+127) || !(x <= 1.2e+274)) tmp = Float64(Float64(2.0 * exp(Float64(-x))) / 2.0); else tmp = Float64(exp(x) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if ((x <= 1e+127) || ~((x <= 1.2e+274))) tmp = (2.0 * exp(-x)) / 2.0; else tmp = exp(x) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[Or[LessEqual[x, 1e+127], N[Not[LessEqual[x, 1.2e+274]], $MachinePrecision]], N[(N[(2.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[Exp[x], $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+127} \lor \neg \left(x \leq 1.2 \cdot 10^{+274}\right):\\
\;\;\;\;\frac{2 \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x}}{2}\\
\end{array}
\end{array}
if x < 9.99999999999999955e126 or 1.2e274 < x Initial program 63.3%
Simplified53.8%
Taylor expanded in eps around inf 98.4%
Taylor expanded in eps around 0 86.3%
Taylor expanded in eps around 0 75.7%
mul-1-neg75.7%
Simplified75.7%
if 9.99999999999999955e126 < x < 1.2e274Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 42.3%
Simplified42.3%
Taylor expanded in x around inf 42.3%
exp-neg42.3%
associate-*r/42.3%
*-rgt-identity42.3%
Simplified42.3%
cancel-sign-sub-inv42.3%
div-inv42.3%
exp-neg42.3%
metadata-eval42.3%
*-un-lft-identity42.3%
distribute-rgt-out42.3%
add-sqr-sqrt0.0%
sqrt-unprod59.3%
sqr-neg59.3%
sqrt-unprod59.3%
add-sqr-sqrt59.3%
+-commutative59.3%
Applied egg-rr59.3%
Taylor expanded in x around 0 59.3%
Final simplification73.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 3.2e-18)
(/
(+ 2.0 (* x (- (/ -1.0 eps_m) (* (- -1.0 eps_m) (- -1.0 (/ -1.0 eps_m))))))
2.0)
(/ (/ 0.0 eps_m) 2.0)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 3.2e-18) {
tmp = (2.0 + (x * ((-1.0 / eps_m) - ((-1.0 - eps_m) * (-1.0 - (-1.0 / eps_m)))))) / 2.0;
} else {
tmp = (0.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 (x <= 3.2d-18) then
tmp = (2.0d0 + (x * (((-1.0d0) / eps_m) - (((-1.0d0) - eps_m) * ((-1.0d0) - ((-1.0d0) / eps_m)))))) / 2.0d0
else
tmp = (0.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 (x <= 3.2e-18) {
tmp = (2.0 + (x * ((-1.0 / eps_m) - ((-1.0 - eps_m) * (-1.0 - (-1.0 / eps_m)))))) / 2.0;
} else {
tmp = (0.0 / eps_m) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 3.2e-18: tmp = (2.0 + (x * ((-1.0 / eps_m) - ((-1.0 - eps_m) * (-1.0 - (-1.0 / eps_m)))))) / 2.0 else: tmp = (0.0 / eps_m) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 3.2e-18) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(-1.0 / eps_m) - Float64(Float64(-1.0 - eps_m) * Float64(-1.0 - Float64(-1.0 / eps_m)))))) / 2.0); else tmp = Float64(Float64(0.0 / eps_m) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 3.2e-18) tmp = (2.0 + (x * ((-1.0 / eps_m) - ((-1.0 - eps_m) * (-1.0 - (-1.0 / eps_m)))))) / 2.0; else tmp = (0.0 / eps_m) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 3.2e-18], N[(N[(2.0 + N[(x * N[(N[(-1.0 / eps$95$m), $MachinePrecision] - N[(N[(-1.0 - eps$95$m), $MachinePrecision] * N[(-1.0 - N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.0 / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2 \cdot 10^{-18}:\\
\;\;\;\;\frac{2 + x \cdot \left(\frac{-1}{eps\_m} - \left(-1 - eps\_m\right) \cdot \left(-1 - \frac{-1}{eps\_m}\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < 3.1999999999999999e-18Initial program 55.2%
Simplified43.6%
Taylor expanded in x around 0 61.1%
flip--65.4%
+-commutative65.4%
associate-*r/65.4%
metadata-eval65.4%
fma-neg65.4%
metadata-eval65.4%
Applied egg-rr65.4%
*-commutative65.4%
associate-/l*65.8%
+-commutative65.8%
Simplified65.8%
Taylor expanded in eps around 0 64.4%
if 3.1999999999999999e-18 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 49.4%
Taylor expanded in x around 0 49.4%
Final simplification60.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 500.0) 1.0 (/ (/ 0.0 eps_m) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 500.0) {
tmp = 1.0;
} else {
tmp = (0.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 (x <= 500.0d0) then
tmp = 1.0d0
else
tmp = (0.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 (x <= 500.0) {
tmp = 1.0;
} else {
tmp = (0.0 / eps_m) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 500.0: tmp = 1.0 else: tmp = (0.0 / eps_m) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 500.0) tmp = 1.0; else tmp = Float64(Float64(0.0 / eps_m) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 500.0) tmp = 1.0; else tmp = (0.0 / eps_m) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 500.0], 1.0, N[(N[(0.0 / eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 500:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0}{eps\_m}}{2}\\
\end{array}
\end{array}
if x < 500Initial program 56.1%
Simplified56.1%
Taylor expanded in x around 0 59.9%
if 500 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 52.3%
Taylor expanded in x around 0 52.3%
Final simplification57.9%
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 67.4%
Simplified67.4%
Taylor expanded in x around 0 45.2%
Final simplification45.2%
herbie shell --seed 2024043
(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))