
(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 15 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 (if (<= x 2.4) (/ (+ (exp (* x eps)) (exp (* x (- eps)))) 2.0) (/ (+ (exp (- (* x eps) x)) (exp (- x))) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 2.4) {
tmp = (exp((x * eps)) + exp((x * -eps))) / 2.0;
} else {
tmp = (exp(((x * eps) - x)) + exp(-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 (x <= 2.4d0) then
tmp = (exp((x * eps)) + exp((x * -eps))) / 2.0d0
else
tmp = (exp(((x * eps) - x)) + exp(-x)) / 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.4) {
tmp = (Math.exp((x * eps)) + Math.exp((x * -eps))) / 2.0;
} else {
tmp = (Math.exp(((x * eps) - x)) + Math.exp(-x)) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 2.4: tmp = (math.exp((x * eps)) + math.exp((x * -eps))) / 2.0 else: tmp = (math.exp(((x * eps) - x)) + math.exp(-x)) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 2.4) tmp = Float64(Float64(exp(Float64(x * eps)) + exp(Float64(x * Float64(-eps)))) / 2.0); else tmp = Float64(Float64(exp(Float64(Float64(x * eps) - x)) + exp(Float64(-x))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 2.4) tmp = (exp((x * eps)) + exp((x * -eps))) / 2.0; else tmp = (exp(((x * eps) - x)) + exp(-x)) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 2.4], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(N[(x * eps), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} + e^{x \cdot \left(-\varepsilon\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon - x} + e^{-x}}{2}\\
\end{array}
\end{array}
if x < 2.39999999999999991Initial program 63.5%
div-sub63.5%
+-rgt-identity63.5%
div-sub63.5%
Simplified63.5%
Taylor expanded in eps around inf 98.5%
mul-1-neg98.5%
*-commutative98.5%
mul-1-neg98.5%
associate-*r*98.5%
+-commutative98.5%
associate-*r*98.5%
mul-1-neg98.5%
*-commutative98.5%
distribute-rgt-neg-in98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in eps around inf 98.5%
associate-*r*98.5%
neg-mul-198.5%
Simplified98.5%
Taylor expanded in x around inf 98.5%
mul-1-neg98.5%
Simplified98.5%
Taylor expanded in eps around inf 99.3%
if 2.39999999999999991 < x Initial program 99.2%
div-sub99.2%
+-rgt-identity99.2%
div-sub99.2%
Simplified99.2%
Taylor expanded in eps around inf 99.0%
mul-1-neg99.0%
*-commutative99.0%
mul-1-neg99.0%
associate-*r*99.0%
+-commutative99.0%
associate-*r*99.0%
mul-1-neg99.0%
*-commutative99.0%
distribute-rgt-neg-in99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in eps around 0 69.3%
neg-mul-169.3%
Simplified69.3%
Taylor expanded in x around inf 69.3%
Final simplification89.2%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (/ (+ (exp (* x (+ eps -1.0))) (exp (* x (- -1.0 eps)))) 2.0))
eps = abs(eps);
double code(double x, double eps) {
return (exp((x * (eps + -1.0))) + exp((x * (-1.0 - eps)))) / 2.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 = (exp((x * (eps + (-1.0d0)))) + exp((x * ((-1.0d0) - eps)))) / 2.0d0
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
return (Math.exp((x * (eps + -1.0))) + Math.exp((x * (-1.0 - eps)))) / 2.0;
}
eps = abs(eps) def code(x, eps): return (math.exp((x * (eps + -1.0))) + math.exp((x * (-1.0 - eps)))) / 2.0
eps = abs(eps) function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0) end
eps = abs(eps) function tmp = code(x, eps) tmp = (exp((x * (eps + -1.0))) + exp((x * (-1.0 - eps)))) / 2.0; end
NOTE: eps should be positive before calling this function code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps = |eps|\\
\\
\frac{e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}
\end{array}
Initial program 75.5%
div-sub75.5%
+-rgt-identity75.5%
div-sub75.5%
Simplified75.5%
Taylor expanded in eps around inf 98.7%
mul-1-neg98.7%
*-commutative98.7%
mul-1-neg98.7%
associate-*r*98.7%
+-commutative98.7%
associate-*r*98.7%
mul-1-neg98.7%
*-commutative98.7%
distribute-rgt-neg-in98.7%
+-commutative98.7%
Simplified98.7%
Final simplification98.7%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= eps 1.4e-7) (/ (/ 2.0 (exp x)) 2.0) (/ (+ (exp (* x eps)) (exp (* x (- eps)))) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (eps <= 1.4e-7) {
tmp = (2.0 / exp(x)) / 2.0;
} else {
tmp = (exp((x * eps)) + exp((x * -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 (eps <= 1.4d-7) then
tmp = (2.0d0 / exp(x)) / 2.0d0
else
tmp = (exp((x * eps)) + exp((x * -eps))) / 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.4e-7) {
tmp = (2.0 / Math.exp(x)) / 2.0;
} else {
tmp = (Math.exp((x * eps)) + Math.exp((x * -eps))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if eps <= 1.4e-7: tmp = (2.0 / math.exp(x)) / 2.0 else: tmp = (math.exp((x * eps)) + math.exp((x * -eps))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (eps <= 1.4e-7) tmp = Float64(Float64(2.0 / exp(x)) / 2.0); else tmp = Float64(Float64(exp(Float64(x * eps)) + exp(Float64(x * Float64(-eps)))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 1.4e-7) tmp = (2.0 / exp(x)) / 2.0; else tmp = (exp((x * eps)) + exp((x * -eps))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[eps, 1.4e-7], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{2}{e^{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} + e^{x \cdot \left(-\varepsilon\right)}}{2}\\
\end{array}
\end{array}
if eps < 1.4000000000000001e-7Initial program 66.5%
div-sub66.5%
+-rgt-identity66.5%
div-sub66.5%
Simplified66.5%
Taylor expanded in eps around inf 98.2%
mul-1-neg98.2%
*-commutative98.2%
mul-1-neg98.2%
associate-*r*98.2%
+-commutative98.2%
associate-*r*98.2%
mul-1-neg98.2%
*-commutative98.2%
distribute-rgt-neg-in98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in eps around 0 79.5%
neg-mul-179.5%
Simplified79.5%
Taylor expanded in eps around 0 75.2%
exp-neg75.2%
associate-*r/75.2%
metadata-eval75.2%
Simplified75.2%
if 1.4000000000000001e-7 < eps Initial program 99.8%
div-sub99.8%
+-rgt-identity99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in eps around inf 99.8%
mul-1-neg99.8%
*-commutative99.8%
mul-1-neg99.8%
associate-*r*99.8%
+-commutative99.8%
associate-*r*99.8%
mul-1-neg99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in eps around inf 99.8%
associate-*r*99.8%
neg-mul-199.8%
Simplified99.8%
Taylor expanded in x around inf 99.8%
mul-1-neg99.8%
Simplified99.8%
Taylor expanded in eps around inf 99.8%
Final simplification81.9%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (/ 2.0 (exp x)) 2.0))
(t_1 (- (* x eps) x))
(t_2 (/ (- (exp (* x (+ eps -1.0))) -1.0) 2.0)))
(if (<= eps 3e+17)
t_0
(if (<= eps 1.2e+65)
t_2
(if (<= eps 4.6e+120)
t_0
(if (<= eps 4.4e+138)
(/ (+ (exp t_1) (- 1.0 (* x eps))) 2.0)
(if (or (<= eps 3.2e+267) (not (<= eps 1.05e+299)))
(/ (+ (exp (* x (- eps))) (+ 1.0 t_1)) 2.0)
t_2)))))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = (2.0 / exp(x)) / 2.0;
double t_1 = (x * eps) - x;
double t_2 = (exp((x * (eps + -1.0))) - -1.0) / 2.0;
double tmp;
if (eps <= 3e+17) {
tmp = t_0;
} else if (eps <= 1.2e+65) {
tmp = t_2;
} else if (eps <= 4.6e+120) {
tmp = t_0;
} else if (eps <= 4.4e+138) {
tmp = (exp(t_1) + (1.0 - (x * eps))) / 2.0;
} else if ((eps <= 3.2e+267) || !(eps <= 1.05e+299)) {
tmp = (exp((x * -eps)) + (1.0 + t_1)) / 2.0;
} else {
tmp = t_2;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (2.0d0 / exp(x)) / 2.0d0
t_1 = (x * eps) - x
t_2 = (exp((x * (eps + (-1.0d0)))) - (-1.0d0)) / 2.0d0
if (eps <= 3d+17) then
tmp = t_0
else if (eps <= 1.2d+65) then
tmp = t_2
else if (eps <= 4.6d+120) then
tmp = t_0
else if (eps <= 4.4d+138) then
tmp = (exp(t_1) + (1.0d0 - (x * eps))) / 2.0d0
else if ((eps <= 3.2d+267) .or. (.not. (eps <= 1.05d+299))) then
tmp = (exp((x * -eps)) + (1.0d0 + t_1)) / 2.0d0
else
tmp = t_2
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double t_0 = (2.0 / Math.exp(x)) / 2.0;
double t_1 = (x * eps) - x;
double t_2 = (Math.exp((x * (eps + -1.0))) - -1.0) / 2.0;
double tmp;
if (eps <= 3e+17) {
tmp = t_0;
} else if (eps <= 1.2e+65) {
tmp = t_2;
} else if (eps <= 4.6e+120) {
tmp = t_0;
} else if (eps <= 4.4e+138) {
tmp = (Math.exp(t_1) + (1.0 - (x * eps))) / 2.0;
} else if ((eps <= 3.2e+267) || !(eps <= 1.05e+299)) {
tmp = (Math.exp((x * -eps)) + (1.0 + t_1)) / 2.0;
} else {
tmp = t_2;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = (2.0 / math.exp(x)) / 2.0 t_1 = (x * eps) - x t_2 = (math.exp((x * (eps + -1.0))) - -1.0) / 2.0 tmp = 0 if eps <= 3e+17: tmp = t_0 elif eps <= 1.2e+65: tmp = t_2 elif eps <= 4.6e+120: tmp = t_0 elif eps <= 4.4e+138: tmp = (math.exp(t_1) + (1.0 - (x * eps))) / 2.0 elif (eps <= 3.2e+267) or not (eps <= 1.05e+299): tmp = (math.exp((x * -eps)) + (1.0 + t_1)) / 2.0 else: tmp = t_2 return tmp
eps = abs(eps) function code(x, eps) t_0 = Float64(Float64(2.0 / exp(x)) / 2.0) t_1 = Float64(Float64(x * eps) - x) t_2 = Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) - -1.0) / 2.0) tmp = 0.0 if (eps <= 3e+17) tmp = t_0; elseif (eps <= 1.2e+65) tmp = t_2; elseif (eps <= 4.6e+120) tmp = t_0; elseif (eps <= 4.4e+138) tmp = Float64(Float64(exp(t_1) + Float64(1.0 - Float64(x * eps))) / 2.0); elseif ((eps <= 3.2e+267) || !(eps <= 1.05e+299)) tmp = Float64(Float64(exp(Float64(x * Float64(-eps))) + Float64(1.0 + t_1)) / 2.0); else tmp = t_2; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) t_0 = (2.0 / exp(x)) / 2.0; t_1 = (x * eps) - x; t_2 = (exp((x * (eps + -1.0))) - -1.0) / 2.0; tmp = 0.0; if (eps <= 3e+17) tmp = t_0; elseif (eps <= 1.2e+65) tmp = t_2; elseif (eps <= 4.6e+120) tmp = t_0; elseif (eps <= 4.4e+138) tmp = (exp(t_1) + (1.0 - (x * eps))) / 2.0; elseif ((eps <= 3.2e+267) || ~((eps <= 1.05e+299))) tmp = (exp((x * -eps)) + (1.0 + t_1)) / 2.0; else tmp = t_2; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function
code[x_, eps_] := Block[{t$95$0 = N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * eps), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[eps, 3e+17], t$95$0, If[LessEqual[eps, 1.2e+65], t$95$2, If[LessEqual[eps, 4.6e+120], t$95$0, If[LessEqual[eps, 4.4e+138], N[(N[(N[Exp[t$95$1], $MachinePrecision] + N[(1.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[eps, 3.2e+267], N[Not[LessEqual[eps, 1.05e+299]], $MachinePrecision]], N[(N[(N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision] + N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$2]]]]]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := \frac{\frac{2}{e^{x}}}{2}\\
t_1 := x \cdot \varepsilon - x\\
t_2 := \frac{e^{x \cdot \left(\varepsilon + -1\right)} - -1}{2}\\
\mathbf{if}\;\varepsilon \leq 3 \cdot 10^{+17}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 1.2 \cdot 10^{+65}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\varepsilon \leq 4.6 \cdot 10^{+120}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 4.4 \cdot 10^{+138}:\\
\;\;\;\;\frac{e^{t_1} + \left(1 - x \cdot \varepsilon\right)}{2}\\
\mathbf{elif}\;\varepsilon \leq 3.2 \cdot 10^{+267} \lor \neg \left(\varepsilon \leq 1.05 \cdot 10^{+299}\right):\\
\;\;\;\;\frac{e^{x \cdot \left(-\varepsilon\right)} + \left(1 + t_1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if eps < 3e17 or 1.2000000000000001e65 < eps < 4.59999999999999985e120Initial program 68.2%
div-sub68.2%
+-rgt-identity68.2%
div-sub68.2%
Simplified68.2%
Taylor expanded in eps around inf 98.3%
mul-1-neg98.3%
*-commutative98.3%
mul-1-neg98.3%
associate-*r*98.3%
+-commutative98.3%
associate-*r*98.3%
mul-1-neg98.3%
*-commutative98.3%
distribute-rgt-neg-in98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in eps around 0 80.5%
neg-mul-180.5%
Simplified80.5%
Taylor expanded in eps around 0 76.5%
exp-neg76.5%
associate-*r/76.5%
metadata-eval76.5%
Simplified76.5%
if 3e17 < eps < 1.2000000000000001e65 or 3.2000000000000001e267 < eps < 1.05e299Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
mul-1-neg100.0%
*-commutative100.0%
mul-1-neg100.0%
associate-*r*100.0%
+-commutative100.0%
associate-*r*100.0%
mul-1-neg100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 86.2%
if 4.59999999999999985e120 < eps < 4.4000000000000001e138Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
mul-1-neg100.0%
*-commutative100.0%
mul-1-neg100.0%
associate-*r*100.0%
+-commutative100.0%
associate-*r*100.0%
mul-1-neg100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in eps around 0 100.0%
+-commutative100.0%
neg-mul-1100.0%
*-commutative100.0%
unsub-neg100.0%
*-commutative100.0%
Simplified100.0%
if 4.4000000000000001e138 < eps < 3.2000000000000001e267 or 1.05e299 < eps Initial program 99.7%
div-sub99.7%
+-rgt-identity99.7%
div-sub99.7%
Simplified99.7%
Taylor expanded in eps around inf 99.7%
mul-1-neg99.7%
*-commutative99.7%
mul-1-neg99.7%
associate-*r*99.7%
+-commutative99.7%
associate-*r*99.7%
mul-1-neg99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in eps around inf 99.7%
associate-*r*99.7%
neg-mul-199.7%
Simplified99.7%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
Simplified99.7%
Taylor expanded in x around 0 72.1%
*-commutative72.1%
distribute-lft-out--72.1%
*-commutative72.1%
*-rgt-identity72.1%
Simplified72.1%
Final simplification76.6%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (/ 2.0 (exp x)) 2.0))
(t_1 (/ (- (exp (* x (+ eps -1.0))) -1.0) 2.0)))
(if (<= eps 2.8e+17)
t_0
(if (<= eps 3.5e+64)
t_1
(if (<= eps 5.2e+120)
t_0
(if (<= eps 1.05e+138)
(/ (+ (exp (- (* x eps) x)) (- 1.0 (* x eps))) 2.0)
t_1))))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = (2.0 / exp(x)) / 2.0;
double t_1 = (exp((x * (eps + -1.0))) - -1.0) / 2.0;
double tmp;
if (eps <= 2.8e+17) {
tmp = t_0;
} else if (eps <= 3.5e+64) {
tmp = t_1;
} else if (eps <= 5.2e+120) {
tmp = t_0;
} else if (eps <= 1.05e+138) {
tmp = (exp(((x * eps) - x)) + (1.0 - (x * eps))) / 2.0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = (2.0d0 / exp(x)) / 2.0d0
t_1 = (exp((x * (eps + (-1.0d0)))) - (-1.0d0)) / 2.0d0
if (eps <= 2.8d+17) then
tmp = t_0
else if (eps <= 3.5d+64) then
tmp = t_1
else if (eps <= 5.2d+120) then
tmp = t_0
else if (eps <= 1.05d+138) then
tmp = (exp(((x * eps) - x)) + (1.0d0 - (x * eps))) / 2.0d0
else
tmp = t_1
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double t_0 = (2.0 / Math.exp(x)) / 2.0;
double t_1 = (Math.exp((x * (eps + -1.0))) - -1.0) / 2.0;
double tmp;
if (eps <= 2.8e+17) {
tmp = t_0;
} else if (eps <= 3.5e+64) {
tmp = t_1;
} else if (eps <= 5.2e+120) {
tmp = t_0;
} else if (eps <= 1.05e+138) {
tmp = (Math.exp(((x * eps) - x)) + (1.0 - (x * eps))) / 2.0;
} else {
tmp = t_1;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = (2.0 / math.exp(x)) / 2.0 t_1 = (math.exp((x * (eps + -1.0))) - -1.0) / 2.0 tmp = 0 if eps <= 2.8e+17: tmp = t_0 elif eps <= 3.5e+64: tmp = t_1 elif eps <= 5.2e+120: tmp = t_0 elif eps <= 1.05e+138: tmp = (math.exp(((x * eps) - x)) + (1.0 - (x * eps))) / 2.0 else: tmp = t_1 return tmp
eps = abs(eps) function code(x, eps) t_0 = Float64(Float64(2.0 / exp(x)) / 2.0) t_1 = Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) - -1.0) / 2.0) tmp = 0.0 if (eps <= 2.8e+17) tmp = t_0; elseif (eps <= 3.5e+64) tmp = t_1; elseif (eps <= 5.2e+120) tmp = t_0; elseif (eps <= 1.05e+138) tmp = Float64(Float64(exp(Float64(Float64(x * eps) - x)) + Float64(1.0 - Float64(x * eps))) / 2.0); else tmp = t_1; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) t_0 = (2.0 / exp(x)) / 2.0; t_1 = (exp((x * (eps + -1.0))) - -1.0) / 2.0; tmp = 0.0; if (eps <= 2.8e+17) tmp = t_0; elseif (eps <= 3.5e+64) tmp = t_1; elseif (eps <= 5.2e+120) tmp = t_0; elseif (eps <= 1.05e+138) tmp = (exp(((x * eps) - x)) + (1.0 - (x * eps))) / 2.0; else tmp = t_1; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function
code[x_, eps_] := Block[{t$95$0 = N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[eps, 2.8e+17], t$95$0, If[LessEqual[eps, 3.5e+64], t$95$1, If[LessEqual[eps, 5.2e+120], t$95$0, If[LessEqual[eps, 1.05e+138], N[(N[(N[Exp[N[(N[(x * eps), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[(1.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := \frac{\frac{2}{e^{x}}}{2}\\
t_1 := \frac{e^{x \cdot \left(\varepsilon + -1\right)} - -1}{2}\\
\mathbf{if}\;\varepsilon \leq 2.8 \cdot 10^{+17}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 3.5 \cdot 10^{+64}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\varepsilon \leq 5.2 \cdot 10^{+120}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\varepsilon \leq 1.05 \cdot 10^{+138}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon - x} + \left(1 - x \cdot \varepsilon\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if eps < 2.8e17 or 3.4999999999999999e64 < eps < 5.1999999999999998e120Initial program 68.2%
div-sub68.2%
+-rgt-identity68.2%
div-sub68.2%
Simplified68.2%
Taylor expanded in eps around inf 98.3%
mul-1-neg98.3%
*-commutative98.3%
mul-1-neg98.3%
associate-*r*98.3%
+-commutative98.3%
associate-*r*98.3%
mul-1-neg98.3%
*-commutative98.3%
distribute-rgt-neg-in98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in eps around 0 80.5%
neg-mul-180.5%
Simplified80.5%
Taylor expanded in eps around 0 76.5%
exp-neg76.5%
associate-*r/76.5%
metadata-eval76.5%
Simplified76.5%
if 2.8e17 < eps < 3.4999999999999999e64 or 1.05000000000000003e138 < eps Initial program 99.8%
div-sub99.8%
+-rgt-identity99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in eps around inf 99.8%
mul-1-neg99.8%
*-commutative99.8%
mul-1-neg99.8%
associate-*r*99.8%
+-commutative99.8%
associate-*r*99.8%
mul-1-neg99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in x around 0 71.2%
if 5.1999999999999998e120 < eps < 1.05000000000000003e138Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
mul-1-neg100.0%
*-commutative100.0%
mul-1-neg100.0%
associate-*r*100.0%
+-commutative100.0%
associate-*r*100.0%
mul-1-neg100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in eps around 0 100.0%
+-commutative100.0%
neg-mul-1100.0%
*-commutative100.0%
unsub-neg100.0%
*-commutative100.0%
Simplified100.0%
Final simplification75.6%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (or (<= eps 2.8e+17) (and (not (<= eps 1.2e+65)) (<= eps 1.06e+120))) (/ (/ 2.0 (exp x)) 2.0) (/ (- (exp (* x (+ eps -1.0))) -1.0) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if ((eps <= 2.8e+17) || (!(eps <= 1.2e+65) && (eps <= 1.06e+120))) {
tmp = (2.0 / exp(x)) / 2.0;
} else {
tmp = (exp((x * (eps + -1.0))) - -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 ((eps <= 2.8d+17) .or. (.not. (eps <= 1.2d+65)) .and. (eps <= 1.06d+120)) then
tmp = (2.0d0 / exp(x)) / 2.0d0
else
tmp = (exp((x * (eps + (-1.0d0)))) - (-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 ((eps <= 2.8e+17) || (!(eps <= 1.2e+65) && (eps <= 1.06e+120))) {
tmp = (2.0 / Math.exp(x)) / 2.0;
} else {
tmp = (Math.exp((x * (eps + -1.0))) - -1.0) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if (eps <= 2.8e+17) or (not (eps <= 1.2e+65) and (eps <= 1.06e+120)): tmp = (2.0 / math.exp(x)) / 2.0 else: tmp = (math.exp((x * (eps + -1.0))) - -1.0) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if ((eps <= 2.8e+17) || (!(eps <= 1.2e+65) && (eps <= 1.06e+120))) tmp = Float64(Float64(2.0 / exp(x)) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) - -1.0) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if ((eps <= 2.8e+17) || (~((eps <= 1.2e+65)) && (eps <= 1.06e+120))) tmp = (2.0 / exp(x)) / 2.0; else tmp = (exp((x * (eps + -1.0))) - -1.0) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[Or[LessEqual[eps, 2.8e+17], And[N[Not[LessEqual[eps, 1.2e+65]], $MachinePrecision], LessEqual[eps, 1.06e+120]]], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 2.8 \cdot 10^{+17} \lor \neg \left(\varepsilon \leq 1.2 \cdot 10^{+65}\right) \land \varepsilon \leq 1.06 \cdot 10^{+120}:\\
\;\;\;\;\frac{\frac{2}{e^{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(\varepsilon + -1\right)} - -1}{2}\\
\end{array}
\end{array}
if eps < 2.8e17 or 1.2000000000000001e65 < eps < 1.05999999999999994e120Initial program 68.2%
div-sub68.2%
+-rgt-identity68.2%
div-sub68.2%
Simplified68.2%
Taylor expanded in eps around inf 98.3%
mul-1-neg98.3%
*-commutative98.3%
mul-1-neg98.3%
associate-*r*98.3%
+-commutative98.3%
associate-*r*98.3%
mul-1-neg98.3%
*-commutative98.3%
distribute-rgt-neg-in98.3%
+-commutative98.3%
Simplified98.3%
Taylor expanded in eps around 0 80.5%
neg-mul-180.5%
Simplified80.5%
Taylor expanded in eps around 0 76.5%
exp-neg76.5%
associate-*r/76.5%
metadata-eval76.5%
Simplified76.5%
if 2.8e17 < eps < 1.2000000000000001e65 or 1.05999999999999994e120 < eps Initial program 99.8%
div-sub99.8%
+-rgt-identity99.8%
div-sub99.8%
Simplified99.8%
Taylor expanded in eps around inf 99.8%
mul-1-neg99.8%
*-commutative99.8%
mul-1-neg99.8%
associate-*r*99.8%
+-commutative99.8%
associate-*r*99.8%
mul-1-neg99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in x around 0 69.4%
Final simplification74.8%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (or (<= x 5e+166) (and (not (<= x 5e+236)) (<= x 2e+251))) (/ (/ 2.0 (exp x)) 2.0) (/ (* 0.3333333333333333 (pow x 3.0)) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if ((x <= 5e+166) || (!(x <= 5e+236) && (x <= 2e+251))) {
tmp = (2.0 / exp(x)) / 2.0;
} else {
tmp = (0.3333333333333333 * pow(x, 3.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 <= 5d+166) .or. (.not. (x <= 5d+236)) .and. (x <= 2d+251)) then
tmp = (2.0d0 / exp(x)) / 2.0d0
else
tmp = (0.3333333333333333d0 * (x ** 3.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 <= 5e+166) || (!(x <= 5e+236) && (x <= 2e+251))) {
tmp = (2.0 / Math.exp(x)) / 2.0;
} else {
tmp = (0.3333333333333333 * Math.pow(x, 3.0)) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if (x <= 5e+166) or (not (x <= 5e+236) and (x <= 2e+251)): tmp = (2.0 / math.exp(x)) / 2.0 else: tmp = (0.3333333333333333 * math.pow(x, 3.0)) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if ((x <= 5e+166) || (!(x <= 5e+236) && (x <= 2e+251))) tmp = Float64(Float64(2.0 / exp(x)) / 2.0); else tmp = Float64(Float64(0.3333333333333333 * (x ^ 3.0)) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= 5e+166) || (~((x <= 5e+236)) && (x <= 2e+251))) tmp = (2.0 / exp(x)) / 2.0; else tmp = (0.3333333333333333 * (x ^ 3.0)) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[Or[LessEqual[x, 5e+166], And[N[Not[LessEqual[x, 5e+236]], $MachinePrecision], LessEqual[x, 2e+251]]], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+166} \lor \neg \left(x \leq 5 \cdot 10^{+236}\right) \land x \leq 2 \cdot 10^{+251}:\\
\;\;\;\;\frac{\frac{2}{e^{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333 \cdot {x}^{3}}{2}\\
\end{array}
\end{array}
if x < 5.0000000000000002e166 or 4.9999999999999997e236 < x < 2.0000000000000001e251Initial program 72.0%
div-sub72.0%
+-rgt-identity72.0%
div-sub72.0%
Simplified72.0%
Taylor expanded in eps around inf 98.5%
mul-1-neg98.5%
*-commutative98.5%
mul-1-neg98.5%
associate-*r*98.5%
+-commutative98.5%
associate-*r*98.5%
mul-1-neg98.5%
*-commutative98.5%
distribute-rgt-neg-in98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in eps around 0 85.7%
neg-mul-185.7%
Simplified85.7%
Taylor expanded in eps around 0 74.1%
exp-neg74.1%
associate-*r/74.1%
metadata-eval74.1%
Simplified74.1%
if 5.0000000000000002e166 < x < 4.9999999999999997e236 or 2.0000000000000001e251 < x Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in eps around 0 29.2%
*-commutative29.2%
distribute-lft1-in29.2%
mul-1-neg29.2%
distribute-lft-out29.2%
mul-1-neg29.2%
*-commutative29.2%
distribute-lft1-in29.2%
mul-1-neg29.2%
Simplified29.2%
Taylor expanded in x around 0 0.4%
*-commutative0.4%
unpow20.4%
Simplified0.4%
Taylor expanded in x around 0 0.0%
+-commutative0.0%
associate-+r+0.0%
mul-1-neg0.0%
unsub-neg0.0%
*-commutative0.0%
unpow20.0%
Simplified0.0%
Taylor expanded in x around inf 72.3%
Final simplification73.9%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= eps 3.8e+138) (/ (/ 2.0 (exp x)) 2.0) (/ (+ 2.0 (* x eps)) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (eps <= 3.8e+138) {
tmp = (2.0 / exp(x)) / 2.0;
} else {
tmp = (2.0 + (x * 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 (eps <= 3.8d+138) then
tmp = (2.0d0 / exp(x)) / 2.0d0
else
tmp = (2.0d0 + (x * eps)) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (eps <= 3.8e+138) {
tmp = (2.0 / Math.exp(x)) / 2.0;
} else {
tmp = (2.0 + (x * eps)) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if eps <= 3.8e+138: tmp = (2.0 / math.exp(x)) / 2.0 else: tmp = (2.0 + (x * eps)) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (eps <= 3.8e+138) tmp = Float64(Float64(2.0 / exp(x)) / 2.0); else tmp = Float64(Float64(2.0 + Float64(x * eps)) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 3.8e+138) tmp = (2.0 / exp(x)) / 2.0; else tmp = (2.0 + (x * eps)) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[eps, 3.8e+138], N[(N[(2.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 3.8 \cdot 10^{+138}:\\
\;\;\;\;\frac{\frac{2}{e^{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + x \cdot \varepsilon}{2}\\
\end{array}
\end{array}
if eps < 3.80000000000000012e138Initial program 70.0%
div-sub70.0%
+-rgt-identity70.0%
div-sub70.0%
Simplified70.0%
Taylor expanded in eps around inf 98.4%
mul-1-neg98.4%
*-commutative98.4%
mul-1-neg98.4%
associate-*r*98.4%
+-commutative98.4%
associate-*r*98.4%
mul-1-neg98.4%
*-commutative98.4%
distribute-rgt-neg-in98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in eps around 0 81.6%
neg-mul-181.6%
Simplified81.6%
Taylor expanded in eps around 0 75.0%
exp-neg75.0%
associate-*r/75.0%
metadata-eval75.0%
Simplified75.0%
if 3.80000000000000012e138 < eps Initial program 99.7%
Simplified82.4%
Taylor expanded in x around 0 27.5%
Taylor expanded in eps around 0 44.9%
Taylor expanded in eps around 0 44.9%
Final simplification69.5%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x -180.0)
(/ (* x (- -1.0 eps)) 2.0)
(if (<= x 1.45)
(/ (- 2.0 (* x x)) 2.0)
(if (<= x 9.8e+151)
0.0
(if (or (<= x 3.2e+238) (not (<= x 1.85e+251)))
(/
(+ 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 <= -180.0) {
tmp = (x * (-1.0 - eps)) / 2.0;
} else if (x <= 1.45) {
tmp = (2.0 - (x * x)) / 2.0;
} else if (x <= 9.8e+151) {
tmp = 0.0;
} else if ((x <= 3.2e+238) || !(x <= 1.85e+251)) {
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 <= (-180.0d0)) then
tmp = (x * ((-1.0d0) - eps)) / 2.0d0
else if (x <= 1.45d0) then
tmp = (2.0d0 - (x * x)) / 2.0d0
else if (x <= 9.8d+151) then
tmp = 0.0d0
else if ((x <= 3.2d+238) .or. (.not. (x <= 1.85d+251))) 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 <= -180.0) {
tmp = (x * (-1.0 - eps)) / 2.0;
} else if (x <= 1.45) {
tmp = (2.0 - (x * x)) / 2.0;
} else if (x <= 9.8e+151) {
tmp = 0.0;
} else if ((x <= 3.2e+238) || !(x <= 1.85e+251)) {
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 <= -180.0: tmp = (x * (-1.0 - eps)) / 2.0 elif x <= 1.45: tmp = (2.0 - (x * x)) / 2.0 elif x <= 9.8e+151: tmp = 0.0 elif (x <= 3.2e+238) or not (x <= 1.85e+251): 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 <= -180.0) tmp = Float64(Float64(x * Float64(-1.0 - eps)) / 2.0); elseif (x <= 1.45) tmp = Float64(Float64(2.0 - Float64(x * x)) / 2.0); elseif (x <= 9.8e+151) tmp = 0.0; elseif ((x <= 3.2e+238) || !(x <= 1.85e+251)) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(1.0 / eps) + Float64(Float64(1.0 - eps) * Float64(-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 <= -180.0) tmp = (x * (-1.0 - eps)) / 2.0; elseif (x <= 1.45) tmp = (2.0 - (x * x)) / 2.0; elseif (x <= 9.8e+151) tmp = 0.0; elseif ((x <= 3.2e+238) || ~((x <= 1.85e+251))) 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, -180.0], N[(N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.45], N[(N[(2.0 - N[(x * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 9.8e+151], 0.0, If[Or[LessEqual[x, 3.2e+238], N[Not[LessEqual[x, 1.85e+251]], $MachinePrecision]], N[(N[(2.0 + N[(x * N[(N[(1.0 / eps), $MachinePrecision] + N[(N[(1.0 - eps), $MachinePrecision] * N[(-1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -180:\\
\;\;\;\;\frac{x \cdot \left(-1 - \varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 1.45:\\
\;\;\;\;\frac{2 - x \cdot x}{2}\\
\mathbf{elif}\;x \leq 9.8 \cdot 10^{+151}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{+238} \lor \neg \left(x \leq 1.85 \cdot 10^{+251}\right):\\
\;\;\;\;\frac{2 + x \cdot \left(\frac{1}{\varepsilon} + \left(1 - \varepsilon\right) \cdot \left(-1 + \frac{-1}{\varepsilon}\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -180Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 49.5%
mul-1-neg49.5%
+-commutative49.5%
*-commutative49.5%
distribute-rgt-neg-in49.5%
+-commutative49.5%
Simplified49.5%
Taylor expanded in x around inf 23.8%
Taylor expanded in eps around inf 23.8%
neg-mul-123.8%
Simplified23.8%
if -180 < x < 1.44999999999999996Initial program 55.3%
div-sub55.3%
+-rgt-identity55.3%
div-sub55.3%
Simplified55.3%
Taylor expanded in eps around 0 74.8%
*-commutative74.8%
distribute-lft1-in74.7%
mul-1-neg74.7%
distribute-lft-out74.7%
mul-1-neg74.7%
*-commutative74.7%
distribute-lft1-in74.7%
mul-1-neg74.7%
Simplified74.7%
Taylor expanded in x around 0 74.3%
*-commutative74.3%
unpow274.3%
Simplified74.3%
Taylor expanded in x around 0 74.3%
mul-1-neg74.3%
unsub-neg74.3%
unpow274.3%
Simplified74.3%
if 1.44999999999999996 < x < 9.7999999999999998e151 or 3.19999999999999981e238 < x < 1.84999999999999995e251Initial program 98.7%
Simplified98.6%
Taylor expanded in eps around 0 62.2%
div-sub62.2%
rec-exp62.2%
mul-1-neg62.2%
+-inverses62.2%
Simplified62.2%
if 9.7999999999999998e151 < x < 3.19999999999999981e238 or 1.84999999999999995e251 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 3.2%
Taylor expanded in eps around 0 18.8%
Final simplification58.3%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x -1.0)
(/ (* x (- eps)) 2.0)
(if (<= x 480.0)
1.0
(if (<= x 2.5e+156)
0.0
(if (or (<= x 6.8e+235) (not (<= x 2.2e+251)))
(/ (+ 2.0 (* x eps)) 2.0)
0.0)))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -1.0) {
tmp = (x * -eps) / 2.0;
} else if (x <= 480.0) {
tmp = 1.0;
} else if (x <= 2.5e+156) {
tmp = 0.0;
} else if ((x <= 6.8e+235) || !(x <= 2.2e+251)) {
tmp = (2.0 + (x * 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 <= (-1.0d0)) then
tmp = (x * -eps) / 2.0d0
else if (x <= 480.0d0) then
tmp = 1.0d0
else if (x <= 2.5d+156) then
tmp = 0.0d0
else if ((x <= 6.8d+235) .or. (.not. (x <= 2.2d+251))) then
tmp = (2.0d0 + (x * 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 <= -1.0) {
tmp = (x * -eps) / 2.0;
} else if (x <= 480.0) {
tmp = 1.0;
} else if (x <= 2.5e+156) {
tmp = 0.0;
} else if ((x <= 6.8e+235) || !(x <= 2.2e+251)) {
tmp = (2.0 + (x * eps)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -1.0: tmp = (x * -eps) / 2.0 elif x <= 480.0: tmp = 1.0 elif x <= 2.5e+156: tmp = 0.0 elif (x <= 6.8e+235) or not (x <= 2.2e+251): tmp = (2.0 + (x * eps)) / 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(x * Float64(-eps)) / 2.0); elseif (x <= 480.0) tmp = 1.0; elseif (x <= 2.5e+156) tmp = 0.0; elseif ((x <= 6.8e+235) || !(x <= 2.2e+251)) tmp = Float64(Float64(2.0 + Float64(x * 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 <= -1.0) tmp = (x * -eps) / 2.0; elseif (x <= 480.0) tmp = 1.0; elseif (x <= 2.5e+156) tmp = 0.0; elseif ((x <= 6.8e+235) || ~((x <= 2.2e+251))) tmp = (2.0 + (x * 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, -1.0], N[(N[(x * (-eps)), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 480.0], 1.0, If[LessEqual[x, 2.5e+156], 0.0, If[Or[LessEqual[x, 6.8e+235], N[Not[LessEqual[x, 2.2e+251]], $MachinePrecision]], N[(N[(2.0 + N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x \cdot \left(-\varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 480:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+156}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+235} \lor \neg \left(x \leq 2.2 \cdot 10^{+251}\right):\\
\;\;\;\;\frac{2 + x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 49.5%
mul-1-neg49.5%
+-commutative49.5%
*-commutative49.5%
distribute-rgt-neg-in49.5%
+-commutative49.5%
Simplified49.5%
Taylor expanded in x around inf 23.8%
Taylor expanded in eps around inf 23.8%
neg-mul-123.8%
distribute-lft-neg-in23.8%
*-commutative23.8%
Simplified23.8%
if -1 < x < 480Initial program 55.5%
div-sub55.5%
+-rgt-identity55.5%
div-sub55.5%
Simplified55.5%
Taylor expanded in x around 0 73.1%
if 480 < x < 2.49999999999999996e156 or 6.79999999999999991e235 < x < 2.2e251Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 64.6%
div-sub64.6%
rec-exp64.6%
mul-1-neg64.6%
+-inverses64.6%
Simplified64.6%
if 2.49999999999999996e156 < x < 6.79999999999999991e235 or 2.2e251 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 3.2%
Taylor expanded in eps around 0 18.8%
Taylor expanded in eps around 0 18.6%
Final simplification58.2%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x -50.0)
(/ (* x (- eps)) 2.0)
(if (<= x 1.45)
(/ (- 2.0 (* x x)) 2.0)
(if (<= x 1.02e+149)
0.0
(if (or (<= x 3e+236) (not (<= x 2.25e+251)))
(/ (+ 2.0 (* x eps)) 2.0)
0.0)))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -50.0) {
tmp = (x * -eps) / 2.0;
} else if (x <= 1.45) {
tmp = (2.0 - (x * x)) / 2.0;
} else if (x <= 1.02e+149) {
tmp = 0.0;
} else if ((x <= 3e+236) || !(x <= 2.25e+251)) {
tmp = (2.0 + (x * 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 <= (-50.0d0)) then
tmp = (x * -eps) / 2.0d0
else if (x <= 1.45d0) then
tmp = (2.0d0 - (x * x)) / 2.0d0
else if (x <= 1.02d+149) then
tmp = 0.0d0
else if ((x <= 3d+236) .or. (.not. (x <= 2.25d+251))) then
tmp = (2.0d0 + (x * 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 <= -50.0) {
tmp = (x * -eps) / 2.0;
} else if (x <= 1.45) {
tmp = (2.0 - (x * x)) / 2.0;
} else if (x <= 1.02e+149) {
tmp = 0.0;
} else if ((x <= 3e+236) || !(x <= 2.25e+251)) {
tmp = (2.0 + (x * eps)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -50.0: tmp = (x * -eps) / 2.0 elif x <= 1.45: tmp = (2.0 - (x * x)) / 2.0 elif x <= 1.02e+149: tmp = 0.0 elif (x <= 3e+236) or not (x <= 2.25e+251): tmp = (2.0 + (x * eps)) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -50.0) tmp = Float64(Float64(x * Float64(-eps)) / 2.0); elseif (x <= 1.45) tmp = Float64(Float64(2.0 - Float64(x * x)) / 2.0); elseif (x <= 1.02e+149) tmp = 0.0; elseif ((x <= 3e+236) || !(x <= 2.25e+251)) tmp = Float64(Float64(2.0 + Float64(x * 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 <= -50.0) tmp = (x * -eps) / 2.0; elseif (x <= 1.45) tmp = (2.0 - (x * x)) / 2.0; elseif (x <= 1.02e+149) tmp = 0.0; elseif ((x <= 3e+236) || ~((x <= 2.25e+251))) tmp = (2.0 + (x * 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, -50.0], N[(N[(x * (-eps)), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.45], N[(N[(2.0 - N[(x * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.02e+149], 0.0, If[Or[LessEqual[x, 3e+236], N[Not[LessEqual[x, 2.25e+251]], $MachinePrecision]], N[(N[(2.0 + N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -50:\\
\;\;\;\;\frac{x \cdot \left(-\varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 1.45:\\
\;\;\;\;\frac{2 - x \cdot x}{2}\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{+149}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+236} \lor \neg \left(x \leq 2.25 \cdot 10^{+251}\right):\\
\;\;\;\;\frac{2 + x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -50Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 49.5%
mul-1-neg49.5%
+-commutative49.5%
*-commutative49.5%
distribute-rgt-neg-in49.5%
+-commutative49.5%
Simplified49.5%
Taylor expanded in x around inf 23.8%
Taylor expanded in eps around inf 23.8%
neg-mul-123.8%
distribute-lft-neg-in23.8%
*-commutative23.8%
Simplified23.8%
if -50 < x < 1.44999999999999996Initial program 55.3%
div-sub55.3%
+-rgt-identity55.3%
div-sub55.3%
Simplified55.3%
Taylor expanded in eps around 0 74.8%
*-commutative74.8%
distribute-lft1-in74.7%
mul-1-neg74.7%
distribute-lft-out74.7%
mul-1-neg74.7%
*-commutative74.7%
distribute-lft1-in74.7%
mul-1-neg74.7%
Simplified74.7%
Taylor expanded in x around 0 74.3%
*-commutative74.3%
unpow274.3%
Simplified74.3%
Taylor expanded in x around 0 74.3%
mul-1-neg74.3%
unsub-neg74.3%
unpow274.3%
Simplified74.3%
if 1.44999999999999996 < x < 1.01999999999999997e149 or 2.9999999999999998e236 < x < 2.2499999999999999e251Initial program 98.7%
Simplified98.6%
Taylor expanded in eps around 0 62.2%
div-sub62.2%
rec-exp62.2%
mul-1-neg62.2%
+-inverses62.2%
Simplified62.2%
if 1.01999999999999997e149 < x < 2.9999999999999998e236 or 2.2499999999999999e251 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 3.2%
Taylor expanded in eps around 0 18.8%
Taylor expanded in eps around 0 18.6%
Final simplification58.3%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x -300.0)
(/ (* x (- -1.0 eps)) 2.0)
(if (<= x 1.45)
(/ (- 2.0 (* x x)) 2.0)
(if (<= x 2.45e+151)
0.0
(if (or (<= x 2.55e+238) (not (<= x 2.5e+251)))
(/ (+ 2.0 (* x eps)) 2.0)
0.0)))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -300.0) {
tmp = (x * (-1.0 - eps)) / 2.0;
} else if (x <= 1.45) {
tmp = (2.0 - (x * x)) / 2.0;
} else if (x <= 2.45e+151) {
tmp = 0.0;
} else if ((x <= 2.55e+238) || !(x <= 2.5e+251)) {
tmp = (2.0 + (x * 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 <= (-300.0d0)) then
tmp = (x * ((-1.0d0) - eps)) / 2.0d0
else if (x <= 1.45d0) then
tmp = (2.0d0 - (x * x)) / 2.0d0
else if (x <= 2.45d+151) then
tmp = 0.0d0
else if ((x <= 2.55d+238) .or. (.not. (x <= 2.5d+251))) then
tmp = (2.0d0 + (x * 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 <= -300.0) {
tmp = (x * (-1.0 - eps)) / 2.0;
} else if (x <= 1.45) {
tmp = (2.0 - (x * x)) / 2.0;
} else if (x <= 2.45e+151) {
tmp = 0.0;
} else if ((x <= 2.55e+238) || !(x <= 2.5e+251)) {
tmp = (2.0 + (x * eps)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -300.0: tmp = (x * (-1.0 - eps)) / 2.0 elif x <= 1.45: tmp = (2.0 - (x * x)) / 2.0 elif x <= 2.45e+151: tmp = 0.0 elif (x <= 2.55e+238) or not (x <= 2.5e+251): tmp = (2.0 + (x * eps)) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -300.0) tmp = Float64(Float64(x * Float64(-1.0 - eps)) / 2.0); elseif (x <= 1.45) tmp = Float64(Float64(2.0 - Float64(x * x)) / 2.0); elseif (x <= 2.45e+151) tmp = 0.0; elseif ((x <= 2.55e+238) || !(x <= 2.5e+251)) tmp = Float64(Float64(2.0 + Float64(x * 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 <= -300.0) tmp = (x * (-1.0 - eps)) / 2.0; elseif (x <= 1.45) tmp = (2.0 - (x * x)) / 2.0; elseif (x <= 2.45e+151) tmp = 0.0; elseif ((x <= 2.55e+238) || ~((x <= 2.5e+251))) tmp = (2.0 + (x * 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, -300.0], N[(N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.45], N[(N[(2.0 - N[(x * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.45e+151], 0.0, If[Or[LessEqual[x, 2.55e+238], N[Not[LessEqual[x, 2.5e+251]], $MachinePrecision]], N[(N[(2.0 + N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -300:\\
\;\;\;\;\frac{x \cdot \left(-1 - \varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 1.45:\\
\;\;\;\;\frac{2 - x \cdot x}{2}\\
\mathbf{elif}\;x \leq 2.45 \cdot 10^{+151}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 2.55 \cdot 10^{+238} \lor \neg \left(x \leq 2.5 \cdot 10^{+251}\right):\\
\;\;\;\;\frac{2 + x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -300Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 49.5%
mul-1-neg49.5%
+-commutative49.5%
*-commutative49.5%
distribute-rgt-neg-in49.5%
+-commutative49.5%
Simplified49.5%
Taylor expanded in x around inf 23.8%
Taylor expanded in eps around inf 23.8%
neg-mul-123.8%
Simplified23.8%
if -300 < x < 1.44999999999999996Initial program 55.3%
div-sub55.3%
+-rgt-identity55.3%
div-sub55.3%
Simplified55.3%
Taylor expanded in eps around 0 74.8%
*-commutative74.8%
distribute-lft1-in74.7%
mul-1-neg74.7%
distribute-lft-out74.7%
mul-1-neg74.7%
*-commutative74.7%
distribute-lft1-in74.7%
mul-1-neg74.7%
Simplified74.7%
Taylor expanded in x around 0 74.3%
*-commutative74.3%
unpow274.3%
Simplified74.3%
Taylor expanded in x around 0 74.3%
mul-1-neg74.3%
unsub-neg74.3%
unpow274.3%
Simplified74.3%
if 1.44999999999999996 < x < 2.45e151 or 2.5500000000000001e238 < x < 2.5000000000000002e251Initial program 98.7%
Simplified98.6%
Taylor expanded in eps around 0 62.2%
div-sub62.2%
rec-exp62.2%
mul-1-neg62.2%
+-inverses62.2%
Simplified62.2%
if 2.45e151 < x < 2.5500000000000001e238 or 2.5000000000000002e251 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 3.2%
Taylor expanded in eps around 0 18.8%
Taylor expanded in eps around 0 18.6%
Final simplification58.3%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -1.0) (/ (* x (- eps)) 2.0) (if (<= x 520.0) 1.0 0.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -1.0) {
tmp = (x * -eps) / 2.0;
} else if (x <= 520.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 <= (-1.0d0)) then
tmp = (x * -eps) / 2.0d0
else if (x <= 520.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 <= -1.0) {
tmp = (x * -eps) / 2.0;
} else if (x <= 520.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -1.0: tmp = (x * -eps) / 2.0 elif x <= 520.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(x * Float64(-eps)) / 2.0); elseif (x <= 520.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 <= -1.0) tmp = (x * -eps) / 2.0; elseif (x <= 520.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, -1.0], N[(N[(x * (-eps)), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 520.0], 1.0, 0.0]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{x \cdot \left(-\varepsilon\right)}{2}\\
\mathbf{elif}\;x \leq 520:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
div-sub100.0%
+-rgt-identity100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 49.5%
mul-1-neg49.5%
+-commutative49.5%
*-commutative49.5%
distribute-rgt-neg-in49.5%
+-commutative49.5%
Simplified49.5%
Taylor expanded in x around inf 23.8%
Taylor expanded in eps around inf 23.8%
neg-mul-123.8%
distribute-lft-neg-in23.8%
*-commutative23.8%
Simplified23.8%
if -1 < x < 520Initial program 55.5%
div-sub55.5%
+-rgt-identity55.5%
div-sub55.5%
Simplified55.5%
Taylor expanded in x around 0 73.1%
if 520 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 50.8%
div-sub50.8%
rec-exp50.8%
mul-1-neg50.8%
+-inverses50.8%
Simplified50.8%
Final simplification59.8%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 550.0) 1.0 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 550.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 <= 550.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 <= 550.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 550.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 550.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 <= 550.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, 550.0], 1.0, 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 550:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 550Initial program 63.5%
div-sub63.5%
+-rgt-identity63.5%
div-sub63.5%
Simplified63.5%
Taylor expanded in x around 0 60.4%
if 550 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 50.8%
div-sub50.8%
rec-exp50.8%
mul-1-neg50.8%
+-inverses50.8%
Simplified50.8%
Final simplification57.3%
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 75.5%
Simplified68.5%
Taylor expanded in eps around 0 18.2%
div-sub18.2%
rec-exp18.2%
mul-1-neg18.2%
+-inverses18.3%
Simplified18.3%
Final simplification18.3%
herbie shell --seed 2023230
(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))