
(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 13 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 (exp (- x))))
(if (<= eps 0.1)
(/ (+ (* t_0 (- (+ x 1.0) -1.0)) (* x t_0)) 2.0)
(/ (+ (exp (* x (+ eps -1.0))) (exp (* x (- eps)))) 2.0))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if (eps <= 0.1) {
tmp = ((t_0 * ((x + 1.0) - -1.0)) + (x * t_0)) / 2.0;
} else {
tmp = (exp((x * (eps + -1.0))) + 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) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (eps <= 0.1d0) then
tmp = ((t_0 * ((x + 1.0d0) - (-1.0d0))) + (x * t_0)) / 2.0d0
else
tmp = (exp((x * (eps + (-1.0d0)))) + exp((x * -eps))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double t_0 = Math.exp(-x);
double tmp;
if (eps <= 0.1) {
tmp = ((t_0 * ((x + 1.0) - -1.0)) + (x * t_0)) / 2.0;
} else {
tmp = (Math.exp((x * (eps + -1.0))) + Math.exp((x * -eps))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = math.exp(-x) tmp = 0 if eps <= 0.1: tmp = ((t_0 * ((x + 1.0) - -1.0)) + (x * t_0)) / 2.0 else: tmp = (math.exp((x * (eps + -1.0))) + math.exp((x * -eps))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (eps <= 0.1) tmp = Float64(Float64(Float64(t_0 * Float64(Float64(x + 1.0) - -1.0)) + Float64(x * t_0)) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + exp(Float64(x * Float64(-eps)))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) t_0 = exp(-x); tmp = 0.0; if (eps <= 0.1) tmp = ((t_0 * ((x + 1.0) - -1.0)) + (x * t_0)) / 2.0; else tmp = (exp((x * (eps + -1.0))) + exp((x * -eps))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[eps, 0.1], N[(N[(N[(t$95$0 * N[(N[(x + 1.0), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;\varepsilon \leq 0.1:\\
\;\;\;\;\frac{t_0 \cdot \left(\left(x + 1\right) - -1\right) + x \cdot t_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-\varepsilon\right)}}{2}\\
\end{array}
\end{array}
if eps < 0.10000000000000001Initial program 60.7%
sub-neg60.7%
neg-sub060.7%
associate-+r-60.7%
Simplified60.7%
Taylor expanded in eps around 0 73.3%
associate--r+73.3%
associate-*r*73.3%
neg-mul-173.3%
cancel-sign-sub73.3%
distribute-rgt1-in73.3%
distribute-rgt-out--73.3%
neg-mul-173.3%
neg-mul-173.3%
Simplified73.3%
if 0.10000000000000001 < eps Initial program 100.0%
Simplified67.3%
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%
neg-mul-1100.0%
neg-mul-1100.0%
sub-neg100.0%
mul-1-neg100.0%
associate-*r*100.0%
neg-mul-1100.0%
Simplified100.0%
Final simplification81.8%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (/ (+ (exp (* x (- -1.0 eps))) (exp (* x (+ eps -1.0)))) 2.0))
eps = abs(eps);
double code(double x, double eps) {
return (exp((x * (-1.0 - eps))) + exp((x * (eps + -1.0)))) / 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 * ((-1.0d0) - eps))) + exp((x * (eps + (-1.0d0))))) / 2.0d0
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
return (Math.exp((x * (-1.0 - eps))) + Math.exp((x * (eps + -1.0)))) / 2.0;
}
eps = abs(eps) def code(x, eps): return (math.exp((x * (-1.0 - eps))) + math.exp((x * (eps + -1.0)))) / 2.0
eps = abs(eps) function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(-1.0 - eps))) + exp(Float64(x * Float64(eps + -1.0)))) / 2.0) end
eps = abs(eps) function tmp = code(x, eps) tmp = (exp((x * (-1.0 - eps))) + exp((x * (eps + -1.0)))) / 2.0; end
NOTE: eps should be positive before calling this function code[x_, eps_] := N[(N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps = |eps|\\
\\
\frac{e^{x \cdot \left(-1 - \varepsilon\right)} + e^{x \cdot \left(\varepsilon + -1\right)}}{2}
\end{array}
Initial program 73.3%
Simplified53.4%
Taylor expanded in eps around inf 98.6%
Final simplification98.6%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 8.2e+108) (/ (+ (exp (* x (- eps))) (exp (* x eps))) 2.0) 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 8.2e+108) {
tmp = (exp((x * -eps)) + exp((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 <= 8.2d+108) then
tmp = (exp((x * -eps)) + exp((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 <= 8.2e+108) {
tmp = (Math.exp((x * -eps)) + Math.exp((x * eps))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 8.2e+108: tmp = (math.exp((x * -eps)) + math.exp((x * eps))) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 8.2e+108) tmp = Float64(Float64(exp(Float64(x * Float64(-eps))) + exp(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 <= 8.2e+108) tmp = (exp((x * -eps)) + exp((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, 8.2e+108], N[(N[(N[Exp[N[(x * (-eps)), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.2 \cdot 10^{+108}:\\
\;\;\;\;\frac{e^{x \cdot \left(-\varepsilon\right)} + e^{x \cdot \varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 8.1999999999999998e108Initial program 68.5%
Simplified45.1%
Taylor expanded in eps around inf 98.3%
Taylor expanded in eps around inf 94.3%
*-commutative94.3%
Simplified94.3%
Taylor expanded in eps around -inf 94.3%
associate-*r*94.3%
neg-mul-194.3%
neg-mul-194.3%
sub-neg94.3%
mul-1-neg94.3%
associate-*r*94.3%
neg-mul-194.3%
Simplified94.3%
Taylor expanded in eps around inf 94.7%
if 8.1999999999999998e108 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 59.6%
neg-mul-159.6%
rec-exp59.6%
neg-mul-159.6%
div-sub59.6%
+-inverses59.6%
Simplified59.6%
Final simplification89.3%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (/ (+ (exp (* x (+ eps -1.0))) (exp (* x (- eps)))) 2.0))
eps = abs(eps);
double code(double x, double eps) {
return (exp((x * (eps + -1.0))) + exp((x * -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 * -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 * -eps))) / 2.0;
}
eps = abs(eps) def code(x, eps): return (math.exp((x * (eps + -1.0))) + math.exp((x * -eps))) / 2.0
eps = abs(eps) function code(x, eps) return Float64(Float64(exp(Float64(x * Float64(eps + -1.0))) + exp(Float64(x * Float64(-eps)))) / 2.0) end
eps = abs(eps) function tmp = code(x, eps) tmp = (exp((x * (eps + -1.0))) + exp((x * -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 * (-eps)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps = |eps|\\
\\
\frac{e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-\varepsilon\right)}}{2}
\end{array}
Initial program 73.3%
Simplified53.4%
Taylor expanded in eps around inf 98.6%
Taylor expanded in eps around inf 88.7%
*-commutative88.7%
Simplified88.7%
Taylor expanded in eps around -inf 88.7%
associate-*r*88.7%
neg-mul-188.7%
neg-mul-188.7%
sub-neg88.7%
mul-1-neg88.7%
associate-*r*88.7%
neg-mul-188.7%
Simplified88.7%
Final simplification88.7%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -2e-268) (/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0) (if (<= x 2.8e+109) (/ (+ 1.0 (exp (* x (+ eps -1.0)))) 2.0) 0.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -2e-268) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 2.8e+109) {
tmp = (1.0 + exp((x * (eps + -1.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 <= (-2d-268)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else if (x <= 2.8d+109) then
tmp = (1.0d0 + exp((x * (eps + (-1.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 <= -2e-268) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 2.8e+109) {
tmp = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -2e-268: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 elif x <= 2.8e+109: tmp = (1.0 + math.exp((x * (eps + -1.0)))) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -2e-268) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif (x <= 2.8e+109) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.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 <= -2e-268) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; elseif (x <= 2.8e+109) tmp = (1.0 + exp((x * (eps + -1.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, -2e-268], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.8e+109], N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-268}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{+109}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1.99999999999999992e-268Initial program 72.0%
Simplified51.7%
Taylor expanded in eps around inf 97.6%
Taylor expanded in x around 0 73.0%
Taylor expanded in eps around -inf 73.0%
sub-neg73.0%
mul-1-neg73.0%
remove-double-neg73.0%
associate-*r*73.0%
exp-prod64.9%
cancel-sign-sub-inv64.9%
metadata-eval64.9%
*-lft-identity64.9%
+-commutative64.9%
exp-prod73.0%
*-commutative73.0%
associate-*l*73.0%
neg-mul-173.0%
Simplified73.0%
if -1.99999999999999992e-268 < x < 2.8000000000000002e109Initial program 65.3%
sub-neg65.3%
neg-sub065.3%
associate-+r-65.3%
Simplified65.3%
Taylor expanded in x around 0 43.9%
Taylor expanded in eps around inf 78.3%
*-commutative78.3%
sub-neg78.3%
mul-1-neg78.3%
*-commutative78.3%
associate-*r*78.3%
mul-1-neg78.3%
mul-1-neg78.3%
sub-neg78.3%
Simplified78.3%
if 2.8000000000000002e109 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 59.6%
neg-mul-159.6%
rec-exp59.6%
neg-mul-159.6%
div-sub59.6%
+-inverses59.6%
Simplified59.6%
Final simplification73.3%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x 2.95e-272)
(/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0)
(if (<= x 1.6e+56)
(/
(-
2.0
(*
x
(+
(/ 1.0 eps)
(* (/ (- -1.0 (/ -1.0 eps)) (+ eps -1.0)) (+ 1.0 (* eps eps))))))
2.0)
0.0)))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 2.95e-272) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 1.6e+56) {
tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * 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 <= 2.95d-272) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else if (x <= 1.6d+56) then
tmp = (2.0d0 - (x * ((1.0d0 / eps) + ((((-1.0d0) - ((-1.0d0) / eps)) / (eps + (-1.0d0))) * (1.0d0 + (eps * 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 <= 2.95e-272) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 1.6e+56) {
tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * eps)))))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 2.95e-272: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 elif x <= 1.6e+56: tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * eps)))))) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 2.95e-272) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif (x <= 1.6e+56) tmp = Float64(Float64(2.0 - Float64(x * Float64(Float64(1.0 / eps) + Float64(Float64(Float64(-1.0 - Float64(-1.0 / eps)) / Float64(eps + -1.0)) * Float64(1.0 + Float64(eps * 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 <= 2.95e-272) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; elseif (x <= 1.6e+56) tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * 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, 2.95e-272], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.6e+56], N[(N[(2.0 - N[(x * N[(N[(1.0 / eps), $MachinePrecision] + N[(N[(N[(-1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] / N[(eps + -1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.95 \cdot 10^{-272}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+56}:\\
\;\;\;\;\frac{2 - x \cdot \left(\frac{1}{\varepsilon} + \frac{-1 - \frac{-1}{\varepsilon}}{\varepsilon + -1} \cdot \left(1 + \varepsilon \cdot \varepsilon\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2.95e-272Initial program 69.2%
Simplified44.2%
Taylor expanded in eps around inf 98.0%
Taylor expanded in x around 0 77.7%
Taylor expanded in eps around -inf 77.7%
sub-neg77.7%
mul-1-neg77.7%
remove-double-neg77.7%
associate-*r*77.7%
exp-prod71.0%
cancel-sign-sub-inv71.0%
metadata-eval71.0%
*-lft-identity71.0%
+-commutative71.0%
exp-prod77.7%
*-commutative77.7%
associate-*l*77.7%
neg-mul-177.7%
Simplified77.7%
if 2.95e-272 < x < 1.60000000000000002e56Initial program 61.6%
Simplified61.6%
Taylor expanded in x around 0 62.9%
Taylor expanded in eps around 0 64.9%
*-commutative64.9%
flip-+73.5%
associate-*r/73.5%
sub-neg73.5%
distribute-neg-frac73.5%
metadata-eval73.5%
metadata-eval73.5%
Applied egg-rr73.5%
*-commutative73.5%
associate-/l*73.5%
Simplified73.5%
div-inv73.5%
sub-neg73.5%
distribute-rgt-neg-in73.5%
add-sqr-sqrt41.6%
sqrt-unprod90.5%
sqr-neg90.5%
sqrt-prod48.9%
add-sqr-sqrt77.5%
clear-num77.5%
frac-2neg77.5%
Applied egg-rr77.5%
*-commutative77.5%
Simplified77.5%
if 1.60000000000000002e56 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 55.4%
neg-mul-155.4%
rec-exp55.4%
neg-mul-155.4%
div-sub55.4%
+-inverses55.4%
Simplified55.4%
Final simplification73.0%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x -350000000000.0)
(/ (/ (expm1 (- x)) eps) 2.0)
(if (<= x -1.4e-206)
(/
(+
2.0
(*
x
(+
(* (+ eps -1.0) (- 1.0 (/ -1.0 eps)))
(/ (+ -1.0 (* eps eps)) (/ (- 1.0 eps) (+ 1.0 (/ -1.0 eps)))))))
2.0)
(if (<= x 2.9e-272)
(/ (- 2.0 (* x eps)) 2.0)
(if (<= x 1.1e+56)
(/
(-
2.0
(*
x
(+
(/ 1.0 eps)
(* (/ (- -1.0 (/ -1.0 eps)) (+ eps -1.0)) (+ 1.0 (* eps eps))))))
2.0)
0.0)))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -350000000000.0) {
tmp = (expm1(-x) / eps) / 2.0;
} else if (x <= -1.4e-206) {
tmp = (2.0 + (x * (((eps + -1.0) * (1.0 - (-1.0 / eps))) + ((-1.0 + (eps * eps)) / ((1.0 - eps) / (1.0 + (-1.0 / eps))))))) / 2.0;
} else if (x <= 2.9e-272) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if (x <= 1.1e+56) {
tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * eps)))))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -350000000000.0) {
tmp = (Math.expm1(-x) / eps) / 2.0;
} else if (x <= -1.4e-206) {
tmp = (2.0 + (x * (((eps + -1.0) * (1.0 - (-1.0 / eps))) + ((-1.0 + (eps * eps)) / ((1.0 - eps) / (1.0 + (-1.0 / eps))))))) / 2.0;
} else if (x <= 2.9e-272) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if (x <= 1.1e+56) {
tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * eps)))))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -350000000000.0: tmp = (math.expm1(-x) / eps) / 2.0 elif x <= -1.4e-206: tmp = (2.0 + (x * (((eps + -1.0) * (1.0 - (-1.0 / eps))) + ((-1.0 + (eps * eps)) / ((1.0 - eps) / (1.0 + (-1.0 / eps))))))) / 2.0 elif x <= 2.9e-272: tmp = (2.0 - (x * eps)) / 2.0 elif x <= 1.1e+56: tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * eps)))))) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -350000000000.0) tmp = Float64(Float64(expm1(Float64(-x)) / eps) / 2.0); elseif (x <= -1.4e-206) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(Float64(eps + -1.0) * Float64(1.0 - Float64(-1.0 / eps))) + Float64(Float64(-1.0 + Float64(eps * eps)) / Float64(Float64(1.0 - eps) / Float64(1.0 + Float64(-1.0 / eps))))))) / 2.0); elseif (x <= 2.9e-272) tmp = Float64(Float64(2.0 - Float64(x * eps)) / 2.0); elseif (x <= 1.1e+56) tmp = Float64(Float64(2.0 - Float64(x * Float64(Float64(1.0 / eps) + Float64(Float64(Float64(-1.0 - Float64(-1.0 / eps)) / Float64(eps + -1.0)) * Float64(1.0 + Float64(eps * eps)))))) / 2.0); else tmp = 0.0; end return tmp end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -350000000000.0], N[(N[(N[(Exp[(-x)] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.4e-206], N[(N[(2.0 + N[(x * N[(N[(N[(eps + -1.0), $MachinePrecision] * N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 + N[(eps * eps), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - eps), $MachinePrecision] / N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.9e-272], N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.1e+56], N[(N[(2.0 - N[(x * N[(N[(1.0 / eps), $MachinePrecision] + N[(N[(N[(-1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] / N[(eps + -1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -350000000000:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(-x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-206}:\\
\;\;\;\;\frac{2 + x \cdot \left(\left(\varepsilon + -1\right) \cdot \left(1 - \frac{-1}{\varepsilon}\right) + \frac{-1 + \varepsilon \cdot \varepsilon}{\frac{1 - \varepsilon}{1 + \frac{-1}{\varepsilon}}}\right)}{2}\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{-272}:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+56}:\\
\;\;\;\;\frac{2 - x \cdot \left(\frac{1}{\varepsilon} + \frac{-1 - \frac{-1}{\varepsilon}}{\varepsilon + -1} \cdot \left(1 + \varepsilon \cdot \varepsilon\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -3.5e11Initial program 100.0%
sub-neg100.0%
neg-sub0100.0%
associate-+r-100.0%
Simplified100.0%
Taylor expanded in x around 0 40.4%
Taylor expanded in eps around 0 61.5%
expm1-def61.5%
mul-1-neg61.5%
Simplified61.5%
if -3.5e11 < x < -1.4000000000000001e-206Initial program 55.2%
Simplified55.5%
Taylor expanded in x around 0 58.3%
*-commutative57.2%
flip-+68.6%
associate-*r/68.6%
sub-neg68.6%
distribute-neg-frac68.6%
metadata-eval68.6%
metadata-eval68.6%
Applied egg-rr69.3%
*-commutative68.6%
associate-/l*68.6%
Simplified69.3%
if -1.4000000000000001e-206 < x < 2.89999999999999995e-272Initial program 55.5%
Simplified55.5%
Taylor expanded in x around 0 97.4%
Taylor expanded in eps around 0 97.4%
Taylor expanded in eps around 0 97.4%
neg-mul-197.4%
Simplified97.4%
if 2.89999999999999995e-272 < x < 1.10000000000000008e56Initial program 61.6%
Simplified61.6%
Taylor expanded in x around 0 62.9%
Taylor expanded in eps around 0 64.9%
*-commutative64.9%
flip-+73.5%
associate-*r/73.5%
sub-neg73.5%
distribute-neg-frac73.5%
metadata-eval73.5%
metadata-eval73.5%
Applied egg-rr73.5%
*-commutative73.5%
associate-/l*73.5%
Simplified73.5%
div-inv73.5%
sub-neg73.5%
distribute-rgt-neg-in73.5%
add-sqr-sqrt41.6%
sqrt-unprod90.5%
sqr-neg90.5%
sqrt-prod48.9%
add-sqr-sqrt77.5%
clear-num77.5%
frac-2neg77.5%
Applied egg-rr77.5%
*-commutative77.5%
Simplified77.5%
if 1.10000000000000008e56 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 55.4%
neg-mul-155.4%
rec-exp55.4%
neg-mul-155.4%
div-sub55.4%
+-inverses55.4%
Simplified55.4%
Final simplification71.8%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x -2e-206)
(/
(+
2.0
(*
x
(+
(/ -1.0 eps)
(/ (+ -1.0 (* eps eps)) (/ (- 1.0 eps) (+ 1.0 (/ -1.0 eps)))))))
2.0)
(if (<= x 2.8e-272)
(/ (- 2.0 (* x eps)) 2.0)
(if (<= x 3.5e+56)
(/
(-
2.0
(*
x
(+
(/ 1.0 eps)
(* (/ (- -1.0 (/ -1.0 eps)) (+ eps -1.0)) (+ 1.0 (* eps eps))))))
2.0)
0.0))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -2e-206) {
tmp = (2.0 + (x * ((-1.0 / eps) + ((-1.0 + (eps * eps)) / ((1.0 - eps) / (1.0 + (-1.0 / eps))))))) / 2.0;
} else if (x <= 2.8e-272) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if (x <= 3.5e+56) {
tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * 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 <= (-2d-206)) then
tmp = (2.0d0 + (x * (((-1.0d0) / eps) + (((-1.0d0) + (eps * eps)) / ((1.0d0 - eps) / (1.0d0 + ((-1.0d0) / eps))))))) / 2.0d0
else if (x <= 2.8d-272) then
tmp = (2.0d0 - (x * eps)) / 2.0d0
else if (x <= 3.5d+56) then
tmp = (2.0d0 - (x * ((1.0d0 / eps) + ((((-1.0d0) - ((-1.0d0) / eps)) / (eps + (-1.0d0))) * (1.0d0 + (eps * 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 <= -2e-206) {
tmp = (2.0 + (x * ((-1.0 / eps) + ((-1.0 + (eps * eps)) / ((1.0 - eps) / (1.0 + (-1.0 / eps))))))) / 2.0;
} else if (x <= 2.8e-272) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if (x <= 3.5e+56) {
tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * eps)))))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -2e-206: tmp = (2.0 + (x * ((-1.0 / eps) + ((-1.0 + (eps * eps)) / ((1.0 - eps) / (1.0 + (-1.0 / eps))))))) / 2.0 elif x <= 2.8e-272: tmp = (2.0 - (x * eps)) / 2.0 elif x <= 3.5e+56: tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * eps)))))) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -2e-206) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(-1.0 / eps) + Float64(Float64(-1.0 + Float64(eps * eps)) / Float64(Float64(1.0 - eps) / Float64(1.0 + Float64(-1.0 / eps))))))) / 2.0); elseif (x <= 2.8e-272) tmp = Float64(Float64(2.0 - Float64(x * eps)) / 2.0); elseif (x <= 3.5e+56) tmp = Float64(Float64(2.0 - Float64(x * Float64(Float64(1.0 / eps) + Float64(Float64(Float64(-1.0 - Float64(-1.0 / eps)) / Float64(eps + -1.0)) * Float64(1.0 + Float64(eps * 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 <= -2e-206) tmp = (2.0 + (x * ((-1.0 / eps) + ((-1.0 + (eps * eps)) / ((1.0 - eps) / (1.0 + (-1.0 / eps))))))) / 2.0; elseif (x <= 2.8e-272) tmp = (2.0 - (x * eps)) / 2.0; elseif (x <= 3.5e+56) tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * 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, -2e-206], N[(N[(2.0 + N[(x * N[(N[(-1.0 / eps), $MachinePrecision] + N[(N[(-1.0 + N[(eps * eps), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - eps), $MachinePrecision] / N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.8e-272], N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 3.5e+56], N[(N[(2.0 - N[(x * N[(N[(1.0 / eps), $MachinePrecision] + N[(N[(N[(-1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] / N[(eps + -1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-206}:\\
\;\;\;\;\frac{2 + x \cdot \left(\frac{-1}{\varepsilon} + \frac{-1 + \varepsilon \cdot \varepsilon}{\frac{1 - \varepsilon}{1 + \frac{-1}{\varepsilon}}}\right)}{2}\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-272}:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+56}:\\
\;\;\;\;\frac{2 - x \cdot \left(\frac{1}{\varepsilon} + \frac{-1 - \frac{-1}{\varepsilon}}{\varepsilon + -1} \cdot \left(1 + \varepsilon \cdot \varepsilon\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -2.00000000000000006e-206Initial program 74.9%
Simplified75.0%
Taylor expanded in x around 0 34.2%
Taylor expanded in eps around 0 48.6%
*-commutative48.6%
flip-+56.0%
associate-*r/56.0%
sub-neg56.0%
distribute-neg-frac56.0%
metadata-eval56.0%
metadata-eval56.0%
Applied egg-rr56.0%
*-commutative56.0%
associate-/l*56.0%
Simplified56.0%
if -2.00000000000000006e-206 < x < 2.79999999999999994e-272Initial program 55.5%
Simplified55.5%
Taylor expanded in x around 0 97.4%
Taylor expanded in eps around 0 97.4%
Taylor expanded in eps around 0 97.4%
neg-mul-197.4%
Simplified97.4%
if 2.79999999999999994e-272 < x < 3.49999999999999999e56Initial program 61.6%
Simplified61.6%
Taylor expanded in x around 0 62.9%
Taylor expanded in eps around 0 64.9%
*-commutative64.9%
flip-+73.5%
associate-*r/73.5%
sub-neg73.5%
distribute-neg-frac73.5%
metadata-eval73.5%
metadata-eval73.5%
Applied egg-rr73.5%
*-commutative73.5%
associate-/l*73.5%
Simplified73.5%
div-inv73.5%
sub-neg73.5%
distribute-rgt-neg-in73.5%
add-sqr-sqrt41.6%
sqrt-unprod90.5%
sqr-neg90.5%
sqrt-prod48.9%
add-sqr-sqrt77.5%
clear-num77.5%
frac-2neg77.5%
Applied egg-rr77.5%
*-commutative77.5%
Simplified77.5%
if 3.49999999999999999e56 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 55.4%
neg-mul-155.4%
rec-exp55.4%
neg-mul-155.4%
div-sub55.4%
+-inverses55.4%
Simplified55.4%
Final simplification68.3%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x 1.7e-276)
(/ (- 2.0 (* x eps)) 2.0)
(if (<= x 1.75e+56)
(/
(-
2.0
(*
x
(+
(/ 1.0 eps)
(* (/ (- -1.0 (/ -1.0 eps)) (+ eps -1.0)) (+ 1.0 (* eps eps))))))
2.0)
0.0)))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 1.7e-276) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if (x <= 1.75e+56) {
tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * 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.7d-276) then
tmp = (2.0d0 - (x * eps)) / 2.0d0
else if (x <= 1.75d+56) then
tmp = (2.0d0 - (x * ((1.0d0 / eps) + ((((-1.0d0) - ((-1.0d0) / eps)) / (eps + (-1.0d0))) * (1.0d0 + (eps * 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.7e-276) {
tmp = (2.0 - (x * eps)) / 2.0;
} else if (x <= 1.75e+56) {
tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * eps)))))) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 1.7e-276: tmp = (2.0 - (x * eps)) / 2.0 elif x <= 1.75e+56: tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * eps)))))) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 1.7e-276) tmp = Float64(Float64(2.0 - Float64(x * eps)) / 2.0); elseif (x <= 1.75e+56) tmp = Float64(Float64(2.0 - Float64(x * Float64(Float64(1.0 / eps) + Float64(Float64(Float64(-1.0 - Float64(-1.0 / eps)) / Float64(eps + -1.0)) * Float64(1.0 + Float64(eps * 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.7e-276) tmp = (2.0 - (x * eps)) / 2.0; elseif (x <= 1.75e+56) tmp = (2.0 - (x * ((1.0 / eps) + (((-1.0 - (-1.0 / eps)) / (eps + -1.0)) * (1.0 + (eps * 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.7e-276], N[(N[(2.0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.75e+56], N[(N[(2.0 - N[(x * N[(N[(1.0 / eps), $MachinePrecision] + N[(N[(N[(-1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] / N[(eps + -1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7 \cdot 10^{-276}:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{+56}:\\
\;\;\;\;\frac{2 - x \cdot \left(\frac{1}{\varepsilon} + \frac{-1 - \frac{-1}{\varepsilon}}{\varepsilon + -1} \cdot \left(1 + \varepsilon \cdot \varepsilon\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.69999999999999996e-276Initial program 69.2%
Simplified69.3%
Taylor expanded in x around 0 52.7%
Taylor expanded in eps around 0 62.9%
Taylor expanded in eps around 0 62.9%
neg-mul-162.9%
Simplified62.9%
if 1.69999999999999996e-276 < x < 1.75e56Initial program 61.6%
Simplified61.6%
Taylor expanded in x around 0 62.9%
Taylor expanded in eps around 0 64.9%
*-commutative64.9%
flip-+73.5%
associate-*r/73.5%
sub-neg73.5%
distribute-neg-frac73.5%
metadata-eval73.5%
metadata-eval73.5%
Applied egg-rr73.5%
*-commutative73.5%
associate-/l*73.5%
Simplified73.5%
div-inv73.5%
sub-neg73.5%
distribute-rgt-neg-in73.5%
add-sqr-sqrt41.6%
sqrt-unprod90.5%
sqr-neg90.5%
sqrt-prod48.9%
add-sqr-sqrt77.5%
clear-num77.5%
frac-2neg77.5%
Applied egg-rr77.5%
*-commutative77.5%
Simplified77.5%
if 1.75e56 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 55.4%
neg-mul-155.4%
rec-exp55.4%
neg-mul-155.4%
div-sub55.4%
+-inverses55.4%
Simplified55.4%
Final simplification65.8%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 185.0) (/ (- 2.0 (* x eps)) 2.0) 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 185.0) {
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 <= 185.0d0) 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 <= 185.0) {
tmp = (2.0 - (x * eps)) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 185.0: 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 <= 185.0) 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 <= 185.0) 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, 185.0], 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 185:\\
\;\;\;\;\frac{2 - x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 185Initial program 64.6%
Simplified64.6%
Taylor expanded in x around 0 59.3%
Taylor expanded in eps around 0 65.8%
Taylor expanded in eps around 0 65.8%
neg-mul-165.8%
Simplified65.8%
if 185 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 51.6%
neg-mul-151.6%
rec-exp51.6%
neg-mul-151.6%
div-sub51.6%
+-inverses51.6%
Simplified51.6%
Final simplification62.3%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 2.0) (/ (- 2.0 x) 2.0) 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 2.0) {
tmp = (2.0 - x) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 2.0d0) then
tmp = (2.0d0 - x) / 2.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 2.0) {
tmp = (2.0 - x) / 2.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 2.0: tmp = (2.0 - x) / 2.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 2.0) tmp = Float64(Float64(2.0 - x) / 2.0); else tmp = 0.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 2.0) tmp = (2.0 - x) / 2.0; else tmp = 0.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 2.0], N[(N[(2.0 - x), $MachinePrecision] / 2.0), $MachinePrecision], 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\frac{2 - x}{2}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 2Initial program 64.6%
Simplified38.2%
Taylor expanded in eps around inf 98.1%
Taylor expanded in eps around inf 98.1%
*-commutative98.1%
Simplified98.1%
Taylor expanded in x around 0 59.4%
neg-mul-159.4%
unsub-neg59.4%
Simplified59.4%
if 2 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 51.6%
neg-mul-151.6%
rec-exp51.6%
neg-mul-151.6%
div-sub51.6%
+-inverses51.6%
Simplified51.6%
Final simplification57.5%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 500.0) 1.0 0.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 500.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 <= 500.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 <= 500.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 500.0: tmp = 1.0 else: tmp = 0.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 500.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 <= 500.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, 500.0], 1.0, 0.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 500:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 500Initial program 64.6%
sub-neg64.6%
neg-sub064.6%
associate-+r-64.6%
Simplified64.6%
Taylor expanded in x around 0 59.3%
if 500 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 51.6%
neg-mul-151.6%
rec-exp51.6%
neg-mul-151.6%
div-sub51.6%
+-inverses51.6%
Simplified51.6%
Final simplification57.4%
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 73.3%
Simplified73.3%
Taylor expanded in eps around 0 14.4%
neg-mul-114.4%
rec-exp14.3%
neg-mul-114.3%
div-sub14.3%
+-inverses14.6%
Simplified14.6%
Final simplification14.6%
herbie shell --seed 2023278
(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))