
(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 14 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 (<= eps 1e-10)
(/ (+ (/ (+ 1.0 x) (exp x)) (* (+ 1.0 x) (exp (- x)))) 2.0)
(/
(+
(* (- 1.0 (/ -1.0 eps)) (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))
2.0)))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (eps <= 1e-10) {
tmp = (((1.0 + x) / exp(x)) + ((1.0 + x) * exp(-x))) / 2.0;
} else {
tmp = (((1.0 - (-1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / 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 <= 1d-10) then
tmp = (((1.0d0 + x) / exp(x)) + ((1.0d0 + x) * exp(-x))) / 2.0d0
else
tmp = (((1.0d0 - ((-1.0d0) / eps)) * exp((x * (eps + (-1.0d0))))) + (exp((x * ((-1.0d0) - eps))) * (1.0d0 + ((-1.0d0) / 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 <= 1e-10) {
tmp = (((1.0 + x) / Math.exp(x)) + ((1.0 + x) * Math.exp(-x))) / 2.0;
} else {
tmp = (((1.0 - (-1.0 / eps)) * Math.exp((x * (eps + -1.0)))) + (Math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if eps <= 1e-10: tmp = (((1.0 + x) / math.exp(x)) + ((1.0 + x) * math.exp(-x))) / 2.0 else: tmp = (((1.0 - (-1.0 / eps)) * math.exp((x * (eps + -1.0)))) + (math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (eps <= 1e-10) tmp = Float64(Float64(Float64(Float64(1.0 + x) / exp(x)) + Float64(Float64(1.0 + x) * exp(Float64(-x)))) / 2.0); else tmp = Float64(Float64(Float64(Float64(1.0 - Float64(-1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (eps <= 1e-10) tmp = (((1.0 + x) / exp(x)) + ((1.0 + x) * exp(-x))) / 2.0; else tmp = (((1.0 - (-1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[eps, 1e-10], N[(N[(N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 10^{-10}:\\
\;\;\;\;\frac{\frac{1 + x}{e^{x}} + \left(1 + x\right) \cdot e^{-x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{-1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if eps < 1.00000000000000004e-10Initial program 61.1%
Simplified61.1%
Taylor expanded in eps around 0 70.0%
Simplified71.1%
exp-neg71.1%
un-div-inv71.1%
+-commutative71.1%
Applied egg-rr71.1%
if 1.00000000000000004e-10 < eps Initial program 100.0%
Final simplification78.9%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (+ (/ (+ 1.0 x) (exp x)) (* (+ 1.0 x) (exp (- x)))) 2.0)))
(if (<= x -1.1e-228)
(/ (+ 1.0 (exp (* eps (- x)))) 2.0)
(if (<= x 1.2e+85)
(/ (+ 1.0 (exp (* eps x))) 2.0)
(if (<= x 3.4e+161)
t_0
(if (<= x 6e+193)
(/ (+ 1.0 (exp (* x (+ eps -1.0)))) 2.0)
(if (<= x 1.28e+238)
(/ (+ (- 1.0 (/ -1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)
t_0)))))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = (((1.0 + x) / exp(x)) + ((1.0 + x) * exp(-x))) / 2.0;
double tmp;
if (x <= -1.1e-228) {
tmp = (1.0 + exp((eps * -x))) / 2.0;
} else if (x <= 1.2e+85) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else if (x <= 3.4e+161) {
tmp = t_0;
} else if (x <= 6e+193) {
tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0;
} else if (x <= 1.28e+238) {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = t_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 = (((1.0d0 + x) / exp(x)) + ((1.0d0 + x) * exp(-x))) / 2.0d0
if (x <= (-1.1d-228)) then
tmp = (1.0d0 + exp((eps * -x))) / 2.0d0
else if (x <= 1.2d+85) then
tmp = (1.0d0 + exp((eps * x))) / 2.0d0
else if (x <= 3.4d+161) then
tmp = t_0
else if (x <= 6d+193) then
tmp = (1.0d0 + exp((x * (eps + (-1.0d0))))) / 2.0d0
else if (x <= 1.28d+238) then
tmp = ((1.0d0 - ((-1.0d0) / eps)) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
else
tmp = t_0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double t_0 = (((1.0 + x) / Math.exp(x)) + ((1.0 + x) * Math.exp(-x))) / 2.0;
double tmp;
if (x <= -1.1e-228) {
tmp = (1.0 + Math.exp((eps * -x))) / 2.0;
} else if (x <= 1.2e+85) {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
} else if (x <= 3.4e+161) {
tmp = t_0;
} else if (x <= 6e+193) {
tmp = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
} else if (x <= 1.28e+238) {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = t_0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = (((1.0 + x) / math.exp(x)) + ((1.0 + x) * math.exp(-x))) / 2.0 tmp = 0 if x <= -1.1e-228: tmp = (1.0 + math.exp((eps * -x))) / 2.0 elif x <= 1.2e+85: tmp = (1.0 + math.exp((eps * x))) / 2.0 elif x <= 3.4e+161: tmp = t_0 elif x <= 6e+193: tmp = (1.0 + math.exp((x * (eps + -1.0)))) / 2.0 elif x <= 1.28e+238: tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 else: tmp = t_0 return tmp
eps = abs(eps) function code(x, eps) t_0 = Float64(Float64(Float64(Float64(1.0 + x) / exp(x)) + Float64(Float64(1.0 + x) * exp(Float64(-x)))) / 2.0) tmp = 0.0 if (x <= -1.1e-228) tmp = Float64(Float64(1.0 + exp(Float64(eps * Float64(-x)))) / 2.0); elseif (x <= 1.2e+85) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); elseif (x <= 3.4e+161) tmp = t_0; elseif (x <= 6e+193) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) / 2.0); elseif (x <= 1.28e+238) tmp = Float64(Float64(Float64(1.0 - Float64(-1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); else tmp = t_0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) t_0 = (((1.0 + x) / exp(x)) + ((1.0 + x) * exp(-x))) / 2.0; tmp = 0.0; if (x <= -1.1e-228) tmp = (1.0 + exp((eps * -x))) / 2.0; elseif (x <= 1.2e+85) tmp = (1.0 + exp((eps * x))) / 2.0; elseif (x <= 3.4e+161) tmp = t_0; elseif (x <= 6e+193) tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0; elseif (x <= 1.28e+238) tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0; else tmp = t_0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, -1.1e-228], N[(N[(1.0 + N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.2e+85], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 3.4e+161], t$95$0, If[LessEqual[x, 6e+193], N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.28e+238], N[(N[(N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := \frac{\frac{1 + x}{e^{x}} + \left(1 + x\right) \cdot e^{-x}}{2}\\
\mathbf{if}\;x \leq -1.1 \cdot 10^{-228}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+85}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+161}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+193}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
\mathbf{elif}\;x \leq 1.28 \cdot 10^{+238}:\\
\;\;\;\;\frac{\left(1 - \frac{-1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.1e-228Initial program 69.2%
Simplified69.2%
Taylor expanded in x around 0 41.5%
Taylor expanded in eps around inf 68.4%
associate-*r*68.4%
exp-prod61.7%
remove-double-neg61.7%
neg-mul-161.7%
sub-neg61.7%
exp-prod68.4%
associate-*r*68.4%
mul-1-neg68.4%
associate-*r*68.4%
exp-prod61.7%
cancel-sign-sub-inv61.7%
metadata-eval61.7%
*-lft-identity61.7%
exp-prod68.4%
neg-mul-168.4%
Simplified68.4%
Taylor expanded in eps around inf 69.0%
if -1.1e-228 < x < 1.19999999999999998e85Initial program 59.2%
Simplified59.2%
Taylor expanded in x around 0 46.7%
Taylor expanded in eps around inf 87.4%
associate-*r*87.4%
exp-prod77.0%
remove-double-neg77.0%
neg-mul-177.0%
sub-neg77.0%
exp-prod87.4%
associate-*r*87.4%
mul-1-neg87.4%
associate-*r*87.4%
exp-prod77.0%
cancel-sign-sub-inv77.0%
metadata-eval77.0%
*-lft-identity77.0%
exp-prod87.4%
neg-mul-187.4%
Simplified87.4%
add-sqr-sqrt20.6%
sqrt-unprod77.9%
sqr-neg77.9%
sqrt-unprod61.1%
add-sqr-sqrt81.7%
+-commutative81.7%
distribute-lft-in81.7%
*-rgt-identity81.7%
Applied egg-rr81.7%
Taylor expanded in eps around inf 81.9%
*-commutative81.9%
Simplified81.9%
if 1.19999999999999998e85 < x < 3.39999999999999993e161 or 1.28000000000000007e238 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 69.9%
Simplified69.9%
exp-neg69.9%
un-div-inv69.9%
+-commutative69.9%
Applied egg-rr69.9%
if 3.39999999999999993e161 < x < 6e193Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 51.4%
Taylor expanded in eps around inf 51.6%
neg-mul-151.6%
distribute-lft-neg-in51.6%
Simplified51.6%
if 6e193 < x < 1.28000000000000007e238Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 29.0%
Taylor expanded in x around 0 56.0%
Final simplification73.3%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (/ (/ (+ (exp (- x)) (/ -1.0 (exp x))) eps) 2.0)))
(if (<= x -1.1e-228)
(/ (+ 1.0 (exp (* eps (- x)))) 2.0)
(if (<= x 4.6e+80)
(/ (+ 1.0 (exp (* eps x))) 2.0)
(if (<= x 4e+161)
t_0
(if (<= x 1.9e+194)
(/ (+ 1.0 (exp (* x (+ eps -1.0)))) 2.0)
(if (<= x 4.25e+241)
(/ (+ (- 1.0 (/ -1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)
t_0)))))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = ((exp(-x) + (-1.0 / exp(x))) / eps) / 2.0;
double tmp;
if (x <= -1.1e-228) {
tmp = (1.0 + exp((eps * -x))) / 2.0;
} else if (x <= 4.6e+80) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else if (x <= 4e+161) {
tmp = t_0;
} else if (x <= 1.9e+194) {
tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0;
} else if (x <= 4.25e+241) {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = t_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) + ((-1.0d0) / exp(x))) / eps) / 2.0d0
if (x <= (-1.1d-228)) then
tmp = (1.0d0 + exp((eps * -x))) / 2.0d0
else if (x <= 4.6d+80) then
tmp = (1.0d0 + exp((eps * x))) / 2.0d0
else if (x <= 4d+161) then
tmp = t_0
else if (x <= 1.9d+194) then
tmp = (1.0d0 + exp((x * (eps + (-1.0d0))))) / 2.0d0
else if (x <= 4.25d+241) then
tmp = ((1.0d0 - ((-1.0d0) / eps)) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
else
tmp = t_0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double t_0 = ((Math.exp(-x) + (-1.0 / Math.exp(x))) / eps) / 2.0;
double tmp;
if (x <= -1.1e-228) {
tmp = (1.0 + Math.exp((eps * -x))) / 2.0;
} else if (x <= 4.6e+80) {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
} else if (x <= 4e+161) {
tmp = t_0;
} else if (x <= 1.9e+194) {
tmp = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
} else if (x <= 4.25e+241) {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
} else {
tmp = t_0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = ((math.exp(-x) + (-1.0 / math.exp(x))) / eps) / 2.0 tmp = 0 if x <= -1.1e-228: tmp = (1.0 + math.exp((eps * -x))) / 2.0 elif x <= 4.6e+80: tmp = (1.0 + math.exp((eps * x))) / 2.0 elif x <= 4e+161: tmp = t_0 elif x <= 1.9e+194: tmp = (1.0 + math.exp((x * (eps + -1.0)))) / 2.0 elif x <= 4.25e+241: tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 else: tmp = t_0 return tmp
eps = abs(eps) function code(x, eps) t_0 = Float64(Float64(Float64(exp(Float64(-x)) + Float64(-1.0 / exp(x))) / eps) / 2.0) tmp = 0.0 if (x <= -1.1e-228) tmp = Float64(Float64(1.0 + exp(Float64(eps * Float64(-x)))) / 2.0); elseif (x <= 4.6e+80) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); elseif (x <= 4e+161) tmp = t_0; elseif (x <= 1.9e+194) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) / 2.0); elseif (x <= 4.25e+241) tmp = Float64(Float64(Float64(1.0 - Float64(-1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); else tmp = t_0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) t_0 = ((exp(-x) + (-1.0 / exp(x))) / eps) / 2.0; tmp = 0.0; if (x <= -1.1e-228) tmp = (1.0 + exp((eps * -x))) / 2.0; elseif (x <= 4.6e+80) tmp = (1.0 + exp((eps * x))) / 2.0; elseif (x <= 4e+161) tmp = t_0; elseif (x <= 1.9e+194) tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0; elseif (x <= 4.25e+241) tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0; else tmp = t_0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(N[Exp[(-x)], $MachinePrecision] + N[(-1.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, -1.1e-228], N[(N[(1.0 + N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 4.6e+80], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 4e+161], t$95$0, If[LessEqual[x, 1.9e+194], N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 4.25e+241], N[(N[(N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := \frac{\frac{e^{-x} + \frac{-1}{e^{x}}}{\varepsilon}}{2}\\
\mathbf{if}\;x \leq -1.1 \cdot 10^{-228}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{+80}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+161}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+194}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
\mathbf{elif}\;x \leq 4.25 \cdot 10^{+241}:\\
\;\;\;\;\frac{\left(1 - \frac{-1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.1e-228Initial program 69.2%
Simplified69.2%
Taylor expanded in x around 0 41.5%
Taylor expanded in eps around inf 68.4%
associate-*r*68.4%
exp-prod61.7%
remove-double-neg61.7%
neg-mul-161.7%
sub-neg61.7%
exp-prod68.4%
associate-*r*68.4%
mul-1-neg68.4%
associate-*r*68.4%
exp-prod61.7%
cancel-sign-sub-inv61.7%
metadata-eval61.7%
*-lft-identity61.7%
exp-prod68.4%
neg-mul-168.4%
Simplified68.4%
Taylor expanded in eps around inf 69.0%
if -1.1e-228 < x < 4.60000000000000008e80Initial program 59.2%
Simplified59.2%
Taylor expanded in x around 0 46.7%
Taylor expanded in eps around inf 87.4%
associate-*r*87.4%
exp-prod77.0%
remove-double-neg77.0%
neg-mul-177.0%
sub-neg77.0%
exp-prod87.4%
associate-*r*87.4%
mul-1-neg87.4%
associate-*r*87.4%
exp-prod77.0%
cancel-sign-sub-inv77.0%
metadata-eval77.0%
*-lft-identity77.0%
exp-prod87.4%
neg-mul-187.4%
Simplified87.4%
add-sqr-sqrt20.6%
sqrt-unprod77.9%
sqr-neg77.9%
sqrt-unprod61.1%
add-sqr-sqrt81.7%
+-commutative81.7%
distribute-lft-in81.7%
*-rgt-identity81.7%
Applied egg-rr81.7%
Taylor expanded in eps around inf 81.9%
*-commutative81.9%
Simplified81.9%
if 4.60000000000000008e80 < x < 4.0000000000000002e161 or 4.24999999999999977e241 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 69.9%
if 4.0000000000000002e161 < x < 1.8999999999999999e194Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 51.4%
Taylor expanded in eps around inf 51.6%
neg-mul-151.6%
distribute-lft-neg-in51.6%
Simplified51.6%
if 1.8999999999999999e194 < x < 4.24999999999999977e241Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 29.0%
Taylor expanded in x around 0 56.0%
Final simplification73.3%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x -22000000.0)
(/ (/ (expm1 (- x)) eps) 2.0)
(if (<= x 520.0)
1.0
(if (<= x 3e+80)
(/ (/ (expm1 x) eps) 2.0)
(/ (+ (- 1.0 (/ -1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -22000000.0) {
tmp = (expm1(-x) / eps) / 2.0;
} else if (x <= 520.0) {
tmp = 1.0;
} else if (x <= 3e+80) {
tmp = (expm1(x) / eps) / 2.0;
} else {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -22000000.0) {
tmp = (Math.expm1(-x) / eps) / 2.0;
} else if (x <= 520.0) {
tmp = 1.0;
} else if (x <= 3e+80) {
tmp = (Math.expm1(x) / eps) / 2.0;
} else {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -22000000.0: tmp = (math.expm1(-x) / eps) / 2.0 elif x <= 520.0: tmp = 1.0 elif x <= 3e+80: tmp = (math.expm1(x) / eps) / 2.0 else: tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -22000000.0) tmp = Float64(Float64(expm1(Float64(-x)) / eps) / 2.0); elseif (x <= 520.0) tmp = 1.0; elseif (x <= 3e+80) tmp = Float64(Float64(expm1(x) / eps) / 2.0); else tmp = Float64(Float64(Float64(1.0 - Float64(-1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); end return tmp end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -22000000.0], N[(N[(N[(Exp[(-x)] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 520.0], 1.0, If[LessEqual[x, 3e+80], N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -22000000:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(-x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 520:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+80}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{-1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < -2.2e7Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 50.3%
Taylor expanded in eps around 0 51.3%
expm1-def51.3%
neg-mul-151.3%
Simplified51.3%
if -2.2e7 < x < 520Initial program 51.8%
Simplified51.8%
Taylor expanded in x around 0 76.1%
if 520 < x < 2.99999999999999987e80Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 40.2%
Taylor expanded in eps around 0 1.8%
expm1-def1.8%
neg-mul-11.8%
Simplified1.8%
expm1-log1p-u1.8%
expm1-udef1.7%
expm1-udef1.7%
expm1-udef1.7%
add-sqr-sqrt0.0%
sqrt-unprod38.5%
sqr-neg38.5%
sqrt-unprod38.5%
add-sqr-sqrt38.5%
Applied egg-rr38.5%
expm1-def38.5%
expm1-log1p38.7%
Simplified38.7%
if 2.99999999999999987e80 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 26.3%
Taylor expanded in x around 0 56.1%
Final simplification66.3%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x -22000000.0)
(/ (/ (expm1 (- x)) eps) 2.0)
(if (<= x 1.85e+83)
(/ (+ 1.0 (exp (* eps x))) 2.0)
(/ (+ (- 1.0 (/ -1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -22000000.0) {
tmp = (expm1(-x) / eps) / 2.0;
} else if (x <= 1.85e+83) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -22000000.0) {
tmp = (Math.expm1(-x) / eps) / 2.0;
} else if (x <= 1.85e+83) {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
} else {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -22000000.0: tmp = (math.expm1(-x) / eps) / 2.0 elif x <= 1.85e+83: tmp = (1.0 + math.exp((eps * x))) / 2.0 else: tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -22000000.0) tmp = Float64(Float64(expm1(Float64(-x)) / eps) / 2.0); elseif (x <= 1.85e+83) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); else tmp = Float64(Float64(Float64(1.0 - Float64(-1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); end return tmp end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -22000000.0], N[(N[(N[(Exp[(-x)] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.85e+83], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -22000000:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(-x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{+83}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{-1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < -2.2e7Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 50.3%
Taylor expanded in eps around 0 51.3%
expm1-def51.3%
neg-mul-151.3%
Simplified51.3%
if -2.2e7 < x < 1.8500000000000001e83Initial program 55.7%
Simplified55.7%
Taylor expanded in x around 0 42.0%
Taylor expanded in eps around inf 83.9%
associate-*r*83.9%
exp-prod73.3%
remove-double-neg73.3%
neg-mul-173.3%
sub-neg73.3%
exp-prod83.9%
associate-*r*83.9%
mul-1-neg83.9%
associate-*r*83.9%
exp-prod73.3%
cancel-sign-sub-inv73.3%
metadata-eval73.3%
*-lft-identity73.3%
exp-prod83.9%
neg-mul-183.9%
Simplified83.9%
add-sqr-sqrt42.4%
sqrt-unprod76.8%
sqr-neg76.8%
sqrt-unprod38.0%
add-sqr-sqrt82.7%
+-commutative82.7%
distribute-lft-in82.7%
*-rgt-identity82.7%
Applied egg-rr82.7%
Taylor expanded in eps around inf 83.2%
*-commutative83.2%
Simplified83.2%
if 1.8500000000000001e83 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 26.3%
Taylor expanded in x around 0 56.1%
Final simplification72.8%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x -1.1e-228)
(/ (+ 1.0 (exp (* eps (- x)))) 2.0)
(if (<= x 3.2e+83)
(/ (+ 1.0 (exp (* eps x))) 2.0)
(/ (+ (- 1.0 (/ -1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -1.1e-228) {
tmp = (1.0 + exp((eps * -x))) / 2.0;
} else if (x <= 3.2e+83) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1.1d-228)) then
tmp = (1.0d0 + exp((eps * -x))) / 2.0d0
else if (x <= 3.2d+83) then
tmp = (1.0d0 + exp((eps * x))) / 2.0d0
else
tmp = ((1.0d0 - ((-1.0d0) / eps)) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -1.1e-228) {
tmp = (1.0 + Math.exp((eps * -x))) / 2.0;
} else if (x <= 3.2e+83) {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
} else {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -1.1e-228: tmp = (1.0 + math.exp((eps * -x))) / 2.0 elif x <= 3.2e+83: tmp = (1.0 + math.exp((eps * x))) / 2.0 else: tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -1.1e-228) tmp = Float64(Float64(1.0 + exp(Float64(eps * Float64(-x)))) / 2.0); elseif (x <= 3.2e+83) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); else tmp = Float64(Float64(Float64(1.0 - Float64(-1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.1e-228) tmp = (1.0 + exp((eps * -x))) / 2.0; elseif (x <= 3.2e+83) tmp = (1.0 + exp((eps * x))) / 2.0; else tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -1.1e-228], N[(N[(1.0 + N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 3.2e+83], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{-228}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot \left(-x\right)}}{2}\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{+83}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{-1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < -1.1e-228Initial program 69.2%
Simplified69.2%
Taylor expanded in x around 0 41.5%
Taylor expanded in eps around inf 68.4%
associate-*r*68.4%
exp-prod61.7%
remove-double-neg61.7%
neg-mul-161.7%
sub-neg61.7%
exp-prod68.4%
associate-*r*68.4%
mul-1-neg68.4%
associate-*r*68.4%
exp-prod61.7%
cancel-sign-sub-inv61.7%
metadata-eval61.7%
*-lft-identity61.7%
exp-prod68.4%
neg-mul-168.4%
Simplified68.4%
Taylor expanded in eps around inf 69.0%
if -1.1e-228 < x < 3.1999999999999999e83Initial program 59.2%
Simplified59.2%
Taylor expanded in x around 0 46.7%
Taylor expanded in eps around inf 87.4%
associate-*r*87.4%
exp-prod77.0%
remove-double-neg77.0%
neg-mul-177.0%
sub-neg77.0%
exp-prod87.4%
associate-*r*87.4%
mul-1-neg87.4%
associate-*r*87.4%
exp-prod77.0%
cancel-sign-sub-inv77.0%
metadata-eval77.0%
*-lft-identity77.0%
exp-prod87.4%
neg-mul-187.4%
Simplified87.4%
add-sqr-sqrt20.6%
sqrt-unprod77.9%
sqr-neg77.9%
sqrt-unprod61.1%
add-sqr-sqrt81.7%
+-commutative81.7%
distribute-lft-in81.7%
*-rgt-identity81.7%
Applied egg-rr81.7%
Taylor expanded in eps around inf 81.9%
*-commutative81.9%
Simplified81.9%
if 3.1999999999999999e83 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 26.3%
Taylor expanded in x around 0 56.1%
Final simplification71.5%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x 180.0)
(/ (+ 2.0 (- x (* eps x))) 2.0)
(if (<= x 5.9e+84)
(/ (/ (expm1 x) eps) 2.0)
(/ (+ (- 1.0 (/ -1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 180.0) {
tmp = (2.0 + (x - (eps * x))) / 2.0;
} else if (x <= 5.9e+84) {
tmp = (expm1(x) / eps) / 2.0;
} else {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 180.0) {
tmp = (2.0 + (x - (eps * x))) / 2.0;
} else if (x <= 5.9e+84) {
tmp = (Math.expm1(x) / eps) / 2.0;
} else {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 180.0: tmp = (2.0 + (x - (eps * x))) / 2.0 elif x <= 5.9e+84: tmp = (math.expm1(x) / eps) / 2.0 else: tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 180.0) tmp = Float64(Float64(2.0 + Float64(x - Float64(eps * x))) / 2.0); elseif (x <= 5.9e+84) tmp = Float64(Float64(expm1(x) / eps) / 2.0); else tmp = Float64(Float64(Float64(1.0 - Float64(-1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); end return tmp end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 180.0], N[(N[(2.0 + N[(x - N[(eps * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 5.9e+84], N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 180:\\
\;\;\;\;\frac{2 + \left(x - \varepsilon \cdot x\right)}{2}\\
\mathbf{elif}\;x \leq 5.9 \cdot 10^{+84}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{-1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < 180Initial program 61.7%
Simplified61.7%
Taylor expanded in x around 0 42.8%
Taylor expanded in x around 0 49.4%
mul-1-neg49.4%
unsub-neg49.4%
associate-*r*49.4%
*-commutative49.4%
Simplified49.4%
Taylor expanded in eps around inf 65.4%
*-commutative65.4%
sub-neg65.4%
distribute-rgt-in65.4%
*-un-lft-identity65.4%
distribute-lft-neg-in65.4%
distribute-rgt-neg-in65.4%
add-sqr-sqrt38.6%
sqrt-unprod67.1%
sqr-neg67.1%
sqrt-unprod27.0%
add-sqr-sqrt67.0%
*-commutative67.0%
+-commutative67.0%
add-sqr-sqrt27.0%
sqrt-unprod63.2%
sqr-neg63.2%
sqrt-unprod40.0%
add-sqr-sqrt67.0%
sub-neg67.0%
*-commutative67.0%
Applied egg-rr67.0%
if 180 < x < 5.89999999999999984e84Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 40.2%
Taylor expanded in eps around 0 1.8%
expm1-def1.8%
neg-mul-11.8%
Simplified1.8%
expm1-log1p-u1.8%
expm1-udef1.7%
expm1-udef1.7%
expm1-udef1.7%
add-sqr-sqrt0.0%
sqrt-unprod38.5%
sqr-neg38.5%
sqrt-unprod38.5%
add-sqr-sqrt38.5%
Applied egg-rr38.5%
expm1-def38.5%
expm1-log1p38.7%
Simplified38.7%
if 5.89999999999999984e84 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 26.3%
Taylor expanded in x around 0 56.1%
Final simplification63.3%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x 660.0)
(/ (+ 1.0 (exp (- x))) 2.0)
(if (<= x 4.6e+82)
(/ (/ (expm1 x) eps) 2.0)
(/ (+ (- 1.0 (/ -1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 660.0) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if (x <= 4.6e+82) {
tmp = (expm1(x) / eps) / 2.0;
} else {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 660.0) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if (x <= 4.6e+82) {
tmp = (Math.expm1(x) / eps) / 2.0;
} else {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 660.0: tmp = (1.0 + math.exp(-x)) / 2.0 elif x <= 4.6e+82: tmp = (math.expm1(x) / eps) / 2.0 else: tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 660.0) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif (x <= 4.6e+82) tmp = Float64(Float64(expm1(x) / eps) / 2.0); else tmp = Float64(Float64(Float64(1.0 - Float64(-1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); end return tmp end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 660.0], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 4.6e+82], N[(N[(N[(Exp[x] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 660:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 4.6 \cdot 10^{+82}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(x\right)}{\varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{-1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < 660Initial program 61.7%
Simplified61.7%
Taylor expanded in x around 0 43.9%
Taylor expanded in eps around inf 80.0%
associate-*r*80.0%
exp-prod70.9%
remove-double-neg70.9%
neg-mul-170.9%
sub-neg70.9%
exp-prod80.0%
associate-*r*80.0%
mul-1-neg80.0%
associate-*r*80.0%
exp-prod70.9%
cancel-sign-sub-inv70.9%
metadata-eval70.9%
*-lft-identity70.9%
exp-prod80.0%
neg-mul-180.0%
Simplified80.0%
Taylor expanded in eps around 0 80.6%
if 660 < x < 4.59999999999999976e82Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 40.2%
Taylor expanded in eps around 0 1.8%
expm1-def1.8%
neg-mul-11.8%
Simplified1.8%
expm1-log1p-u1.8%
expm1-udef1.7%
expm1-udef1.7%
expm1-udef1.7%
add-sqr-sqrt0.0%
sqrt-unprod38.5%
sqr-neg38.5%
sqrt-unprod38.5%
add-sqr-sqrt38.5%
Applied egg-rr38.5%
expm1-def38.5%
expm1-log1p38.7%
Simplified38.7%
if 4.59999999999999976e82 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 26.3%
Taylor expanded in x around 0 56.1%
Final simplification73.4%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 135.0) (/ (+ 2.0 (- x (* eps x))) 2.0) (/ (+ (- 1.0 (/ -1.0 eps)) (+ 1.0 (/ -1.0 eps))) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= 135.0) {
tmp = (2.0 + (x - (eps * x))) / 2.0;
} else {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 135.0d0) then
tmp = (2.0d0 + (x - (eps * x))) / 2.0d0
else
tmp = ((1.0d0 - ((-1.0d0) / eps)) + (1.0d0 + ((-1.0d0) / eps))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= 135.0) {
tmp = (2.0 + (x - (eps * x))) / 2.0;
} else {
tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= 135.0: tmp = (2.0 + (x - (eps * x))) / 2.0 else: tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= 135.0) tmp = Float64(Float64(2.0 + Float64(x - Float64(eps * x))) / 2.0); else tmp = Float64(Float64(Float64(1.0 - Float64(-1.0 / eps)) + Float64(1.0 + Float64(-1.0 / eps))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 135.0) tmp = (2.0 + (x - (eps * x))) / 2.0; else tmp = ((1.0 - (-1.0 / eps)) + (1.0 + (-1.0 / eps))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, 135.0], N[(N[(2.0 + N[(x - N[(eps * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 - N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 135:\\
\;\;\;\;\frac{2 + \left(x - \varepsilon \cdot x\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{-1}{\varepsilon}\right) + \left(1 + \frac{-1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < 135Initial program 61.7%
Simplified61.7%
Taylor expanded in x around 0 42.8%
Taylor expanded in x around 0 49.4%
mul-1-neg49.4%
unsub-neg49.4%
associate-*r*49.4%
*-commutative49.4%
Simplified49.4%
Taylor expanded in eps around inf 65.4%
*-commutative65.4%
sub-neg65.4%
distribute-rgt-in65.4%
*-un-lft-identity65.4%
distribute-lft-neg-in65.4%
distribute-rgt-neg-in65.4%
add-sqr-sqrt38.6%
sqrt-unprod67.1%
sqr-neg67.1%
sqrt-unprod27.0%
add-sqr-sqrt67.0%
*-commutative67.0%
+-commutative67.0%
add-sqr-sqrt27.0%
sqrt-unprod63.2%
sqr-neg63.2%
sqrt-unprod40.0%
add-sqr-sqrt67.0%
sub-neg67.0%
*-commutative67.0%
Applied egg-rr67.0%
if 135 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 29.1%
Taylor expanded in x around 0 48.6%
Final simplification62.2%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -1.0) (/ (+ 2.0 (* x (- (/ 1.0 eps) eps))) 2.0) (/ (+ 2.0 (* eps x)) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -1.0) {
tmp = (2.0 + (x * ((1.0 / eps) - eps))) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = (2.0d0 + (x * ((1.0d0 / eps) - eps))) / 2.0d0
else
tmp = (2.0d0 + (eps * x)) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -1.0) {
tmp = (2.0 + (x * ((1.0 / eps) - eps))) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -1.0: tmp = (2.0 + (x * ((1.0 / eps) - eps))) / 2.0 else: tmp = (2.0 + (eps * x)) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(Float64(1.0 / eps) - eps))) / 2.0); else tmp = Float64(Float64(2.0 + Float64(eps * x)) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.0) tmp = (2.0 + (x * ((1.0 / eps) - eps))) / 2.0; else tmp = (2.0 + (eps * x)) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -1.0], N[(N[(2.0 + N[(x * N[(N[(1.0 / eps), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{2 + x \cdot \left(\frac{1}{\varepsilon} - \varepsilon\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\end{array}
\end{array}
if x < -1Initial program 95.1%
Simplified95.1%
Taylor expanded in x around 0 50.3%
Taylor expanded in x around 0 26.0%
mul-1-neg26.0%
unsub-neg26.0%
associate-*r*26.0%
*-commutative26.0%
Simplified26.0%
Taylor expanded in eps around 0 26.0%
div-inv26.0%
add-sqr-sqrt0.0%
sqrt-unprod33.0%
sqr-neg33.0%
sqrt-unprod26.1%
add-sqr-sqrt26.1%
cancel-sign-sub-inv26.1%
div-inv26.1%
mul-1-neg26.1%
distribute-rgt-neg-in26.1%
add-sqr-sqrt26.1%
sqrt-unprod33.0%
sqr-neg33.0%
sqrt-unprod0.0%
add-sqr-sqrt33.1%
Applied egg-rr33.1%
*-lft-identity33.1%
associate-*l/33.1%
cancel-sign-sub-inv33.1%
distribute-rgt-in33.1%
distribute-neg-frac33.1%
metadata-eval33.1%
Simplified33.1%
if -1 < x Initial program 67.1%
Simplified67.1%
Taylor expanded in x around 0 37.2%
Taylor expanded in x around 0 43.8%
mul-1-neg43.8%
unsub-neg43.8%
associate-*r*43.8%
*-commutative43.8%
Simplified43.8%
Taylor expanded in eps around inf 58.1%
Taylor expanded in eps around inf 58.6%
associate-*r*58.6%
neg-mul-158.6%
Simplified58.6%
Final simplification54.5%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -22000000.0) (/ (- 2.0 (+ x (* eps x))) 2.0) (/ (+ 2.0 (* eps x)) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -22000000.0) {
tmp = (2.0 - (x + (eps * x))) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-22000000.0d0)) then
tmp = (2.0d0 - (x + (eps * x))) / 2.0d0
else
tmp = (2.0d0 + (eps * x)) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -22000000.0) {
tmp = (2.0 - (x + (eps * x))) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -22000000.0: tmp = (2.0 - (x + (eps * x))) / 2.0 else: tmp = (2.0 + (eps * x)) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -22000000.0) tmp = Float64(Float64(2.0 - Float64(x + Float64(eps * x))) / 2.0); else tmp = Float64(Float64(2.0 + Float64(eps * x)) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -22000000.0) tmp = (2.0 - (x + (eps * x))) / 2.0; else tmp = (2.0 + (eps * x)) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -22000000.0], N[(N[(2.0 - N[(x + N[(eps * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -22000000:\\
\;\;\;\;\frac{2 - \left(x + \varepsilon \cdot x\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\end{array}
\end{array}
if x < -2.2e7Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 50.3%
Taylor expanded in x around 0 27.2%
mul-1-neg27.2%
unsub-neg27.2%
associate-*r*27.2%
*-commutative27.2%
Simplified27.2%
Taylor expanded in eps around inf 27.2%
*-commutative27.2%
sub-neg27.2%
distribute-rgt-in27.2%
*-un-lft-identity27.2%
distribute-lft-neg-in27.2%
distribute-rgt-neg-in27.2%
add-sqr-sqrt27.2%
sqrt-unprod34.5%
sqr-neg34.5%
sqrt-unprod0.0%
add-sqr-sqrt34.6%
*-commutative34.6%
+-commutative34.6%
*-commutative34.6%
Applied egg-rr34.6%
if -2.2e7 < x Initial program 66.5%
Simplified66.5%
Taylor expanded in x around 0 37.3%
Taylor expanded in x around 0 43.4%
mul-1-neg43.4%
unsub-neg43.4%
associate-*r*43.4%
*-commutative43.4%
Simplified43.4%
Taylor expanded in eps around inf 57.6%
Taylor expanded in eps around inf 58.0%
associate-*r*58.0%
neg-mul-158.0%
Simplified58.0%
Final simplification54.5%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -0.013) (/ (+ 2.0 (- x (* eps x))) 2.0) (/ (+ 2.0 (* eps x)) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -0.013) {
tmp = (2.0 + (x - (eps * x))) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-0.013d0)) then
tmp = (2.0d0 + (x - (eps * x))) / 2.0d0
else
tmp = (2.0d0 + (eps * x)) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -0.013) {
tmp = (2.0 + (x - (eps * x))) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -0.013: tmp = (2.0 + (x - (eps * x))) / 2.0 else: tmp = (2.0 + (eps * x)) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -0.013) tmp = Float64(Float64(2.0 + Float64(x - Float64(eps * x))) / 2.0); else tmp = Float64(Float64(2.0 + Float64(eps * x)) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -0.013) tmp = (2.0 + (x - (eps * x))) / 2.0; else tmp = (2.0 + (eps * x)) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -0.013], N[(N[(2.0 + N[(x - N[(eps * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.013:\\
\;\;\;\;\frac{2 + \left(x - \varepsilon \cdot x\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\end{array}
\end{array}
if x < -0.0129999999999999994Initial program 95.1%
Simplified95.1%
Taylor expanded in x around 0 50.3%
Taylor expanded in x around 0 26.0%
mul-1-neg26.0%
unsub-neg26.0%
associate-*r*26.0%
*-commutative26.0%
Simplified26.0%
Taylor expanded in eps around inf 25.9%
*-commutative25.9%
sub-neg25.9%
distribute-rgt-in25.9%
*-un-lft-identity25.9%
distribute-lft-neg-in25.9%
distribute-rgt-neg-in25.9%
add-sqr-sqrt25.9%
sqrt-unprod32.8%
sqr-neg32.8%
sqrt-unprod0.0%
add-sqr-sqrt33.0%
*-commutative33.0%
+-commutative33.0%
add-sqr-sqrt0.0%
sqrt-unprod15.7%
sqr-neg15.7%
sqrt-unprod33.1%
add-sqr-sqrt33.1%
sub-neg33.1%
*-commutative33.1%
Applied egg-rr33.1%
if -0.0129999999999999994 < x Initial program 67.1%
Simplified67.1%
Taylor expanded in x around 0 37.2%
Taylor expanded in x around 0 43.8%
mul-1-neg43.8%
unsub-neg43.8%
associate-*r*43.8%
*-commutative43.8%
Simplified43.8%
Taylor expanded in eps around inf 58.1%
Taylor expanded in eps around inf 58.6%
associate-*r*58.6%
neg-mul-158.6%
Simplified58.6%
Final simplification54.5%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (/ (+ 2.0 (* eps x)) 2.0))
eps = abs(eps);
double code(double x, double eps) {
return (2.0 + (eps * x)) / 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 = (2.0d0 + (eps * x)) / 2.0d0
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
return (2.0 + (eps * x)) / 2.0;
}
eps = abs(eps) def code(x, eps): return (2.0 + (eps * x)) / 2.0
eps = abs(eps) function code(x, eps) return Float64(Float64(2.0 + Float64(eps * x)) / 2.0) end
eps = abs(eps) function tmp = code(x, eps) tmp = (2.0 + (eps * x)) / 2.0; end
NOTE: eps should be positive before calling this function code[x_, eps_] := N[(N[(2.0 + N[(eps * x), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps = |eps|\\
\\
\frac{2 + \varepsilon \cdot x}{2}
\end{array}
Initial program 71.6%
Simplified71.6%
Taylor expanded in x around 0 39.3%
Taylor expanded in x around 0 41.0%
mul-1-neg41.0%
unsub-neg41.0%
associate-*r*41.0%
*-commutative41.0%
Simplified41.0%
Taylor expanded in eps around inf 52.9%
Taylor expanded in eps around inf 53.4%
associate-*r*53.4%
neg-mul-153.4%
Simplified53.4%
Final simplification53.4%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 1.0)
eps = abs(eps);
double code(double x, double eps) {
return 1.0;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
return 1.0;
}
eps = abs(eps) def code(x, eps): return 1.0
eps = abs(eps) function code(x, eps) return 1.0 end
eps = abs(eps) function tmp = code(x, eps) tmp = 1.0; end
NOTE: eps should be positive before calling this function code[x_, eps_] := 1.0
\begin{array}{l}
eps = |eps|\\
\\
1
\end{array}
Initial program 71.6%
Simplified71.6%
Taylor expanded in x around 0 46.2%
Final simplification46.2%
herbie shell --seed 2023314
(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))