
(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-16)
(/ (+ (/ (+ x 1.0) (exp x)) (* (+ x 1.0) (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-16) {
tmp = (((x + 1.0) / exp(x)) + ((x + 1.0) * 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-16) then
tmp = (((x + 1.0d0) / exp(x)) + ((x + 1.0d0) * 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-16) {
tmp = (((x + 1.0) / Math.exp(x)) + ((x + 1.0) * 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-16: tmp = (((x + 1.0) / math.exp(x)) + ((x + 1.0) * 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-16) tmp = Float64(Float64(Float64(Float64(x + 1.0) / exp(x)) + Float64(Float64(x + 1.0) * 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-16) tmp = (((x + 1.0) / exp(x)) + ((x + 1.0) * 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-16], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + N[(N[(x + 1.0), $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^{-16}:\\
\;\;\;\;\frac{\frac{x + 1}{e^{x}} + \left(x + 1\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 < 9.9999999999999998e-17Initial program 57.3%
Simplified57.3%
Taylor expanded in eps around 0 74.9%
Simplified75.5%
exp-neg75.5%
un-div-inv75.5%
Applied egg-rr75.5%
if 9.9999999999999998e-17 < eps Initial program 100.0%
Final simplification82.4%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(if (<= x -1e-289)
(/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0)
(if (<= x 6.2e+33)
(/ (+ 1.0 (exp (* eps x))) 2.0)
(if (<= x 2.5e+88)
(/ (+ (+ 1.0 (/ 1.0 eps)) (- 1.0 (/ 1.0 eps))) 2.0)
(if (<= x 3.8e+223)
(/ (+ 1.0 (exp (* x (+ eps -1.0)))) 2.0)
(/ (+ (/ (+ x 1.0) (exp x)) (* (+ x 1.0) (exp (- x)))) 2.0))))))eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -1e-289) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 6.2e+33) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else if (x <= 2.5e+88) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else if (x <= 3.8e+223) {
tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0;
} else {
tmp = (((x + 1.0) / exp(x)) + ((x + 1.0) * exp(-x))) / 2.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1d-289)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else if (x <= 6.2d+33) then
tmp = (1.0d0 + exp((eps * x))) / 2.0d0
else if (x <= 2.5d+88) then
tmp = ((1.0d0 + (1.0d0 / eps)) + (1.0d0 - (1.0d0 / eps))) / 2.0d0
else if (x <= 3.8d+223) then
tmp = (1.0d0 + exp((x * (eps + (-1.0d0))))) / 2.0d0
else
tmp = (((x + 1.0d0) / exp(x)) + ((x + 1.0d0) * exp(-x))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double tmp;
if (x <= -1e-289) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 6.2e+33) {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
} else if (x <= 2.5e+88) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else if (x <= 3.8e+223) {
tmp = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
} else {
tmp = (((x + 1.0) / Math.exp(x)) + ((x + 1.0) * Math.exp(-x))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -1e-289: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 elif x <= 6.2e+33: tmp = (1.0 + math.exp((eps * x))) / 2.0 elif x <= 2.5e+88: tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0 elif x <= 3.8e+223: tmp = (1.0 + math.exp((x * (eps + -1.0)))) / 2.0 else: tmp = (((x + 1.0) / math.exp(x)) + ((x + 1.0) * math.exp(-x))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -1e-289) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif (x <= 6.2e+33) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); elseif (x <= 2.5e+88) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 - Float64(1.0 / eps))) / 2.0); elseif (x <= 3.8e+223) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) / 2.0); else tmp = Float64(Float64(Float64(Float64(x + 1.0) / exp(x)) + Float64(Float64(x + 1.0) * exp(Float64(-x)))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1e-289) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; elseif (x <= 6.2e+33) tmp = (1.0 + exp((eps * x))) / 2.0; elseif (x <= 2.5e+88) tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0; elseif (x <= 3.8e+223) tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0; else tmp = (((x + 1.0) / exp(x)) + ((x + 1.0) * exp(-x))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function code[x_, eps_] := If[LessEqual[x, -1e-289], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6.2e+33], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.5e+88], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 3.8e+223], N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] + N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-289}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{+33}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+88}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+223}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + 1}{e^{x}} + \left(x + 1\right) \cdot e^{-x}}{2}\\
\end{array}
\end{array}
if x < -1e-289Initial program 69.5%
Simplified69.5%
Taylor expanded in x around 0 50.6%
Taylor expanded in eps around inf 78.8%
sub-neg78.8%
mul-1-neg78.8%
remove-double-neg78.8%
mul-1-neg78.8%
distribute-rgt-neg-in78.8%
mul-1-neg78.8%
distribute-lft-in78.8%
metadata-eval78.8%
neg-mul-178.8%
Simplified78.8%
if -1e-289 < x < 6.2e33Initial program 46.5%
Simplified46.5%
Taylor expanded in x around 0 29.5%
Taylor expanded in eps around inf 82.3%
neg-mul-182.3%
distribute-rgt-neg-in82.3%
Simplified82.3%
Taylor expanded in eps around inf 82.5%
if 6.2e33 < x < 2.49999999999999999e88Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 17.4%
Taylor expanded in x around 0 73.9%
if 2.49999999999999999e88 < x < 3.8e223Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 39.3%
Taylor expanded in eps around inf 39.5%
neg-mul-139.5%
distribute-rgt-neg-in39.5%
Simplified39.5%
if 3.8e223 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 76.6%
Simplified76.6%
exp-neg76.6%
un-div-inv76.6%
Applied egg-rr76.6%
Final simplification75.8%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (- (/ 1.0 eps) (/ 1.0 eps)))))
(if (<= x -21500.0)
(/ (/ (expm1 (- x)) eps) 2.0)
(if (<= x 2.1e+33)
(/ (+ 1.0 (exp (* eps x))) 2.0)
(if (<= x 2.7e+87)
(/ (+ (+ 1.0 (/ 1.0 eps)) (- 1.0 (/ 1.0 eps))) 2.0)
(if (<= x 4.2e+225)
(/ (+ 1.0 (exp (* x (+ eps -1.0)))) 2.0)
(/
(/
(+ -1.0 (* t_0 t_0))
(+ (/ 1.0 eps) (+ 1.0 (+ -1.0 (/ 1.0 eps)))))
2.0)))))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps));
double tmp;
if (x <= -21500.0) {
tmp = (expm1(-x) / eps) / 2.0;
} else if (x <= 2.1e+33) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else if (x <= 2.7e+87) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else if (x <= 4.2e+225) {
tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0;
} else {
tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-1.0 + (1.0 / eps))))) / 2.0;
}
return tmp;
}
eps = Math.abs(eps);
public static double code(double x, double eps) {
double t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps));
double tmp;
if (x <= -21500.0) {
tmp = (Math.expm1(-x) / eps) / 2.0;
} else if (x <= 2.1e+33) {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
} else if (x <= 2.7e+87) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else if (x <= 4.2e+225) {
tmp = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
} else {
tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-1.0 + (1.0 / eps))))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps)) tmp = 0 if x <= -21500.0: tmp = (math.expm1(-x) / eps) / 2.0 elif x <= 2.1e+33: tmp = (1.0 + math.exp((eps * x))) / 2.0 elif x <= 2.7e+87: tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0 elif x <= 4.2e+225: tmp = (1.0 + math.exp((x * (eps + -1.0)))) / 2.0 else: tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-1.0 + (1.0 / eps))))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) t_0 = Float64(1.0 + Float64(Float64(1.0 / eps) - Float64(1.0 / eps))) tmp = 0.0 if (x <= -21500.0) tmp = Float64(Float64(expm1(Float64(-x)) / eps) / 2.0); elseif (x <= 2.1e+33) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); elseif (x <= 2.7e+87) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 - Float64(1.0 / eps))) / 2.0); elseif (x <= 4.2e+225) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) / 2.0); else tmp = Float64(Float64(Float64(-1.0 + Float64(t_0 * t_0)) / Float64(Float64(1.0 / eps) + Float64(1.0 + 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_] := Block[{t$95$0 = N[(1.0 + N[(N[(1.0 / eps), $MachinePrecision] - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -21500.0], N[(N[(N[(Exp[(-x)] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.1e+33], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.7e+87], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 4.2e+225], N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(-1.0 + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / eps), $MachinePrecision] + N[(1.0 + N[(-1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := 1 + \left(\frac{1}{\varepsilon} - \frac{1}{\varepsilon}\right)\\
\mathbf{if}\;x \leq -21500:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(-x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+33}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+87}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{+225}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1 + t_0 \cdot t_0}{\frac{1}{\varepsilon} + \left(1 + \left(-1 + \frac{1}{\varepsilon}\right)\right)}}{2}\\
\end{array}
\end{array}
if x < -21500Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 37.7%
Taylor expanded in eps around 0 64.3%
expm1-def64.3%
neg-mul-164.3%
Simplified64.3%
if -21500 < x < 2.1000000000000001e33Initial program 50.0%
Simplified50.0%
Taylor expanded in x around 0 33.8%
Taylor expanded in eps around inf 81.5%
neg-mul-181.5%
distribute-rgt-neg-in81.5%
Simplified81.5%
Taylor expanded in eps around inf 81.9%
if 2.1000000000000001e33 < x < 2.70000000000000007e87Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 17.4%
Taylor expanded in x around 0 73.9%
if 2.70000000000000007e87 < x < 4.2e225Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 39.3%
Taylor expanded in eps around inf 39.5%
neg-mul-139.5%
distribute-rgt-neg-in39.5%
Simplified39.5%
if 4.2e225 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 16.3%
Taylor expanded in x around 0 72.3%
associate--r-3.1%
flip-+2.2%
associate--l+2.2%
associate--l+71.4%
metadata-eval71.4%
*-un-lft-identity71.4%
cancel-sign-sub-inv71.4%
metadata-eval71.4%
add-sqr-sqrt38.1%
sqrt-unprod71.4%
sqr-neg71.4%
sqrt-unprod38.1%
add-sqr-sqrt76.2%
div-inv76.2%
metadata-eval76.2%
frac-2neg76.2%
Applied egg-rr76.6%
Final simplification74.8%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (- (/ 1.0 eps) (/ 1.0 eps)))))
(if (<= x -1.56e-291)
(/ (+ 1.0 (exp (* x (- -1.0 eps)))) 2.0)
(if (<= x 8.8e+33)
(/ (+ 1.0 (exp (* eps x))) 2.0)
(if (<= x 2.9e+88)
(/ (+ (+ 1.0 (/ 1.0 eps)) (- 1.0 (/ 1.0 eps))) 2.0)
(if (<= x 1.75e+227)
(/ (+ 1.0 (exp (* x (+ eps -1.0)))) 2.0)
(/
(/
(+ -1.0 (* t_0 t_0))
(+ (/ 1.0 eps) (+ 1.0 (+ -1.0 (/ 1.0 eps)))))
2.0)))))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps));
double tmp;
if (x <= -1.56e-291) {
tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 8.8e+33) {
tmp = (1.0 + exp((eps * x))) / 2.0;
} else if (x <= 2.9e+88) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else if (x <= 1.75e+227) {
tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0;
} else {
tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + ((1.0d0 / eps) - (1.0d0 / eps))
if (x <= (-1.56d-291)) then
tmp = (1.0d0 + exp((x * ((-1.0d0) - eps)))) / 2.0d0
else if (x <= 8.8d+33) then
tmp = (1.0d0 + exp((eps * x))) / 2.0d0
else if (x <= 2.9d+88) then
tmp = ((1.0d0 + (1.0d0 / eps)) + (1.0d0 - (1.0d0 / eps))) / 2.0d0
else if (x <= 1.75d+227) then
tmp = (1.0d0 + exp((x * (eps + (-1.0d0))))) / 2.0d0
else
tmp = (((-1.0d0) + (t_0 * t_0)) / ((1.0d0 / eps) + (1.0d0 + ((-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 t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps));
double tmp;
if (x <= -1.56e-291) {
tmp = (1.0 + Math.exp((x * (-1.0 - eps)))) / 2.0;
} else if (x <= 8.8e+33) {
tmp = (1.0 + Math.exp((eps * x))) / 2.0;
} else if (x <= 2.9e+88) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else if (x <= 1.75e+227) {
tmp = (1.0 + Math.exp((x * (eps + -1.0)))) / 2.0;
} else {
tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-1.0 + (1.0 / eps))))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps)) tmp = 0 if x <= -1.56e-291: tmp = (1.0 + math.exp((x * (-1.0 - eps)))) / 2.0 elif x <= 8.8e+33: tmp = (1.0 + math.exp((eps * x))) / 2.0 elif x <= 2.9e+88: tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0 elif x <= 1.75e+227: tmp = (1.0 + math.exp((x * (eps + -1.0)))) / 2.0 else: tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-1.0 + (1.0 / eps))))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) t_0 = Float64(1.0 + Float64(Float64(1.0 / eps) - Float64(1.0 / eps))) tmp = 0.0 if (x <= -1.56e-291) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-1.0 - eps)))) / 2.0); elseif (x <= 8.8e+33) tmp = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0); elseif (x <= 2.9e+88) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 - Float64(1.0 / eps))) / 2.0); elseif (x <= 1.75e+227) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(eps + -1.0)))) / 2.0); else tmp = Float64(Float64(Float64(-1.0 + Float64(t_0 * t_0)) / Float64(Float64(1.0 / eps) + Float64(1.0 + Float64(-1.0 + Float64(1.0 / eps))))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps)); tmp = 0.0; if (x <= -1.56e-291) tmp = (1.0 + exp((x * (-1.0 - eps)))) / 2.0; elseif (x <= 8.8e+33) tmp = (1.0 + exp((eps * x))) / 2.0; elseif (x <= 2.9e+88) tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0; elseif (x <= 1.75e+227) tmp = (1.0 + exp((x * (eps + -1.0)))) / 2.0; else tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-1.0 + (1.0 / 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[(1.0 + N[(N[(1.0 / eps), $MachinePrecision] - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.56e-291], N[(N[(1.0 + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 8.8e+33], N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.9e+88], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.75e+227], N[(N[(1.0 + N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(-1.0 + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / eps), $MachinePrecision] + N[(1.0 + N[(-1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := 1 + \left(\frac{1}{\varepsilon} - \frac{1}{\varepsilon}\right)\\
\mathbf{if}\;x \leq -1.56 \cdot 10^{-291}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-1 - \varepsilon\right)}}{2}\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{+33}:\\
\;\;\;\;\frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{+88}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{+227}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(\varepsilon + -1\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1 + t_0 \cdot t_0}{\frac{1}{\varepsilon} + \left(1 + \left(-1 + \frac{1}{\varepsilon}\right)\right)}}{2}\\
\end{array}
\end{array}
if x < -1.56e-291Initial program 69.5%
Simplified69.5%
Taylor expanded in x around 0 50.6%
Taylor expanded in eps around inf 78.8%
sub-neg78.8%
mul-1-neg78.8%
remove-double-neg78.8%
mul-1-neg78.8%
distribute-rgt-neg-in78.8%
mul-1-neg78.8%
distribute-lft-in78.8%
metadata-eval78.8%
neg-mul-178.8%
Simplified78.8%
if -1.56e-291 < x < 8.79999999999999975e33Initial program 46.5%
Simplified46.5%
Taylor expanded in x around 0 29.5%
Taylor expanded in eps around inf 82.3%
neg-mul-182.3%
distribute-rgt-neg-in82.3%
Simplified82.3%
Taylor expanded in eps around inf 82.5%
if 8.79999999999999975e33 < x < 2.9e88Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 17.4%
Taylor expanded in x around 0 73.9%
if 2.9e88 < x < 1.75e227Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 39.3%
Taylor expanded in eps around inf 39.5%
neg-mul-139.5%
distribute-rgt-neg-in39.5%
Simplified39.5%
if 1.75e227 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 16.3%
Taylor expanded in x around 0 72.3%
associate--r-3.1%
flip-+2.2%
associate--l+2.2%
associate--l+71.4%
metadata-eval71.4%
*-un-lft-identity71.4%
cancel-sign-sub-inv71.4%
metadata-eval71.4%
add-sqr-sqrt38.1%
sqrt-unprod71.4%
sqr-neg71.4%
sqrt-unprod38.1%
add-sqr-sqrt76.2%
div-inv76.2%
metadata-eval76.2%
frac-2neg76.2%
Applied egg-rr76.6%
Final simplification75.8%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (- (/ 1.0 eps) (/ 1.0 eps))))
(t_1 (/ (+ 1.0 (exp (* eps x))) 2.0)))
(if (<= x -21500.0)
(/ (/ (expm1 (- x)) eps) 2.0)
(if (<= x 1.3e+33)
t_1
(if (<= x 7.5e+88)
(/ (+ (+ 1.0 (/ 1.0 eps)) (- 1.0 (/ 1.0 eps))) 2.0)
(if (<= x 1.3e+224)
t_1
(/
(/
(+ -1.0 (* t_0 t_0))
(+ (/ 1.0 eps) (+ 1.0 (+ -1.0 (/ 1.0 eps)))))
2.0)))))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps));
double t_1 = (1.0 + exp((eps * x))) / 2.0;
double tmp;
if (x <= -21500.0) {
tmp = (expm1(-x) / eps) / 2.0;
} else if (x <= 1.3e+33) {
tmp = t_1;
} else if (x <= 7.5e+88) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else if (x <= 1.3e+224) {
tmp = t_1;
} else {
tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-1.0 + (1.0 / eps))))) / 2.0;
}
return tmp;
}
eps = Math.abs(eps);
public static double code(double x, double eps) {
double t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps));
double t_1 = (1.0 + Math.exp((eps * x))) / 2.0;
double tmp;
if (x <= -21500.0) {
tmp = (Math.expm1(-x) / eps) / 2.0;
} else if (x <= 1.3e+33) {
tmp = t_1;
} else if (x <= 7.5e+88) {
tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0;
} else if (x <= 1.3e+224) {
tmp = t_1;
} else {
tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-1.0 + (1.0 / eps))))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps)) t_1 = (1.0 + math.exp((eps * x))) / 2.0 tmp = 0 if x <= -21500.0: tmp = (math.expm1(-x) / eps) / 2.0 elif x <= 1.3e+33: tmp = t_1 elif x <= 7.5e+88: tmp = ((1.0 + (1.0 / eps)) + (1.0 - (1.0 / eps))) / 2.0 elif x <= 1.3e+224: tmp = t_1 else: tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-1.0 + (1.0 / eps))))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) t_0 = Float64(1.0 + Float64(Float64(1.0 / eps) - Float64(1.0 / eps))) t_1 = Float64(Float64(1.0 + exp(Float64(eps * x))) / 2.0) tmp = 0.0 if (x <= -21500.0) tmp = Float64(Float64(expm1(Float64(-x)) / eps) / 2.0); elseif (x <= 1.3e+33) tmp = t_1; elseif (x <= 7.5e+88) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) + Float64(1.0 - Float64(1.0 / eps))) / 2.0); elseif (x <= 1.3e+224) tmp = t_1; else tmp = Float64(Float64(Float64(-1.0 + Float64(t_0 * t_0)) / Float64(Float64(1.0 / eps) + Float64(1.0 + 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_] := Block[{t$95$0 = N[(1.0 + N[(N[(1.0 / eps), $MachinePrecision] - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 + N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[x, -21500.0], N[(N[(N[(Exp[(-x)] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.3e+33], t$95$1, If[LessEqual[x, 7.5e+88], N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.3e+224], t$95$1, N[(N[(N[(-1.0 + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / eps), $MachinePrecision] + N[(1.0 + N[(-1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := 1 + \left(\frac{1}{\varepsilon} - \frac{1}{\varepsilon}\right)\\
t_1 := \frac{1 + e^{\varepsilon \cdot x}}{2}\\
\mathbf{if}\;x \leq -21500:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(-x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+33}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+88}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+224}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1 + t_0 \cdot t_0}{\frac{1}{\varepsilon} + \left(1 + \left(-1 + \frac{1}{\varepsilon}\right)\right)}}{2}\\
\end{array}
\end{array}
if x < -21500Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 37.7%
Taylor expanded in eps around 0 64.3%
expm1-def64.3%
neg-mul-164.3%
Simplified64.3%
if -21500 < x < 1.2999999999999999e33 or 7.50000000000000031e88 < x < 1.3e224Initial program 56.6%
Simplified56.6%
Taylor expanded in x around 0 34.6%
Taylor expanded in eps around inf 75.9%
neg-mul-175.9%
distribute-rgt-neg-in75.9%
Simplified75.9%
Taylor expanded in eps around inf 76.3%
if 1.2999999999999999e33 < x < 7.50000000000000031e88Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 17.4%
Taylor expanded in x around 0 73.9%
if 1.3e224 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 16.3%
Taylor expanded in x around 0 72.3%
associate--r-3.1%
flip-+2.2%
associate--l+2.2%
associate--l+71.4%
metadata-eval71.4%
*-un-lft-identity71.4%
cancel-sign-sub-inv71.4%
metadata-eval71.4%
add-sqr-sqrt38.1%
sqrt-unprod71.4%
sqr-neg71.4%
sqrt-unprod38.1%
add-sqr-sqrt76.2%
div-inv76.2%
metadata-eval76.2%
frac-2neg76.2%
Applied egg-rr76.6%
Final simplification74.8%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (- (/ 1.0 eps) (/ 1.0 eps)))))
(if (<= x -21500.0)
(/ (/ (expm1 (- x)) eps) 2.0)
(if (<= x 750.0)
1.0
(/
(/ (+ -1.0 (* t_0 t_0)) (+ (/ 1.0 eps) (+ 1.0 (+ -1.0 (/ 1.0 eps)))))
2.0)))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps));
double tmp;
if (x <= -21500.0) {
tmp = (expm1(-x) / eps) / 2.0;
} else if (x <= 750.0) {
tmp = 1.0;
} else {
tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-1.0 + (1.0 / eps))))) / 2.0;
}
return tmp;
}
eps = Math.abs(eps);
public static double code(double x, double eps) {
double t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps));
double tmp;
if (x <= -21500.0) {
tmp = (Math.expm1(-x) / eps) / 2.0;
} else if (x <= 750.0) {
tmp = 1.0;
} else {
tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-1.0 + (1.0 / eps))))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps)) tmp = 0 if x <= -21500.0: tmp = (math.expm1(-x) / eps) / 2.0 elif x <= 750.0: tmp = 1.0 else: tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + (-1.0 + (1.0 / eps))))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) t_0 = Float64(1.0 + Float64(Float64(1.0 / eps) - Float64(1.0 / eps))) tmp = 0.0 if (x <= -21500.0) tmp = Float64(Float64(expm1(Float64(-x)) / eps) / 2.0); elseif (x <= 750.0) tmp = 1.0; else tmp = Float64(Float64(Float64(-1.0 + Float64(t_0 * t_0)) / Float64(Float64(1.0 / eps) + Float64(1.0 + 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_] := Block[{t$95$0 = N[(1.0 + N[(N[(1.0 / eps), $MachinePrecision] - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -21500.0], N[(N[(N[(Exp[(-x)] - 1), $MachinePrecision] / eps), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 750.0], 1.0, N[(N[(N[(-1.0 + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / eps), $MachinePrecision] + N[(1.0 + N[(-1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := 1 + \left(\frac{1}{\varepsilon} - \frac{1}{\varepsilon}\right)\\
\mathbf{if}\;x \leq -21500:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(-x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 750:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1 + t_0 \cdot t_0}{\frac{1}{\varepsilon} + \left(1 + \left(-1 + \frac{1}{\varepsilon}\right)\right)}}{2}\\
\end{array}
\end{array}
if x < -21500Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 37.7%
Taylor expanded in eps around 0 64.3%
expm1-def64.3%
neg-mul-164.3%
Simplified64.3%
if -21500 < x < 750Initial program 49.0%
Simplified49.0%
Taylor expanded in x around 0 74.1%
if 750 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 23.6%
Taylor expanded in x around 0 55.5%
associate--r-3.1%
flip-+1.7%
associate--l+1.7%
associate--l+54.1%
metadata-eval54.1%
*-un-lft-identity54.1%
cancel-sign-sub-inv54.1%
metadata-eval54.1%
add-sqr-sqrt27.0%
sqrt-unprod55.5%
sqr-neg55.5%
sqrt-unprod29.8%
add-sqr-sqrt56.8%
div-inv56.8%
metadata-eval56.8%
frac-2neg56.8%
Applied egg-rr57.4%
Final simplification68.2%
NOTE: eps should be positive before calling this function
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (- (/ 1.0 eps) (/ 1.0 eps)))) (t_1 (+ -1.0 (/ 1.0 eps))))
(if (<= x 120.0)
(/ (- 2.0 (* x (+ (/ 1.0 eps) (* t_1 (- -1.0 eps))))) 2.0)
(/ (/ (+ -1.0 (* t_0 t_0)) (+ (/ 1.0 eps) (+ 1.0 t_1))) 2.0))))eps = abs(eps);
double code(double x, double eps) {
double t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps));
double t_1 = -1.0 + (1.0 / eps);
double tmp;
if (x <= 120.0) {
tmp = (2.0 - (x * ((1.0 / eps) + (t_1 * (-1.0 - eps))))) / 2.0;
} else {
tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + t_1))) / 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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 + ((1.0d0 / eps) - (1.0d0 / eps))
t_1 = (-1.0d0) + (1.0d0 / eps)
if (x <= 120.0d0) then
tmp = (2.0d0 - (x * ((1.0d0 / eps) + (t_1 * ((-1.0d0) - eps))))) / 2.0d0
else
tmp = (((-1.0d0) + (t_0 * t_0)) / ((1.0d0 / eps) + (1.0d0 + t_1))) / 2.0d0
end if
code = tmp
end function
eps = Math.abs(eps);
public static double code(double x, double eps) {
double t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps));
double t_1 = -1.0 + (1.0 / eps);
double tmp;
if (x <= 120.0) {
tmp = (2.0 - (x * ((1.0 / eps) + (t_1 * (-1.0 - eps))))) / 2.0;
} else {
tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + t_1))) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps)) t_1 = -1.0 + (1.0 / eps) tmp = 0 if x <= 120.0: tmp = (2.0 - (x * ((1.0 / eps) + (t_1 * (-1.0 - eps))))) / 2.0 else: tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + t_1))) / 2.0 return tmp
eps = abs(eps) function code(x, eps) t_0 = Float64(1.0 + Float64(Float64(1.0 / eps) - Float64(1.0 / eps))) t_1 = Float64(-1.0 + Float64(1.0 / eps)) tmp = 0.0 if (x <= 120.0) tmp = Float64(Float64(2.0 - Float64(x * Float64(Float64(1.0 / eps) + Float64(t_1 * Float64(-1.0 - eps))))) / 2.0); else tmp = Float64(Float64(Float64(-1.0 + Float64(t_0 * t_0)) / Float64(Float64(1.0 / eps) + Float64(1.0 + t_1))) / 2.0); end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) t_0 = 1.0 + ((1.0 / eps) - (1.0 / eps)); t_1 = -1.0 + (1.0 / eps); tmp = 0.0; if (x <= 120.0) tmp = (2.0 - (x * ((1.0 / eps) + (t_1 * (-1.0 - eps))))) / 2.0; else tmp = ((-1.0 + (t_0 * t_0)) / ((1.0 / eps) + (1.0 + t_1))) / 2.0; end tmp_2 = tmp; end
NOTE: eps should be positive before calling this function
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[(N[(1.0 / eps), $MachinePrecision] - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 120.0], N[(N[(2.0 - N[(x * N[(N[(1.0 / eps), $MachinePrecision] + N[(t$95$1 * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(-1.0 + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 / eps), $MachinePrecision] + N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
t_0 := 1 + \left(\frac{1}{\varepsilon} - \frac{1}{\varepsilon}\right)\\
t_1 := -1 + \frac{1}{\varepsilon}\\
\mathbf{if}\;x \leq 120:\\
\;\;\;\;\frac{2 - x \cdot \left(\frac{1}{\varepsilon} + t_1 \cdot \left(-1 - \varepsilon\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1 + t_0 \cdot t_0}{\frac{1}{\varepsilon} + \left(1 + t_1\right)}}{2}\\
\end{array}
\end{array}
if x < 120Initial program 56.4%
Simplified49.3%
Taylor expanded in x around 0 63.9%
Taylor expanded in eps around 0 67.6%
if 120 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 24.3%
Taylor expanded in x around 0 54.1%
associate--r-3.1%
flip-+1.7%
associate--l+1.7%
associate--l+52.7%
metadata-eval52.7%
*-un-lft-identity52.7%
cancel-sign-sub-inv52.7%
metadata-eval52.7%
add-sqr-sqrt26.3%
sqrt-unprod54.0%
sqr-neg54.0%
sqrt-unprod29.0%
add-sqr-sqrt55.3%
div-inv55.3%
metadata-eval55.3%
frac-2neg55.3%
Applied egg-rr56.0%
Final simplification64.1%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 106.0) (/ (- 2.0 (* x (+ (/ 1.0 eps) (* (+ -1.0 (/ 1.0 eps)) (- -1.0 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 <= 106.0) {
tmp = (2.0 - (x * ((1.0 / eps) + ((-1.0 + (1.0 / eps)) * (-1.0 - eps))))) / 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 <= 106.0d0) then
tmp = (2.0d0 - (x * ((1.0d0 / eps) + (((-1.0d0) + (1.0d0 / eps)) * ((-1.0d0) - eps))))) / 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 <= 106.0) {
tmp = (2.0 - (x * ((1.0 / eps) + ((-1.0 + (1.0 / eps)) * (-1.0 - 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 <= 106.0: tmp = (2.0 - (x * ((1.0 / eps) + ((-1.0 + (1.0 / eps)) * (-1.0 - 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 <= 106.0) tmp = Float64(Float64(2.0 - Float64(x * Float64(Float64(1.0 / eps) + Float64(Float64(-1.0 + Float64(1.0 / eps)) * Float64(-1.0 - 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
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 106.0) tmp = (2.0 - (x * ((1.0 / eps) + ((-1.0 + (1.0 / eps)) * (-1.0 - eps))))) / 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, 106.0], N[(N[(2.0 - N[(x * N[(N[(1.0 / eps), $MachinePrecision] + N[(N[(-1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]), $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 106:\\
\;\;\;\;\frac{2 - x \cdot \left(\frac{1}{\varepsilon} + \left(-1 + \frac{1}{\varepsilon}\right) \cdot \left(-1 - \varepsilon\right)\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < 106Initial program 56.4%
Simplified49.3%
Taylor expanded in x around 0 63.9%
Taylor expanded in eps around 0 67.6%
if 106 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 24.3%
Taylor expanded in x around 0 54.1%
Final simplification63.6%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x 2.0) (/ (+ 2.0 (* x (- -1.0 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 <= 2.0) {
tmp = (2.0 + (x * (-1.0 - eps))) / 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 <= 2.0d0) then
tmp = (2.0d0 + (x * ((-1.0d0) - eps))) / 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 <= 2.0) {
tmp = (2.0 + (x * (-1.0 - 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 <= 2.0: tmp = (2.0 + (x * (-1.0 - 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 <= 2.0) tmp = Float64(Float64(2.0 + Float64(x * Float64(-1.0 - 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
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 2.0) tmp = (2.0 + (x * (-1.0 - eps))) / 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, 2.0], N[(N[(2.0 + N[(x * N[(-1.0 - eps), $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 2:\\
\;\;\;\;\frac{2 + x \cdot \left(-1 - \varepsilon\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) + \left(1 - \frac{1}{\varepsilon}\right)}{2}\\
\end{array}
\end{array}
if x < 2Initial program 56.4%
Simplified56.4%
Taylor expanded in x around 0 42.4%
Taylor expanded in eps around inf 84.4%
sub-neg84.4%
mul-1-neg84.4%
remove-double-neg84.4%
mul-1-neg84.4%
distribute-rgt-neg-in84.4%
mul-1-neg84.4%
distribute-lft-in84.4%
metadata-eval84.4%
neg-mul-184.4%
Simplified84.4%
Taylor expanded in x around 0 67.2%
if 2 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in x around 0 24.3%
Taylor expanded in x around 0 54.1%
Final simplification63.3%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -5e-288) (/ (- 2.0 (* x (+ eps 2.0))) 2.0) (/ (+ 2.0 (* eps x)) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -5e-288) {
tmp = (2.0 - (x * (eps + 2.0))) / 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 <= (-5d-288)) then
tmp = (2.0d0 - (x * (eps + 2.0d0))) / 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 <= -5e-288) {
tmp = (2.0 - (x * (eps + 2.0))) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -5e-288: tmp = (2.0 - (x * (eps + 2.0))) / 2.0 else: tmp = (2.0 + (eps * x)) / 2.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -5e-288) tmp = Float64(Float64(2.0 - Float64(x * Float64(eps + 2.0))) / 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 <= -5e-288) tmp = (2.0 - (x * (eps + 2.0))) / 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, -5e-288], N[(N[(2.0 - N[(x * N[(eps + 2.0), $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 -5 \cdot 10^{-288}:\\
\;\;\;\;\frac{2 - x \cdot \left(\varepsilon + 2\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\end{array}
\end{array}
if x < -5.00000000000000011e-288Initial program 69.5%
Simplified69.5%
Taylor expanded in x around 0 39.7%
Taylor expanded in x around 0 33.7%
mul-1-neg33.7%
unsub-neg33.7%
*-commutative33.7%
associate-*r*33.7%
Simplified33.7%
+-commutative33.7%
distribute-rgt-in29.2%
Applied egg-rr38.8%
Taylor expanded in eps around inf 57.1%
distribute-rgt-out57.1%
Simplified57.1%
if -5.00000000000000011e-288 < x Initial program 69.3%
Simplified69.3%
Taylor expanded in x around 0 27.4%
Taylor expanded in eps around inf 57.9%
neg-mul-157.9%
distribute-rgt-neg-in57.9%
Simplified57.9%
Taylor expanded in eps around inf 57.9%
Taylor expanded in eps around 0 48.4%
Final simplification51.4%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -5e-288) (/ (+ 2.0 (* x (- -1.0 eps))) 2.0) (/ (+ 2.0 (* eps x)) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -5e-288) {
tmp = (2.0 + (x * (-1.0 - 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 <= (-5d-288)) then
tmp = (2.0d0 + (x * ((-1.0d0) - 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 <= -5e-288) {
tmp = (2.0 + (x * (-1.0 - eps))) / 2.0;
} else {
tmp = (2.0 + (eps * x)) / 2.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -5e-288: tmp = (2.0 + (x * (-1.0 - 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 <= -5e-288) tmp = Float64(Float64(2.0 + Float64(x * Float64(-1.0 - 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 <= -5e-288) tmp = (2.0 + (x * (-1.0 - 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, -5e-288], N[(N[(2.0 + N[(x * N[(-1.0 - 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 -5 \cdot 10^{-288}:\\
\;\;\;\;\frac{2 + x \cdot \left(-1 - \varepsilon\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\end{array}
\end{array}
if x < -5.00000000000000011e-288Initial program 69.5%
Simplified69.5%
Taylor expanded in x around 0 50.6%
Taylor expanded in eps around inf 78.8%
sub-neg78.8%
mul-1-neg78.8%
remove-double-neg78.8%
mul-1-neg78.8%
distribute-rgt-neg-in78.8%
mul-1-neg78.8%
distribute-lft-in78.8%
metadata-eval78.8%
neg-mul-178.8%
Simplified78.8%
Taylor expanded in x around 0 57.2%
if -5.00000000000000011e-288 < x Initial program 69.3%
Simplified69.3%
Taylor expanded in x around 0 27.4%
Taylor expanded in eps around inf 57.9%
neg-mul-157.9%
distribute-rgt-neg-in57.9%
Simplified57.9%
Taylor expanded in eps around inf 57.9%
Taylor expanded in eps around 0 48.4%
Final simplification51.4%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -1.0) (/ (* eps (- x)) 2.0) (/ (+ 2.0 (* eps x)) 2.0)))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -1.0) {
tmp = (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 <= (-1.0d0)) then
tmp = (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 <= -1.0) {
tmp = (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 <= -1.0: tmp = (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 <= -1.0) tmp = Float64(Float64(eps * Float64(-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 <= -1.0) tmp = (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, -1.0], N[(N[(eps * (-x)), $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{\varepsilon \cdot \left(-x\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \varepsilon \cdot x}{2}\\
\end{array}
\end{array}
if x < -1Initial program 96.6%
Simplified96.6%
Taylor expanded in x around 0 63.1%
Taylor expanded in eps around inf 63.1%
sub-neg63.1%
mul-1-neg63.1%
remove-double-neg63.1%
mul-1-neg63.1%
distribute-rgt-neg-in63.1%
mul-1-neg63.1%
distribute-lft-in63.1%
metadata-eval63.1%
neg-mul-163.1%
Simplified63.1%
Taylor expanded in x around 0 30.5%
Taylor expanded in eps around inf 30.6%
neg-mul-130.6%
distribute-rgt-neg-in30.6%
Simplified30.6%
if -1 < x Initial program 65.9%
Simplified65.9%
Taylor expanded in x around 0 30.6%
Taylor expanded in eps around inf 64.2%
neg-mul-164.2%
distribute-rgt-neg-in64.2%
Simplified64.2%
Taylor expanded in eps around inf 64.4%
Taylor expanded in eps around 0 54.3%
Final simplification51.6%
NOTE: eps should be positive before calling this function (FPCore (x eps) :precision binary64 (if (<= x -1.0) (/ (* eps (- x)) 2.0) 1.0))
eps = abs(eps);
double code(double x, double eps) {
double tmp;
if (x <= -1.0) {
tmp = (eps * -x) / 2.0;
} else {
tmp = 1.0;
}
return tmp;
}
NOTE: eps should be positive before calling this function
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = (eps * -x) / 2.0d0
else
tmp = 1.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 = (eps * -x) / 2.0;
} else {
tmp = 1.0;
}
return tmp;
}
eps = abs(eps) def code(x, eps): tmp = 0 if x <= -1.0: tmp = (eps * -x) / 2.0 else: tmp = 1.0 return tmp
eps = abs(eps) function code(x, eps) tmp = 0.0 if (x <= -1.0) tmp = Float64(Float64(eps * Float64(-x)) / 2.0); else tmp = 1.0; end return tmp end
eps = abs(eps) function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -1.0) tmp = (eps * -x) / 2.0; else tmp = 1.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[(eps * (-x)), $MachinePrecision] / 2.0), $MachinePrecision], 1.0]
\begin{array}{l}
eps = |eps|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{\varepsilon \cdot \left(-x\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1Initial program 96.6%
Simplified96.6%
Taylor expanded in x around 0 63.1%
Taylor expanded in eps around inf 63.1%
sub-neg63.1%
mul-1-neg63.1%
remove-double-neg63.1%
mul-1-neg63.1%
distribute-rgt-neg-in63.1%
mul-1-neg63.1%
distribute-lft-in63.1%
metadata-eval63.1%
neg-mul-163.1%
Simplified63.1%
Taylor expanded in x around 0 30.5%
Taylor expanded in eps around inf 30.6%
neg-mul-130.6%
distribute-rgt-neg-in30.6%
Simplified30.6%
if -1 < x Initial program 65.9%
Simplified65.9%
Taylor expanded in x around 0 51.3%
Final simplification49.0%
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 69.3%
Simplified69.3%
Taylor expanded in x around 0 45.8%
Final simplification45.8%
herbie shell --seed 2023309
(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))