
(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 1.529e-38)
(/ (+ 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 <= 1.529e-38) {
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 <= 1.529d-38) 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 <= 1.529e-38) {
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 <= 1.529e-38: 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 <= 1.529e-38) 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 <= 1.529e-38) 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, 1.529e-38], 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 1.529 \cdot 10^{-38}:\\
\;\;\;\;\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 < 1.529e-38Initial program 68.2%
div-sub68.2%
+-rgt-identity68.2%
div-sub68.2%
Simplified68.2%
Taylor expanded in eps around 0 66.6%
*-commutative66.6%
distribute-lft1-in66.6%
neg-mul-166.6%
distribute-lft-out66.6%
mul-1-neg66.6%
*-commutative66.6%
distribute-lft1-in67.2%
neg-mul-167.2%
Simplified67.2%
if 1.529e-38 < eps Initial program 97.3%
div-sub97.3%
+-rgt-identity97.3%
div-sub97.3%
Simplified97.3%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification76.5%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (+ x 1.0) (exp (- x)))))
(if (<= eps 1.0)
(/ (+ t_0 t_0) 2.0)
(/ (+ (exp (* eps (- x))) (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 <= 1.0) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (exp((eps * -x)) + 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 <= 1.0d0) then
tmp = (t_0 + t_0) / 2.0d0
else
tmp = (exp((eps * -x)) + 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 <= 1.0) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (Math.exp((eps * -x)) + 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 <= 1.0: tmp = (t_0 + t_0) / 2.0 else: tmp = (math.exp((eps * -x)) + 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 <= 1.0) tmp = Float64(Float64(t_0 + t_0) / 2.0); else tmp = Float64(Float64(exp(Float64(eps * Float64(-x))) + exp(Float64(eps * 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 <= 1.0) tmp = (t_0 + t_0) / 2.0; else tmp = (exp((eps * -x)) + 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, 1.0], N[(N[(t$95$0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(eps * (-x)), $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 1:\\
\;\;\;\;\frac{t_0 + t_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\varepsilon \cdot \left(-x\right)} + e^{\varepsilon \cdot x}}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 68.2%
div-sub68.2%
+-rgt-identity68.2%
div-sub68.2%
Simplified68.2%
Taylor expanded in eps around 0 67.7%
*-commutative67.7%
distribute-lft1-in67.7%
neg-mul-167.7%
distribute-lft-out67.7%
mul-1-neg67.7%
*-commutative67.7%
distribute-lft1-in68.2%
neg-mul-168.2%
Simplified68.2%
if 1 < 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 inf 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
associate-*r*100.0%
mul-1-neg100.0%
Simplified100.0%
Final simplification76.5%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -2e-293)
(/ (+ t_0 (exp (* x (- -1.0 eps)))) 2.0)
(if (or (<= x 1e+14) (and (not (<= x 1e+46)) (<= x 1.5e+159)))
(* 0.5 (+ (+ (exp (* x (+ eps 1.0))) 1.0) (* eps x)))
(/ (* t_0 2.0) 2.0)))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if (x <= -2e-293) {
tmp = (t_0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if ((x <= 1e+14) || (!(x <= 1e+46) && (x <= 1.5e+159))) {
tmp = 0.5 * ((exp((x * (eps + 1.0))) + 1.0) + (eps * x));
} else {
tmp = (t_0 * 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) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (x <= (-2d-293)) then
tmp = (t_0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else if ((x <= 1d+14) .or. (.not. (x <= 1d+46)) .and. (x <= 1.5d+159)) then
tmp = 0.5d0 * ((exp((x * (eps + 1.0d0))) + 1.0d0) + (eps * x))
else
tmp = (t_0 * 2.0d0) / 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 (x <= -2e-293) {
tmp = (t_0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else if ((x <= 1e+14) || (!(x <= 1e+46) && (x <= 1.5e+159))) {
tmp = 0.5 * ((Math.exp((x * (eps + 1.0))) + 1.0) + (eps * x));
} else {
tmp = (t_0 * 2.0) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = math.exp(-x) tmp = 0 if x <= -2e-293: tmp = (t_0 + math.exp((x * (-1.0 - eps)))) / 2.0 elif (x <= 1e+14) or (not (x <= 1e+46) and (x <= 1.5e+159)): tmp = 0.5 * ((math.exp((x * (eps + 1.0))) + 1.0) + (eps * x)) else: tmp = (t_0 * 2.0) / 2.0 return tmp
eps = abs(eps) function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -2e-293) tmp = Float64(Float64(t_0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif ((x <= 1e+14) || (!(x <= 1e+46) && (x <= 1.5e+159))) tmp = Float64(0.5 * Float64(Float64(exp(Float64(x * Float64(eps + 1.0))) + 1.0) + Float64(eps * x))); else tmp = Float64(Float64(t_0 * 2.0) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) t_0 = exp(-x); tmp = 0.0; if (x <= -2e-293) tmp = (t_0 + exp((x * (-1.0 - eps)))) / 2.0; elseif ((x <= 1e+14) || (~((x <= 1e+46)) && (x <= 1.5e+159))) tmp = 0.5 * ((exp((x * (eps + 1.0))) + 1.0) + (eps * x)); else tmp = (t_0 * 2.0) / 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[x, -2e-293], N[(N[(t$95$0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 1e+14], And[N[Not[LessEqual[x, 1e+46]], $MachinePrecision], LessEqual[x, 1.5e+159]]], N[(0.5 * N[(N[(N[Exp[N[(x * N[(eps + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] + N[(eps * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * 2.0), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-293}:\\
\;\;\;\;\frac{t_0 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 10^{+14} \lor \neg \left(x \leq 10^{+46}\right) \land x \leq 1.5 \cdot 10^{+159}:\\
\;\;\;\;0.5 \cdot \left(\left(e^{x \cdot \left(\varepsilon + 1\right)} + 1\right) + \varepsilon \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 \cdot 2}{2}\\
\end{array}
\end{array}
if x < -2.0000000000000001e-293Initial program 78.7%
div-sub78.7%
+-rgt-identity78.7%
div-sub78.7%
Simplified78.7%
Taylor expanded in eps around inf 96.6%
Taylor expanded in eps around 0 82.0%
if -2.0000000000000001e-293 < x < 1e14 or 9.9999999999999999e45 < x < 1.5000000000000001e159Initial program 64.7%
div-sub64.7%
+-rgt-identity64.7%
div-sub64.7%
Simplified51.4%
Taylor expanded in x around 0 35.9%
Taylor expanded in eps around inf 70.2%
Taylor expanded in x around inf 70.2%
distribute-lft-out70.2%
mul-1-neg70.2%
mul-1-neg70.2%
*-commutative70.2%
Simplified70.2%
add-sqr-sqrt48.7%
sqrt-unprod58.1%
sqr-neg58.1%
sqrt-unprod9.4%
add-sqr-sqrt69.9%
neg-sub069.9%
distribute-rgt-in69.9%
*-un-lft-identity69.9%
fma-def69.9%
Applied egg-rr69.9%
neg-sub069.9%
fma-def69.9%
distribute-lft1-in69.9%
distribute-lft-neg-in69.9%
*-commutative69.9%
neg-sub069.9%
+-commutative69.9%
associate--r+69.9%
metadata-eval69.9%
Simplified69.9%
if 1e14 < x < 9.9999999999999999e45 or 1.5000000000000001e159 < 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 84.3%
Taylor expanded in eps around 0 68.7%
cancel-sign-sub-inv68.7%
metadata-eval68.7%
distribute-rgt1-in68.7%
metadata-eval68.7%
neg-mul-168.7%
Simplified68.7%
Final simplification74.7%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= eps 1.0) (/ (* (exp (- x)) 2.0) 2.0) (/ (+ (exp (* eps (- x))) (exp (* eps x))) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (eps <= 1.0) {
tmp = (exp(-x) * 2.0) / 2.0;
} else {
tmp = (exp((eps * -x)) + 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) :: tmp
if (eps <= 1.0d0) then
tmp = (exp(-x) * 2.0d0) / 2.0d0
else
tmp = (exp((eps * -x)) + exp((eps * x))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (eps <= 1.0) {
tmp = (Math.exp(-x) * 2.0) / 2.0;
} else {
tmp = (Math.exp((eps * -x)) + Math.exp((eps * x))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if eps <= 1.0: tmp = (math.exp(-x) * 2.0) / 2.0 else: tmp = (math.exp((eps * -x)) + math.exp((eps * x))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (eps <= 1.0) tmp = Float64(Float64(exp(Float64(-x)) * 2.0) / 2.0); else tmp = Float64(Float64(exp(Float64(eps * Float64(-x))) + exp(Float64(eps * x))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 1.0) tmp = (exp(-x) * 2.0) / 2.0; else tmp = (exp((eps * -x)) + exp((eps * x))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[eps, 1.0], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1:\\
\;\;\;\;\frac{e^{-x} \cdot 2}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\varepsilon \cdot \left(-x\right)} + e^{\varepsilon \cdot x}}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 68.2%
div-sub68.2%
+-rgt-identity68.2%
div-sub68.2%
Simplified68.2%
Taylor expanded in eps around inf 97.5%
Taylor expanded in eps around 0 89.5%
Taylor expanded in eps around 0 77.4%
cancel-sign-sub-inv77.4%
metadata-eval77.4%
distribute-rgt1-in77.4%
metadata-eval77.4%
neg-mul-177.4%
Simplified77.4%
if 1 < 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 inf 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
associate-*r*100.0%
mul-1-neg100.0%
Simplified100.0%
Final simplification83.3%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x -18.0)
(+ 0.5 (/ 0.5 (exp x)))
(if (<= x 5e-295)
(* 0.5 (+ (exp (- (- x) (* eps x))) (+ (* eps x) 1.0)))
(if (or (<= x 3e+14) (and (not (<= x 3e+45)) (<= x 1e+159)))
(* 0.5 (+ (+ (exp (* x (+ eps 1.0))) 1.0) (* eps x)))
(/ (* (exp (- x)) 2.0) 2.0)))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -18.0) {
tmp = 0.5 + (0.5 / exp(x));
} else if (x <= 5e-295) {
tmp = 0.5 * (exp((-x - (eps * x))) + ((eps * x) + 1.0));
} else if ((x <= 3e+14) || (!(x <= 3e+45) && (x <= 1e+159))) {
tmp = 0.5 * ((exp((x * (eps + 1.0))) + 1.0) + (eps * x));
} 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 <= (-18.0d0)) then
tmp = 0.5d0 + (0.5d0 / exp(x))
else if (x <= 5d-295) then
tmp = 0.5d0 * (exp((-x - (eps * x))) + ((eps * x) + 1.0d0))
else if ((x <= 3d+14) .or. (.not. (x <= 3d+45)) .and. (x <= 1d+159)) then
tmp = 0.5d0 * ((exp((x * (eps + 1.0d0))) + 1.0d0) + (eps * x))
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 <= -18.0) {
tmp = 0.5 + (0.5 / Math.exp(x));
} else if (x <= 5e-295) {
tmp = 0.5 * (Math.exp((-x - (eps * x))) + ((eps * x) + 1.0));
} else if ((x <= 3e+14) || (!(x <= 3e+45) && (x <= 1e+159))) {
tmp = 0.5 * ((Math.exp((x * (eps + 1.0))) + 1.0) + (eps * x));
} else {
tmp = (Math.exp(-x) * 2.0) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -18.0: tmp = 0.5 + (0.5 / math.exp(x)) elif x <= 5e-295: tmp = 0.5 * (math.exp((-x - (eps * x))) + ((eps * x) + 1.0)) elif (x <= 3e+14) or (not (x <= 3e+45) and (x <= 1e+159)): tmp = 0.5 * ((math.exp((x * (eps + 1.0))) + 1.0) + (eps * x)) else: tmp = (math.exp(-x) * 2.0) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -18.0) tmp = Float64(0.5 + Float64(0.5 / exp(x))); elseif (x <= 5e-295) tmp = Float64(0.5 * Float64(exp(Float64(Float64(-x) - Float64(eps * x))) + Float64(Float64(eps * x) + 1.0))); elseif ((x <= 3e+14) || (!(x <= 3e+45) && (x <= 1e+159))) tmp = Float64(0.5 * Float64(Float64(exp(Float64(x * Float64(eps + 1.0))) + 1.0) + Float64(eps * x))); 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 <= -18.0) tmp = 0.5 + (0.5 / exp(x)); elseif (x <= 5e-295) tmp = 0.5 * (exp((-x - (eps * x))) + ((eps * x) + 1.0)); elseif ((x <= 3e+14) || (~((x <= 3e+45)) && (x <= 1e+159))) tmp = 0.5 * ((exp((x * (eps + 1.0))) + 1.0) + (eps * x)); 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, -18.0], N[(0.5 + N[(0.5 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e-295], N[(0.5 * N[(N[Exp[N[((-x) - N[(eps * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[(eps * x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 3e+14], And[N[Not[LessEqual[x, 3e+45]], $MachinePrecision], LessEqual[x, 1e+159]]], N[(0.5 * N[(N[(N[Exp[N[(x * N[(eps + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] + N[(eps * x), $MachinePrecision]), $MachinePrecision]), $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 -18:\\
\;\;\;\;0.5 + \frac{0.5}{e^{x}}\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-295}:\\
\;\;\;\;0.5 \cdot \left(e^{\left(-x\right) - \varepsilon \cdot x} + \left(\varepsilon \cdot x + 1\right)\right)\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+14} \lor \neg \left(x \leq 3 \cdot 10^{+45}\right) \land x \leq 10^{+159}:\\
\;\;\;\;0.5 \cdot \left(\left(e^{x \cdot \left(\varepsilon + 1\right)} + 1\right) + \varepsilon \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{-x} \cdot 2}{2}\\
\end{array}
\end{array}
if x < -18Initial program 93.0%
div-sub93.0%
+-rgt-identity93.0%
div-sub93.0%
Simplified93.2%
Taylor expanded in x around 0 47.3%
Taylor expanded in eps around inf 44.7%
Taylor expanded in x around inf 44.7%
distribute-lft-out44.7%
mul-1-neg44.7%
mul-1-neg44.7%
*-commutative44.7%
Simplified44.7%
Taylor expanded in eps around 0 92.9%
distribute-lft-in92.9%
metadata-eval92.9%
exp-neg92.9%
associate-*r/92.9%
metadata-eval92.9%
Simplified92.9%
if -18 < x < 5.00000000000000008e-295Initial program 67.7%
div-sub67.7%
+-rgt-identity67.7%
div-sub67.7%
Simplified38.4%
Taylor expanded in x around 0 46.5%
Taylor expanded in eps around inf 77.9%
Taylor expanded in x around inf 77.9%
distribute-lft-out77.9%
mul-1-neg77.9%
mul-1-neg77.9%
*-commutative77.9%
Simplified77.9%
Taylor expanded in x around inf 77.9%
if 5.00000000000000008e-295 < x < 3e14 or 3.00000000000000011e45 < x < 9.9999999999999993e158Initial program 65.5%
div-sub65.5%
+-rgt-identity65.5%
div-sub65.5%
Simplified54.1%
Taylor expanded in x around 0 35.3%
Taylor expanded in eps around inf 68.7%
Taylor expanded in x around inf 68.7%
distribute-lft-out68.7%
mul-1-neg68.7%
mul-1-neg68.7%
*-commutative68.7%
Simplified68.7%
add-sqr-sqrt48.9%
sqrt-unprod55.9%
sqr-neg55.9%
sqrt-unprod7.0%
add-sqr-sqrt68.7%
neg-sub068.7%
distribute-rgt-in68.7%
*-un-lft-identity68.7%
fma-def68.7%
Applied egg-rr68.7%
neg-sub068.7%
fma-def68.7%
distribute-lft1-in68.7%
distribute-lft-neg-in68.7%
*-commutative68.7%
neg-sub068.7%
+-commutative68.7%
associate--r+68.7%
metadata-eval68.7%
Simplified68.7%
if 3e14 < x < 3.00000000000000011e45 or 9.9999999999999993e158 < 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 84.3%
Taylor expanded in eps around 0 68.7%
cancel-sign-sub-inv68.7%
metadata-eval68.7%
distribute-rgt1-in68.7%
metadata-eval68.7%
neg-mul-168.7%
Simplified68.7%
Final simplification75.2%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= eps 1.0) (/ (* (exp (- x)) 2.0) 2.0) (* 0.5 (+ (exp (- (- x) (* eps x))) (+ (* eps x) 1.0)))))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (eps <= 1.0) {
tmp = (exp(-x) * 2.0) / 2.0;
} else {
tmp = 0.5 * (exp((-x - (eps * x))) + ((eps * x) + 1.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 (eps <= 1.0d0) then
tmp = (exp(-x) * 2.0d0) / 2.0d0
else
tmp = 0.5d0 * (exp((-x - (eps * x))) + ((eps * x) + 1.0d0))
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (eps <= 1.0) {
tmp = (Math.exp(-x) * 2.0) / 2.0;
} else {
tmp = 0.5 * (Math.exp((-x - (eps * x))) + ((eps * x) + 1.0));
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if eps <= 1.0: tmp = (math.exp(-x) * 2.0) / 2.0 else: tmp = 0.5 * (math.exp((-x - (eps * x))) + ((eps * x) + 1.0)) return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (eps <= 1.0) tmp = Float64(Float64(exp(Float64(-x)) * 2.0) / 2.0); else tmp = Float64(0.5 * Float64(exp(Float64(Float64(-x) - Float64(eps * x))) + Float64(Float64(eps * x) + 1.0))); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 1.0) tmp = (exp(-x) * 2.0) / 2.0; else tmp = 0.5 * (exp((-x - (eps * x))) + ((eps * x) + 1.0)); end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[eps, 1.0], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(0.5 * N[(N[Exp[N[((-x) - N[(eps * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[(eps * x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1:\\
\;\;\;\;\frac{e^{-x} \cdot 2}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{\left(-x\right) - \varepsilon \cdot x} + \left(\varepsilon \cdot x + 1\right)\right)\\
\end{array}
\end{array}
if eps < 1Initial program 68.2%
div-sub68.2%
+-rgt-identity68.2%
div-sub68.2%
Simplified68.2%
Taylor expanded in eps around inf 97.5%
Taylor expanded in eps around 0 89.5%
Taylor expanded in eps around 0 77.4%
cancel-sign-sub-inv77.4%
metadata-eval77.4%
distribute-rgt1-in77.4%
metadata-eval77.4%
neg-mul-177.4%
Simplified77.4%
if 1 < eps Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified81.2%
Taylor expanded in x around 0 65.5%
Taylor expanded in eps around inf 65.5%
Taylor expanded in x around inf 65.5%
distribute-lft-out65.5%
mul-1-neg65.5%
mul-1-neg65.5%
*-commutative65.5%
Simplified65.5%
Taylor expanded in x around inf 65.5%
Final simplification74.3%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= eps 3.1e+243) (/ (* (exp (- x)) 2.0) 2.0) (* 0.5 (* eps x))))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (eps <= 3.1e+243) {
tmp = (exp(-x) * 2.0) / 2.0;
} else {
tmp = 0.5 * (eps * x);
}
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 (eps <= 3.1d+243) then
tmp = (exp(-x) * 2.0d0) / 2.0d0
else
tmp = 0.5d0 * (eps * x)
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (eps <= 3.1e+243) {
tmp = (Math.exp(-x) * 2.0) / 2.0;
} else {
tmp = 0.5 * (eps * x);
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if eps <= 3.1e+243: tmp = (math.exp(-x) * 2.0) / 2.0 else: tmp = 0.5 * (eps * x) return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (eps <= 3.1e+243) tmp = Float64(Float64(exp(Float64(-x)) * 2.0) / 2.0); else tmp = Float64(0.5 * Float64(eps * x)); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 3.1e+243) tmp = (exp(-x) * 2.0) / 2.0; else tmp = 0.5 * (eps * x); end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[eps, 3.1e+243], N[(N[(N[Exp[(-x)], $MachinePrecision] * 2.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(0.5 * N[(eps * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 3.1 \cdot 10^{+243}:\\
\;\;\;\;\frac{e^{-x} \cdot 2}{2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\varepsilon \cdot x\right)\\
\end{array}
\end{array}
if eps < 3.1e243Initial program 74.4%
div-sub74.4%
+-rgt-identity74.4%
div-sub74.4%
Simplified74.4%
Taylor expanded in eps around inf 98.0%
Taylor expanded in eps around 0 85.0%
Taylor expanded in eps around 0 73.7%
cancel-sign-sub-inv73.7%
metadata-eval73.7%
distribute-rgt1-in73.7%
metadata-eval73.7%
neg-mul-173.7%
Simplified73.7%
if 3.1e243 < eps Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified91.5%
Taylor expanded in x around 0 70.7%
Taylor expanded in eps around inf 39.7%
*-commutative39.7%
*-commutative39.7%
Simplified39.7%
Final simplification70.9%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 980000000.0) (+ 0.5 (/ 0.5 (exp x))) 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 980000000.0) {
tmp = 0.5 + (0.5 / exp(x));
} 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 <= 980000000.0d0) then
tmp = 0.5d0 + (0.5d0 / exp(x))
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 <= 980000000.0) {
tmp = 0.5 + (0.5 / Math.exp(x));
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 980000000.0: tmp = 0.5 + (0.5 / math.exp(x)) else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 980000000.0) tmp = Float64(0.5 + Float64(0.5 / exp(x))); else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 980000000.0) tmp = 0.5 + (0.5 / exp(x)); else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 980000000.0], N[(0.5 + N[(0.5 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 980000000:\\
\;\;\;\;0.5 + \frac{0.5}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 9.8e8Initial program 66.6%
div-sub66.6%
+-rgt-identity66.6%
div-sub66.6%
Simplified49.0%
Taylor expanded in x around 0 42.8%
Taylor expanded in eps around inf 72.9%
Taylor expanded in x around inf 72.9%
distribute-lft-out72.9%
mul-1-neg72.9%
mul-1-neg72.9%
*-commutative72.9%
Simplified72.9%
Taylor expanded in eps around 0 74.3%
distribute-lft-in74.3%
metadata-eval74.3%
exp-neg74.3%
associate-*r/74.3%
metadata-eval74.3%
Simplified74.3%
if 9.8e8 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 57.3%
div-sub57.3%
rec-exp57.3%
neg-mul-157.3%
+-inverses57.3%
Simplified57.3%
Final simplification69.2%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 150.0) (/ (+ 2.0 (* x (+ (* (- -1.0 eps) (+ (/ -1.0 eps) 1.0)) (/ -1.0 eps)))) 2.0) 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 150.0) {
tmp = (2.0 + (x * (((-1.0 - eps) * ((-1.0 / eps) + 1.0)) + (-1.0 / eps)))) / 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 <= 150.0d0) then
tmp = (2.0d0 + (x * ((((-1.0d0) - eps) * (((-1.0d0) / eps) + 1.0d0)) + ((-1.0d0) / eps)))) / 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 <= 150.0) {
tmp = (2.0 + (x * (((-1.0 - eps) * ((-1.0 / eps) + 1.0)) + (-1.0 / eps)))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 150.0: tmp = (2.0 + (x * (((-1.0 - eps) * ((-1.0 / eps) + 1.0)) + (-1.0 / eps)))) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 150.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(-1.0 - eps) * Float64(Float64(-1.0 / eps) + 1.0)) + Float64(-1.0 / eps)))) / 2.0); else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 150.0) tmp = (2.0 + (x * (((-1.0 - eps) * ((-1.0 / eps) + 1.0)) + (-1.0 / eps)))) / 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, 150.0], N[(N[(2.0 + N[(x * N[(N[(N[(-1.0 - eps), $MachinePrecision] * N[(N[(-1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 150:\\
\;\;\;\;\frac{2 + x \cdot \left(\left(-1 - \varepsilon\right) \cdot \left(\frac{-1}{\varepsilon} + 1\right) + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 150Initial program 66.4%
Simplified55.0%
Taylor expanded in x around 0 54.1%
Taylor expanded in eps around 0 57.9%
if 150 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 56.5%
div-sub56.5%
rec-exp56.5%
neg-mul-156.5%
+-inverses56.5%
Simplified56.5%
Final simplification57.5%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 4.4e-9) (/ (- 2.0 (* x (+ eps 2.0))) 2.0) 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 4.4e-9) {
tmp = (2.0 - (x * (eps + 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 <= 4.4d-9) then
tmp = (2.0d0 - (x * (eps + 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 <= 4.4e-9) {
tmp = (2.0 - (x * (eps + 2.0))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 4.4e-9: tmp = (2.0 - (x * (eps + 2.0))) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 4.4e-9) tmp = Float64(Float64(2.0 - Float64(x * Float64(eps + 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 <= 4.4e-9) tmp = (2.0 - (x * (eps + 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, 4.4e-9], N[(N[(2.0 - N[(x * N[(eps + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.4 \cdot 10^{-9}:\\
\;\;\;\;\frac{2 - x \cdot \left(\varepsilon + 2\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 4.3999999999999997e-9Initial program 66.0%
div-sub66.0%
+-rgt-identity66.0%
div-sub66.0%
Simplified66.0%
Taylor expanded in eps around inf 97.7%
Taylor expanded in eps around 0 84.9%
Taylor expanded in x around 0 58.9%
mul-1-neg58.9%
unsub-neg58.9%
*-commutative58.9%
+-commutative58.9%
Simplified58.9%
if 4.3999999999999997e-9 < x Initial program 98.8%
Simplified98.8%
Taylor expanded in eps around 0 53.2%
div-sub53.2%
rec-exp53.2%
neg-mul-153.2%
+-inverses53.2%
Simplified53.2%
Final simplification57.0%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 980000000.0) 1.0 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 980000000.0) {
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 <= 980000000.0d0) 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 <= 980000000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 980000000.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 980000000.0) 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 <= 980000000.0) 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, 980000000.0], 1.0, 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 980000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 9.8e8Initial program 66.6%
div-sub66.6%
+-rgt-identity66.6%
div-sub66.6%
Simplified49.0%
Taylor expanded in x around 0 42.8%
Taylor expanded in eps around inf 72.9%
Taylor expanded in x around 0 53.8%
if 9.8e8 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 57.3%
div-sub57.3%
rec-exp57.3%
neg-mul-157.3%
+-inverses57.3%
Simplified57.3%
Final simplification54.9%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 1.0)
eps = abs(eps);
double code(double x, double eps) {
return 1.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 = 1.0d0
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
return 1.0;
}
eps = abs(eps) def code(x, eps): return 1.0
eps = abs(eps) function code(x, eps) return 1.0 end
eps = abs(eps) function tmp = code(x, eps) tmp = 1.0; end
NOTE: eps should be positive before calling this function code[x_, eps_] := 1.0
\begin{array}{l}
eps = |eps|\\
\\
1
\end{array}
Initial program 76.5%
div-sub76.5%
+-rgt-identity76.5%
div-sub76.5%
Simplified64.2%
Taylor expanded in x around 0 38.3%
Taylor expanded in eps around inf 59.7%
Taylor expanded in x around 0 38.8%
Final simplification38.8%
herbie shell --seed 2023200
(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))