
(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 12 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}
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (+ x 1.0) (exp (- x)))))
(if (<= eps 3e-79)
(/ (+ t_0 t_0) 2.0)
(/ (+ (exp (* x (+ eps -1.0))) (exp (* eps (- x)))) 2.0))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = (x + 1.0) * exp(-x);
double tmp;
if (eps <= 3e-79) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (exp((x * (eps + -1.0))) + exp((eps * -x))) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = (x + 1.0d0) * exp(-x)
if (eps <= 3d-79) then
tmp = (t_0 + t_0) / 2.0d0
else
tmp = (exp((x * (eps + (-1.0d0)))) + exp((eps * -x))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double t_0 = (x + 1.0) * Math.exp(-x);
double tmp;
if (eps <= 3e-79) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (Math.exp((x * (eps + -1.0))) + Math.exp((eps * -x))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = (x + 1.0) * math.exp(-x) tmp = 0 if eps <= 3e-79: tmp = (t_0 + t_0) / 2.0 else: tmp = (math.exp((x * (eps + -1.0))) + math.exp((eps * -x))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) t_0 = Float64(Float64(x + 1.0) * exp(Float64(-x))) tmp = 0.0 if (eps <= 3e-79) tmp = Float64(Float64(t_0 + t_0) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + exp(Float64(eps * Float64(-x)))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) t_0 = (x + 1.0) * exp(-x); tmp = 0.0; if (eps <= 3e-79) tmp = (t_0 + t_0) / 2.0; else tmp = (exp((x * (eps + -1.0))) + exp((eps * -x))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function
code[x_, eps_] := Block[{t$95$0 = N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, 3e-79], N[(N[(t$95$0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := \left(x + 1\right) \cdot e^{-x}\\
\mathbf{if}\;\varepsilon \leq 3 \cdot 10^{-79}:\\
\;\;\;\;\frac{t_0 + t_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(\varepsilon + -1\right)} + e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\end{array}
\end{array}
if eps < 3e-79Initial program 60.9%
div-sub60.9%
+-rgt-identity60.9%
div-sub60.9%
Simplified60.9%
Taylor expanded in eps around 0 71.1%
*-commutative71.1%
distribute-lft1-in71.1%
neg-mul-171.1%
distribute-lft-out71.1%
mul-1-neg71.1%
*-commutative71.1%
distribute-lft1-in72.3%
neg-mul-172.3%
Simplified72.3%
if 3e-79 < eps Initial program 87.4%
div-sub87.4%
+-rgt-identity87.4%
div-sub87.4%
Simplified87.4%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification81.5%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -2e-261) (/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0) (/ (+ (exp (- x)) (exp (* x (+ eps -1.0)))) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -2e-261) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else {
tmp = (exp(-x) + exp((x * (eps + -1.0)))) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-2d-261)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else
tmp = (exp(-x) + exp((x * (eps + (-1.0d0))))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -2e-261) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else {
tmp = (Math.exp(-x) + Math.exp((x * (eps + -1.0)))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -2e-261: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 else: tmp = (math.exp(-x) + math.exp((x * (eps + -1.0)))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -2e-261) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); else tmp = Float64(Float64(exp(Float64(-x)) + exp(Float64(x * Float64(eps + -1.0)))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2e-261) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; else tmp = (exp(-x) + exp((x * (eps + -1.0)))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -2e-261], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[(-x)], $MachinePrecision] + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-261}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{-x} + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
\end{array}
\end{array}
if x < -1.99999999999999997e-261Initial program 66.3%
div-sub66.3%
+-rgt-identity66.3%
div-sub66.3%
Simplified56.1%
Taylor expanded in x around 0 41.8%
Taylor expanded in eps around inf 70.7%
if -1.99999999999999997e-261 < x Initial program 71.8%
div-sub71.8%
+-rgt-identity71.8%
div-sub71.8%
Simplified71.8%
Taylor expanded in eps around inf 99.8%
Taylor expanded in eps around 0 85.1%
Taylor expanded in eps around -inf 85.1%
cancel-sign-sub-inv85.1%
associate-*r*85.1%
neg-mul-185.1%
sub-neg85.1%
mul-1-neg85.1%
metadata-eval85.1%
neg-mul-185.1%
*-lft-identity85.1%
Simplified85.1%
Final simplification79.6%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (let* ((t_0 (exp (- x)))) (if (<= eps 1.4e-6) (/ (* t_0 2.0) 2.0) (/ (+ t_0 (exp (* eps x))) 2.0))))
eps = abs(eps);
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if (eps <= 1.4e-6) {
tmp = (t_0 * 2.0) / 2.0;
} else {
tmp = (t_0 + exp((eps * x))) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (eps <= 1.4d-6) then
tmp = (t_0 * 2.0d0) / 2.0d0
else
tmp = (t_0 + exp((eps * x))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double t_0 = Math.exp(-x);
double tmp;
if (eps <= 1.4e-6) {
tmp = (t_0 * 2.0) / 2.0;
} else {
tmp = (t_0 + Math.exp((eps * x))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = math.exp(-x) tmp = 0 if eps <= 1.4e-6: tmp = (t_0 * 2.0) / 2.0 else: tmp = (t_0 + math.exp((eps * x))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (eps <= 1.4e-6) tmp = Float64(Float64(t_0 * 2.0) / 2.0); else tmp = Float64(Float64(t_0 + exp(Float64(eps * x))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) t_0 = exp(-x); tmp = 0.0; if (eps <= 1.4e-6) tmp = (t_0 * 2.0) / 2.0; else tmp = (t_0 + exp((eps * x))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[eps, 1.4e-6], N[(N[(t$95$0 * 2.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;\varepsilon \leq 1.4 \cdot 10^{-6}:\\
\;\;\;\;\frac{t_0 \cdot 2}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 + e^{\varepsilon \cdot x}}{2}\\
\end{array}
\end{array}
if eps < 1.39999999999999994e-6Initial program 57.6%
div-sub57.6%
+-rgt-identity57.6%
div-sub57.6%
Simplified57.6%
Taylor expanded in eps around inf 97.7%
Taylor expanded in eps around 0 85.1%
Taylor expanded in eps around 0 81.7%
cancel-sign-sub-inv81.7%
neg-mul-181.7%
metadata-eval81.7%
neg-mul-181.7%
*-lft-identity81.7%
count-281.7%
Simplified81.7%
if 1.39999999999999994e-6 < eps Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around 0 84.5%
Taylor expanded in eps around -inf 84.5%
cancel-sign-sub-inv84.5%
associate-*r*84.5%
neg-mul-184.5%
sub-neg84.5%
mul-1-neg84.5%
metadata-eval84.5%
neg-mul-184.5%
*-lft-identity84.5%
Simplified84.5%
Taylor expanded in eps around inf 84.5%
*-commutative84.5%
Simplified84.5%
Final simplification82.5%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x 7.5e-228)
(/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0)
(if (<= x 8.4e+38)
(/
(-
2.0
(*
x
(+
(* (+ eps 1.0) (+ 1.0 (/ -1.0 eps)))
(/ (+ -1.0 (/ -1.0 eps)) (/ (+ eps 1.0) (fma eps eps -1.0))))))
2.0)
(/ (* (exp (- x)) 2.0) 2.0))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 7.5e-228) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 8.4e+38) {
tmp = (2.0 - (x * (((eps + 1.0) * (1.0 + (-1.0 / eps))) + ((-1.0 + (-1.0 / eps)) / ((eps + 1.0) / fma(eps, eps, -1.0)))))) / 2.0;
} else {
tmp = (exp(-x) * 2.0) / 2.0;
}
return tmp;
}
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 7.5e-228) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif (x <= 8.4e+38) tmp = Float64(Float64(2.0 - Float64(x * Float64(Float64(Float64(eps + 1.0) * Float64(1.0 + Float64(-1.0 / eps))) + Float64(Float64(-1.0 + Float64(-1.0 / eps)) / Float64(Float64(eps + 1.0) / fma(eps, eps, -1.0)))))) / 2.0); else tmp = Float64(Float64(exp(Float64(-x)) * 2.0) / 2.0); end return tmp end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 7.5e-228], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 8.4e+38], N[(N[(2.0 - N[(x * N[(N[(N[(eps + 1.0), $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] / N[(N[(eps + 1.0), $MachinePrecision] / N[(eps * eps + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.5 \cdot 10^{-228}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 8.4 \cdot 10^{+38}:\\
\;\;\;\;\frac{2 - x \cdot \left(\left(\varepsilon + 1\right) \cdot \left(1 + \frac{-1}{\varepsilon}\right) + \frac{-1 + \frac{-1}{\varepsilon}}{\frac{\varepsilon + 1}{\mathsf{fma}\left(\varepsilon, \varepsilon, -1\right)}}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{-x} \cdot 2}{2}\\
\end{array}
\end{array}
if x < 7.4999999999999999e-228Initial program 62.2%
div-sub62.2%
+-rgt-identity62.2%
div-sub62.2%
Simplified44.7%
Taylor expanded in x around 0 43.1%
Taylor expanded in eps around inf 77.3%
if 7.4999999999999999e-228 < x < 8.4e38Initial program 57.4%
Simplified43.2%
Taylor expanded in x around 0 61.0%
+-commutative61.0%
*-rgt-identity61.0%
flip--73.7%
+-commutative73.7%
associate-*r/73.7%
*-rgt-identity73.7%
inv-pow73.7%
metadata-eval73.7%
fma-neg73.7%
metadata-eval73.7%
+-commutative73.7%
Applied egg-rr73.7%
associate-/l*73.7%
unpow-173.7%
Simplified73.7%
if 8.4e38 < x Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around 0 81.6%
Taylor expanded in eps around 0 56.6%
cancel-sign-sub-inv56.6%
neg-mul-156.6%
metadata-eval56.6%
neg-mul-156.6%
*-lft-identity56.6%
count-256.6%
Simplified56.6%
Final simplification71.6%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x 6.2e-228)
(/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0)
(if (<= x 1.12e+39)
(/
(+
2.0
(*
x
(+
(/ 1.0 eps)
(/ (- 1.0 (/ -1.0 eps)) (/ (+ eps 1.0) (fma eps eps -1.0))))))
2.0)
(/ (* (exp (- x)) 2.0) 2.0))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 6.2e-228) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 1.12e+39) {
tmp = (2.0 + (x * ((1.0 / eps) + ((1.0 - (-1.0 / eps)) / ((eps + 1.0) / fma(eps, eps, -1.0)))))) / 2.0;
} else {
tmp = (exp(-x) * 2.0) / 2.0;
}
return tmp;
}
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 6.2e-228) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif (x <= 1.12e+39) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(1.0 / eps) + Float64(Float64(1.0 - Float64(-1.0 / eps)) / Float64(Float64(eps + 1.0) / fma(eps, eps, -1.0)))))) / 2.0); else tmp = Float64(Float64(exp(Float64(-x)) * 2.0) / 2.0); end return tmp end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 6.2e-228], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.12e+39], N[(N[(2.0 + N[(x * N[(N[(1.0 / eps), $MachinePrecision] + N[(N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] / N[(N[(eps + 1.0), $MachinePrecision] / N[(eps * eps + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.2 \cdot 10^{-228}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{+39}:\\
\;\;\;\;\frac{2 + x \cdot \left(\frac{1}{\varepsilon} + \frac{1 - \frac{-1}{\varepsilon}}{\frac{\varepsilon + 1}{\mathsf{fma}\left(\varepsilon, \varepsilon, -1\right)}}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{-x} \cdot 2}{2}\\
\end{array}
\end{array}
if x < 6.1999999999999996e-228Initial program 62.2%
div-sub62.2%
+-rgt-identity62.2%
div-sub62.2%
Simplified44.7%
Taylor expanded in x around 0 43.1%
Taylor expanded in eps around inf 77.3%
if 6.1999999999999996e-228 < x < 1.12e39Initial program 57.4%
Simplified43.2%
Taylor expanded in x around 0 61.0%
+-commutative61.0%
*-rgt-identity61.0%
flip--73.7%
+-commutative73.7%
associate-*r/73.7%
*-rgt-identity73.7%
inv-pow73.7%
metadata-eval73.7%
fma-neg73.7%
metadata-eval73.7%
+-commutative73.7%
Applied egg-rr73.7%
associate-/l*73.7%
unpow-173.7%
Simplified73.7%
Taylor expanded in eps around 0 73.5%
if 1.12e39 < x Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around 0 81.6%
Taylor expanded in eps around 0 56.6%
cancel-sign-sub-inv56.6%
neg-mul-156.6%
metadata-eval56.6%
neg-mul-156.6%
*-lft-identity56.6%
count-256.6%
Simplified56.6%
Final simplification71.6%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -2.45e-241) (/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0) (/ (* (exp (- x)) 2.0) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -2.45e-241) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else {
tmp = (exp(-x) * 2.0) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-2.45d-241)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else
tmp = (exp(-x) * 2.0d0) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -2.45e-241) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else {
tmp = (Math.exp(-x) * 2.0) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -2.45e-241: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 else: tmp = (math.exp(-x) * 2.0) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -2.45e-241) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); else tmp = Float64(Float64(exp(Float64(-x)) * 2.0) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -2.45e-241) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; else tmp = (exp(-x) * 2.0) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -2.45e-241], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.45 \cdot 10^{-241}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{-x} \cdot 2}{2}\\
\end{array}
\end{array}
if x < -2.4499999999999999e-241Initial program 68.0%
div-sub68.0%
+-rgt-identity68.0%
div-sub68.0%
Simplified58.3%
Taylor expanded in x around 0 42.7%
Taylor expanded in eps around inf 69.7%
if -2.4499999999999999e-241 < x Initial program 70.7%
div-sub70.7%
+-rgt-identity70.7%
div-sub70.7%
Simplified70.7%
Taylor expanded in eps around inf 99.8%
Taylor expanded in eps around 0 85.3%
Taylor expanded in eps around 0 68.1%
cancel-sign-sub-inv68.1%
neg-mul-168.1%
metadata-eval68.1%
neg-mul-168.1%
*-lft-identity68.1%
count-268.1%
Simplified68.1%
Final simplification68.7%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (or (<= x -1.15e+20) (not (<= x -2e-240)))
(/ (* (exp (- x)) 2.0) 2.0)
(/
(+
2.0
(*
x
(+
(* (+ eps -1.0) (- 1.0 (/ -1.0 eps)))
(/ (+ -1.0 (* eps eps)) (- eps)))))
2.0)))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if ((x <= -1.15e+20) || !(x <= -2e-240)) {
tmp = (exp(-x) * 2.0) / 2.0;
} else {
tmp = (2.0 + (x * (((eps + -1.0) * (1.0 - (-1.0 / eps))) + ((-1.0 + (eps * eps)) / -eps)))) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((x <= (-1.15d+20)) .or. (.not. (x <= (-2d-240)))) then
tmp = (exp(-x) * 2.0d0) / 2.0d0
else
tmp = (2.0d0 + (x * (((eps + (-1.0d0)) * (1.0d0 - ((-1.0d0) / eps))) + (((-1.0d0) + (eps * eps)) / -eps)))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if ((x <= -1.15e+20) || !(x <= -2e-240)) {
tmp = (Math.exp(-x) * 2.0) / 2.0;
} else {
tmp = (2.0 + (x * (((eps + -1.0) * (1.0 - (-1.0 / eps))) + ((-1.0 + (eps * eps)) / -eps)))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if (x <= -1.15e+20) or not (x <= -2e-240): tmp = (math.exp(-x) * 2.0) / 2.0 else: tmp = (2.0 + (x * (((eps + -1.0) * (1.0 - (-1.0 / eps))) + ((-1.0 + (eps * eps)) / -eps)))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if ((x <= -1.15e+20) || !(x <= -2e-240)) tmp = Float64(Float64(exp(Float64(-x)) * 2.0) / 2.0); else tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(eps + -1.0) * Float64(1.0 - Float64(-1.0 / eps))) + Float64(Float64(-1.0 + Float64(eps * eps)) / Float64(-eps))))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -1.15e+20) || ~((x <= -2e-240))) tmp = (exp(-x) * 2.0) / 2.0; else tmp = (2.0 + (x * (((eps + -1.0) * (1.0 - (-1.0 / eps))) + ((-1.0 + (eps * eps)) / -eps)))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[Or[LessEqual[x, -1.15e+20], N[Not[LessEqual[x, -2e-240]], $MachinePrecision]], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(x * N[(N[(N[(eps + -1.0), $MachinePrecision] * N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 + N[(eps * eps), $MachinePrecision]), $MachinePrecision] / (-eps)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{+20} \lor \neg \left(x \leq -2 \cdot 10^{-240}\right):\\
\;\;\;\;\frac{e^{-x} \cdot 2}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + x \cdot \left(\left(\varepsilon + -1\right) \cdot \left(1 - \frac{-1}{\varepsilon}\right) + \frac{-1 + \varepsilon \cdot \varepsilon}{-\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < -1.15e20 or -1.9999999999999999e-240 < x Initial program 75.5%
div-sub75.5%
+-rgt-identity75.5%
div-sub75.5%
Simplified75.5%
Taylor expanded in eps around inf 99.8%
Taylor expanded in eps around 0 87.7%
Taylor expanded in eps around 0 73.3%
cancel-sign-sub-inv73.3%
neg-mul-173.3%
metadata-eval73.3%
neg-mul-173.3%
*-lft-identity73.3%
count-273.3%
Simplified73.3%
if -1.15e20 < x < -1.9999999999999999e-240Initial program 51.4%
Simplified42.9%
Taylor expanded in x around 0 64.2%
+-commutative64.2%
*-commutative64.2%
flip-+77.9%
associate-*r/77.9%
sub-neg77.9%
distribute-neg-frac77.9%
metadata-eval77.9%
metadata-eval77.9%
Applied egg-rr77.9%
*-commutative77.9%
associate-/l*77.9%
metadata-eval77.9%
distribute-neg-frac77.9%
unpow-177.9%
sub-neg77.9%
unpow-177.9%
Simplified77.9%
Taylor expanded in eps around 0 77.9%
neg-mul-177.9%
Simplified77.9%
Final simplification74.5%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -4.7e-241) (/ (- 2.0 (* x (/ (* eps (- 2.0 eps)) (- 2.0 eps)))) 2.0) (if (<= x 7.4e+24) 1.0 0.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -4.7e-241) {
tmp = (2.0 - (x * ((eps * (2.0 - eps)) / (2.0 - eps)))) / 2.0;
} else if (x <= 7.4e+24) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-4.7d-241)) then
tmp = (2.0d0 - (x * ((eps * (2.0d0 - eps)) / (2.0d0 - eps)))) / 2.0d0
else if (x <= 7.4d+24) then
tmp = 1.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -4.7e-241) {
tmp = (2.0 - (x * ((eps * (2.0 - eps)) / (2.0 - eps)))) / 2.0;
} else if (x <= 7.4e+24) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -4.7e-241: tmp = (2.0 - (x * ((eps * (2.0 - eps)) / (2.0 - eps)))) / 2.0 elif x <= 7.4e+24: tmp = 1.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -4.7e-241) tmp = Float64(Float64(2.0 - Float64(x * Float64(Float64(eps * Float64(2.0 - eps)) / Float64(2.0 - eps)))) / 2.0); elseif (x <= 7.4e+24) tmp = 1.0; else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -4.7e-241) tmp = (2.0 - (x * ((eps * (2.0 - eps)) / (2.0 - eps)))) / 2.0; elseif (x <= 7.4e+24) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -4.7e-241], N[(N[(2.0 - N[(x * N[(N[(eps * N[(2.0 - eps), $MachinePrecision]), $MachinePrecision] / N[(2.0 - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 7.4e+24], 1.0, 0.0]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.7 \cdot 10^{-241}:\\
\;\;\;\;\frac{2 - x \cdot \frac{\varepsilon \cdot \left(2 - \varepsilon\right)}{2 - \varepsilon}}{2}\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{+24}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -4.6999999999999999e-241Initial program 68.0%
div-sub68.0%
+-rgt-identity68.0%
div-sub68.0%
Simplified68.0%
Taylor expanded in eps around inf 96.0%
Taylor expanded in eps around 0 84.2%
Taylor expanded in x around 0 54.9%
flip--31.9%
neg-mul-131.9%
neg-mul-131.9%
sqr-neg31.9%
pow231.9%
metadata-eval31.9%
add-sqr-sqrt4.3%
sqrt-unprod41.3%
neg-mul-141.3%
neg-mul-141.3%
sqr-neg41.3%
sqrt-unprod37.1%
add-sqr-sqrt59.9%
Applied egg-rr59.9%
unpow259.9%
difference-of-sqr-159.9%
+-commutative59.9%
associate-+r-59.9%
metadata-eval59.9%
rem-square-sqrt37.1%
fma-neg37.1%
metadata-eval37.1%
fma-udef37.1%
rem-square-sqrt59.9%
+-commutative59.9%
associate-+r-59.9%
metadata-eval59.9%
neg-sub059.9%
+-commutative59.9%
associate-+r-59.9%
metadata-eval59.9%
Simplified59.9%
if -4.6999999999999999e-241 < x < 7.39999999999999998e24Initial program 52.5%
div-sub52.5%
+-rgt-identity52.5%
div-sub52.5%
Simplified52.5%
Taylor expanded in x around 0 76.2%
if 7.39999999999999998e24 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 55.5%
div-sub55.5%
rec-exp55.5%
neg-mul-155.5%
+-inverses55.5%
Simplified55.5%
Final simplification65.2%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 1.0) (/ (+ 2.0 (* x -2.0)) 2.0) 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 1.0) {
tmp = (2.0 + (x * -2.0)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 1.0d0) then
tmp = (2.0d0 + (x * (-2.0d0))) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 1.0) {
tmp = (2.0 + (x * -2.0)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 1.0: tmp = (2.0 + (x * -2.0)) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(2.0 + Float64(x * -2.0)) / 2.0); else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 1.0) tmp = (2.0 + (x * -2.0)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 1.0], N[(N[(2.0 + N[(x * -2.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{2 + x \cdot -2}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1Initial program 59.8%
div-sub59.8%
+-rgt-identity59.8%
div-sub59.8%
Simplified59.8%
Taylor expanded in eps around inf 97.9%
Taylor expanded in eps around 0 86.1%
Taylor expanded in x around 0 65.7%
Taylor expanded in eps around 0 61.0%
if 1 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 54.7%
div-sub54.7%
rec-exp54.7%
neg-mul-154.7%
+-inverses54.7%
Simplified54.7%
Final simplification59.5%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 8e-6) (/ (- 2.0 (* eps x)) 2.0) 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 8e-6) {
tmp = (2.0 - (eps * x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 8d-6) then
tmp = (2.0d0 - (eps * x)) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 8e-6) {
tmp = (2.0 - (eps * x)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 8e-6: tmp = (2.0 - (eps * x)) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 8e-6) tmp = Float64(Float64(2.0 - Float64(eps * x)) / 2.0); else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 8e-6) tmp = (2.0 - (eps * x)) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 8e-6], N[(N[(2.0 - N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8 \cdot 10^{-6}:\\
\;\;\;\;\frac{2 - \varepsilon \cdot x}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 7.99999999999999964e-6Initial program 59.6%
div-sub59.6%
+-rgt-identity59.6%
div-sub59.6%
Simplified42.7%
Taylor expanded in x around 0 40.7%
Taylor expanded in x around 0 41.5%
Taylor expanded in eps around inf 63.7%
mul-1-neg63.7%
*-commutative63.7%
distribute-lft-neg-in63.7%
Simplified63.7%
if 7.99999999999999964e-6 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 53.9%
div-sub53.9%
rec-exp53.9%
neg-mul-153.9%
+-inverses53.9%
Simplified53.9%
Final simplification61.2%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 7.4e+24) 1.0 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 7.4e+24) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 7.4d+24) then
tmp = 1.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 7.4e+24) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 7.4e+24: tmp = 1.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 7.4e+24) tmp = 1.0; else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 7.4e+24) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 7.4e+24], 1.0, 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.4 \cdot 10^{+24}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 7.39999999999999998e24Initial program 60.0%
div-sub60.0%
+-rgt-identity60.0%
div-sub60.0%
Simplified60.0%
Taylor expanded in x around 0 60.3%
if 7.39999999999999998e24 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 55.5%
div-sub55.5%
rec-exp55.5%
neg-mul-155.5%
+-inverses55.5%
Simplified55.5%
Final simplification59.2%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 0.0)
eps = abs(eps);
double code(double x, double eps) {
return 0.0;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
return 0.0;
}
eps = abs(eps) def code(x, eps): return 0.0
eps = abs(eps) function code(x, eps) return 0.0 end
eps = abs(eps) function tmp = code(x, eps) tmp = 0.0; end
NOTE: eps should be positive before calling this function code[x_, eps_] := 0.0
\begin{array}{l}
eps = |eps|\\
\\
0
\end{array}
Initial program 69.7%
Simplified63.5%
Taylor expanded in eps around 0 15.1%
div-sub15.1%
rec-exp15.1%
neg-mul-115.1%
+-inverses15.4%
Simplified15.4%
Final simplification15.4%
herbie shell --seed 2023208
(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))