
(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 17 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}
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* (+ x 1.0) (exp (- x)))))
(if (<= eps_m 9.5e-5)
(/ (+ t_0 t_0) 2.0)
(/ (+ (exp (* x (- -1.0 eps_m))) (exp (* x eps_m))) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (x + 1.0) * exp(-x);
double tmp;
if (eps_m <= 9.5e-5) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (exp((x * (-1.0 - eps_m))) + exp((x * eps_m))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = (x + 1.0d0) * exp(-x)
if (eps_m <= 9.5d-5) then
tmp = (t_0 + t_0) / 2.0d0
else
tmp = (exp((x * ((-1.0d0) - eps_m))) + exp((x * eps_m))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = (x + 1.0) * Math.exp(-x);
double tmp;
if (eps_m <= 9.5e-5) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (Math.exp((x * (-1.0 - eps_m))) + Math.exp((x * eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = (x + 1.0) * math.exp(-x) tmp = 0 if eps_m <= 9.5e-5: tmp = (t_0 + t_0) / 2.0 else: tmp = (math.exp((x * (-1.0 - eps_m))) + math.exp((x * eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(x + 1.0) * exp(Float64(-x))) tmp = 0.0 if (eps_m <= 9.5e-5) tmp = Float64(Float64(t_0 + t_0) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 - eps_m))) + exp(Float64(x * eps_m))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = (x + 1.0) * exp(-x); tmp = 0.0; if (eps_m <= 9.5e-5) tmp = (t_0 + t_0) / 2.0; else tmp = (exp((x * (-1.0 - eps_m))) + exp((x * eps_m))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps$95$m, 9.5e-5], N[(N[(t$95$0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \left(x + 1\right) \cdot e^{-x}\\
\mathbf{if}\;eps_m \leq 9.5 \cdot 10^{-5}:\\
\;\;\;\;\frac{t_0 + t_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 - eps_m\right)} + e^{x \cdot eps_m}}{2}\\
\end{array}
\end{array}
if eps < 9.5000000000000005e-5Initial program 60.1%
fma-neg60.1%
/-rgt-identity60.1%
fma-neg60.1%
/-rgt-identity60.1%
distribute-rgt-neg-in60.1%
sub-neg60.1%
metadata-eval60.1%
distribute-rgt-neg-in60.1%
Simplified60.1%
Taylor expanded in eps around 0 75.0%
Simplified75.1%
if 9.5000000000000005e-5 < eps Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
neg-mul-1100.0%
distribute-lft-neg-in100.0%
*-commutative100.0%
Simplified100.0%
Final simplification82.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (* x (- eps_m)))))
(if (<= x 6e+54)
(/ (+ (exp (* x eps_m)) t_0) 2.0)
(if (<= x 9.5e+127)
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (- (/ -1.0 eps_m) -1.0)) 2.0)
(/ (+ (exp (* x (+ -1.0 eps_m))) t_0) 2.0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp((x * -eps_m));
double tmp;
if (x <= 6e+54) {
tmp = (exp((x * eps_m)) + t_0) / 2.0;
} else if (x <= 9.5e+127) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps_m))) + t_0) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = exp((x * -eps_m))
if (x <= 6d+54) then
tmp = (exp((x * eps_m)) + t_0) / 2.0d0
else if (x <= 9.5d+127) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (((-1.0d0) / eps_m) - (-1.0d0))) / 2.0d0
else
tmp = (exp((x * ((-1.0d0) + eps_m))) + t_0) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = Math.exp((x * -eps_m));
double tmp;
if (x <= 6e+54) {
tmp = (Math.exp((x * eps_m)) + t_0) / 2.0;
} else if (x <= 9.5e+127) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (Math.exp((x * (-1.0 + eps_m))) + t_0) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp((x * -eps_m)) tmp = 0 if x <= 6e+54: tmp = (math.exp((x * eps_m)) + t_0) / 2.0 elif x <= 9.5e+127: tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0 else: tmp = (math.exp((x * (-1.0 + eps_m))) + t_0) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(x * Float64(-eps_m))) tmp = 0.0 if (x <= 6e+54) tmp = Float64(Float64(exp(Float64(x * eps_m)) + t_0) / 2.0); elseif (x <= 9.5e+127) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(Float64(-1.0 / eps_m) - -1.0)) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) + t_0) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp((x * -eps_m)); tmp = 0.0; if (x <= 6e+54) tmp = (exp((x * eps_m)) + t_0) / 2.0; elseif (x <= 9.5e+127) tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0; else tmp = (exp((x * (-1.0 + eps_m))) + t_0) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 6e+54], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 9.5e+127], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(-eps_m\right)}\\
\mathbf{if}\;x \leq 6 \cdot 10^{+54}:\\
\;\;\;\;\frac{e^{x \cdot eps_m} + t_0}{2}\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+127}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps_m\right)} + t_0}{2}\\
\end{array}
\end{array}
if x < 5.9999999999999998e54Initial program 63.3%
fma-neg63.3%
/-rgt-identity63.3%
fma-neg63.3%
/-rgt-identity63.3%
distribute-rgt-neg-in63.3%
sub-neg63.3%
metadata-eval63.3%
distribute-rgt-neg-in63.3%
Simplified63.3%
Taylor expanded in eps around inf 98.0%
Taylor expanded in eps around inf 96.1%
*-commutative96.1%
Simplified96.1%
Taylor expanded in x around inf 96.1%
associate-*r*96.1%
neg-mul-196.1%
*-commutative96.1%
mul-1-neg96.1%
mul-1-neg96.1%
distribute-rgt-neg-in96.1%
Simplified96.1%
Taylor expanded in eps around inf 96.5%
if 5.9999999999999998e54 < x < 9.49999999999999975e127Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 11.7%
Taylor expanded in x around 0 76.9%
if 9.49999999999999975e127 < x Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 68.4%
*-commutative68.4%
Simplified68.4%
Taylor expanded in x around inf 68.4%
associate-*r*68.4%
neg-mul-168.4%
*-commutative68.4%
mul-1-neg68.4%
mul-1-neg68.4%
distribute-rgt-neg-in68.4%
Simplified68.4%
Final simplification90.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* (+ x 1.0) (exp (- x)))))
(if (<= eps_m 4e-20)
(/ (+ t_0 t_0) 2.0)
(/ (+ (exp (* x (+ -1.0 eps_m))) (exp (* x (- eps_m)))) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (x + 1.0) * exp(-x);
double tmp;
if (eps_m <= 4e-20) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps_m))) + exp((x * -eps_m))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = (x + 1.0d0) * exp(-x)
if (eps_m <= 4d-20) then
tmp = (t_0 + t_0) / 2.0d0
else
tmp = (exp((x * ((-1.0d0) + eps_m))) + exp((x * -eps_m))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = (x + 1.0) * Math.exp(-x);
double tmp;
if (eps_m <= 4e-20) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (Math.exp((x * (-1.0 + eps_m))) + Math.exp((x * -eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = (x + 1.0) * math.exp(-x) tmp = 0 if eps_m <= 4e-20: tmp = (t_0 + t_0) / 2.0 else: tmp = (math.exp((x * (-1.0 + eps_m))) + math.exp((x * -eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(x + 1.0) * exp(Float64(-x))) tmp = 0.0 if (eps_m <= 4e-20) tmp = Float64(Float64(t_0 + t_0) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) + exp(Float64(x * Float64(-eps_m)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = (x + 1.0) * exp(-x); tmp = 0.0; if (eps_m <= 4e-20) tmp = (t_0 + t_0) / 2.0; else tmp = (exp((x * (-1.0 + eps_m))) + exp((x * -eps_m))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps$95$m, 4e-20], N[(N[(t$95$0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \left(x + 1\right) \cdot e^{-x}\\
\mathbf{if}\;eps_m \leq 4 \cdot 10^{-20}:\\
\;\;\;\;\frac{t_0 + t_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps_m\right)} + e^{x \cdot \left(-eps_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 3.99999999999999978e-20Initial program 60.0%
fma-neg59.9%
/-rgt-identity59.9%
fma-neg60.0%
/-rgt-identity60.0%
distribute-rgt-neg-in60.0%
sub-neg60.0%
metadata-eval60.0%
distribute-rgt-neg-in60.0%
Simplified60.0%
Taylor expanded in eps around 0 74.6%
Simplified74.6%
if 3.99999999999999978e-20 < eps Initial program 98.7%
fma-neg98.7%
/-rgt-identity98.7%
fma-neg98.7%
/-rgt-identity98.7%
distribute-rgt-neg-in98.7%
sub-neg98.7%
metadata-eval98.7%
distribute-rgt-neg-in98.7%
Simplified98.7%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
*-commutative100.0%
mul-1-neg100.0%
mul-1-neg100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Final simplification82.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 5e-21) (/ (+ (* (+ x 1.0) (exp (- x))) (/ (+ x 1.0) (exp x))) 2.0) (/ (+ (exp (* x (+ -1.0 eps_m))) (exp (* x (- eps_m)))) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 5e-21) {
tmp = (((x + 1.0) * exp(-x)) + ((x + 1.0) / exp(x))) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps_m))) + exp((x * -eps_m))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 5d-21) then
tmp = (((x + 1.0d0) * exp(-x)) + ((x + 1.0d0) / exp(x))) / 2.0d0
else
tmp = (exp((x * ((-1.0d0) + eps_m))) + exp((x * -eps_m))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 5e-21) {
tmp = (((x + 1.0) * Math.exp(-x)) + ((x + 1.0) / Math.exp(x))) / 2.0;
} else {
tmp = (Math.exp((x * (-1.0 + eps_m))) + Math.exp((x * -eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 5e-21: tmp = (((x + 1.0) * math.exp(-x)) + ((x + 1.0) / math.exp(x))) / 2.0 else: tmp = (math.exp((x * (-1.0 + eps_m))) + math.exp((x * -eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 5e-21) tmp = Float64(Float64(Float64(Float64(x + 1.0) * exp(Float64(-x))) + Float64(Float64(x + 1.0) / exp(x))) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) + exp(Float64(x * Float64(-eps_m)))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 5e-21) tmp = (((x + 1.0) * exp(-x)) + ((x + 1.0) / exp(x))) / 2.0; else tmp = (exp((x * (-1.0 + eps_m))) + exp((x * -eps_m))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 5e-21], 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[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps_m \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\left(x + 1\right) \cdot e^{-x} + \frac{x + 1}{e^{x}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps_m\right)} + e^{x \cdot \left(-eps_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 4.99999999999999973e-21Initial program 60.0%
fma-neg59.9%
/-rgt-identity59.9%
fma-neg60.0%
/-rgt-identity60.0%
distribute-rgt-neg-in60.0%
sub-neg60.0%
metadata-eval60.0%
distribute-rgt-neg-in60.0%
Simplified60.0%
Taylor expanded in eps around 0 74.6%
Simplified74.6%
exp-neg74.6%
un-div-inv74.6%
Applied egg-rr74.6%
if 4.99999999999999973e-21 < eps Initial program 98.7%
fma-neg98.7%
/-rgt-identity98.7%
fma-neg98.7%
/-rgt-identity98.7%
distribute-rgt-neg-in98.7%
sub-neg98.7%
metadata-eval98.7%
distribute-rgt-neg-in98.7%
Simplified98.7%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
*-commutative100.0%
mul-1-neg100.0%
mul-1-neg100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Final simplification82.2%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 2.7e+51)
(/ (+ (exp (* x eps_m)) (exp (* x (- eps_m)))) 2.0)
(if (or (<= x 1.7e+268) (not (<= x 1.16e+297)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (- (/ -1.0 eps_m) -1.0)) 2.0)
(/ (- (exp (* x (+ -1.0 eps_m))) -1.0) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 2.7e+51) {
tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0;
} else if ((x <= 1.7e+268) || !(x <= 1.16e+297)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (exp((x * (-1.0 + eps_m))) - -1.0) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 2.7d+51) then
tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0d0
else if ((x <= 1.7d+268) .or. (.not. (x <= 1.16d+297))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (((-1.0d0) / eps_m) - (-1.0d0))) / 2.0d0
else
tmp = (exp((x * ((-1.0d0) + eps_m))) - (-1.0d0)) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 2.7e+51) {
tmp = (Math.exp((x * eps_m)) + Math.exp((x * -eps_m))) / 2.0;
} else if ((x <= 1.7e+268) || !(x <= 1.16e+297)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (Math.exp((x * (-1.0 + eps_m))) - -1.0) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 2.7e+51: tmp = (math.exp((x * eps_m)) + math.exp((x * -eps_m))) / 2.0 elif (x <= 1.7e+268) or not (x <= 1.16e+297): tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0 else: tmp = (math.exp((x * (-1.0 + eps_m))) - -1.0) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 2.7e+51) tmp = Float64(Float64(exp(Float64(x * eps_m)) + exp(Float64(x * Float64(-eps_m)))) / 2.0); elseif ((x <= 1.7e+268) || !(x <= 1.16e+297)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(Float64(-1.0 / eps_m) - -1.0)) / 2.0); else tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) - -1.0) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 2.7e+51) tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0; elseif ((x <= 1.7e+268) || ~((x <= 1.16e+297))) tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0; else tmp = (exp((x * (-1.0 + eps_m))) - -1.0) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 2.7e+51], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 1.7e+268], N[Not[LessEqual[x, 1.16e+297]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.7 \cdot 10^{+51}:\\
\;\;\;\;\frac{e^{x \cdot eps_m} + e^{x \cdot \left(-eps_m\right)}}{2}\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{+268} \lor \neg \left(x \leq 1.16 \cdot 10^{+297}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps_m\right)} - -1}{2}\\
\end{array}
\end{array}
if x < 2.69999999999999992e51Initial program 63.3%
fma-neg63.3%
/-rgt-identity63.3%
fma-neg63.3%
/-rgt-identity63.3%
distribute-rgt-neg-in63.3%
sub-neg63.3%
metadata-eval63.3%
distribute-rgt-neg-in63.3%
Simplified63.3%
Taylor expanded in eps around inf 98.0%
Taylor expanded in eps around inf 96.1%
*-commutative96.1%
Simplified96.1%
Taylor expanded in x around inf 96.1%
associate-*r*96.1%
neg-mul-196.1%
*-commutative96.1%
mul-1-neg96.1%
mul-1-neg96.1%
distribute-rgt-neg-in96.1%
Simplified96.1%
Taylor expanded in eps around inf 96.5%
if 2.69999999999999992e51 < x < 1.7000000000000001e268 or 1.16000000000000001e297 < x Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 19.6%
Taylor expanded in x around 0 71.5%
if 1.7000000000000001e268 < x < 1.16000000000000001e297Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
*-commutative100.0%
mul-1-neg100.0%
mul-1-neg100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in eps around 0 86.2%
Final simplification91.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (/ (+ (exp (* x (- -1.0 eps_m))) (exp (* x (+ -1.0 eps_m)))) 2.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (exp((x * (-1.0 - eps_m))) + exp((x * (-1.0 + eps_m)))) / 2.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = (exp((x * ((-1.0d0) - eps_m))) + exp((x * ((-1.0d0) + eps_m)))) / 2.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return (Math.exp((x * (-1.0 - eps_m))) + Math.exp((x * (-1.0 + eps_m)))) / 2.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return (math.exp((x * (-1.0 - eps_m))) + math.exp((x * (-1.0 + eps_m)))) / 2.0
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(exp(Float64(x * Float64(-1.0 - eps_m))) + exp(Float64(x * Float64(-1.0 + eps_m)))) / 2.0) end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = (exp((x * (-1.0 - eps_m))) + exp((x * (-1.0 + eps_m)))) / 2.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\frac{e^{x \cdot \left(-1 - eps_m\right)} + e^{x \cdot \left(-1 + eps_m\right)}}{2}
\end{array}
Initial program 71.6%
fma-neg71.6%
/-rgt-identity71.6%
fma-neg71.6%
/-rgt-identity71.6%
distribute-rgt-neg-in71.6%
sub-neg71.6%
metadata-eval71.6%
distribute-rgt-neg-in71.6%
Simplified71.6%
Taylor expanded in eps around inf 98.5%
Final simplification98.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -1.05e-215)
(/ (+ 1.0 (exp (* x (- eps_m)))) 2.0)
(if (or (<= x 2.5e+54) (and (not (<= x 3.5e+267)) (<= x 7.3e+295)))
(/ (- (exp (* x (+ -1.0 eps_m))) -1.0) 2.0)
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (- (/ -1.0 eps_m) -1.0)) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.05e-215) {
tmp = (1.0 + exp((x * -eps_m))) / 2.0;
} else if ((x <= 2.5e+54) || (!(x <= 3.5e+267) && (x <= 7.3e+295))) {
tmp = (exp((x * (-1.0 + eps_m))) - -1.0) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-1.05d-215)) then
tmp = (1.0d0 + exp((x * -eps_m))) / 2.0d0
else if ((x <= 2.5d+54) .or. (.not. (x <= 3.5d+267)) .and. (x <= 7.3d+295)) then
tmp = (exp((x * ((-1.0d0) + eps_m))) - (-1.0d0)) / 2.0d0
else
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (((-1.0d0) / eps_m) - (-1.0d0))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -1.05e-215) {
tmp = (1.0 + Math.exp((x * -eps_m))) / 2.0;
} else if ((x <= 2.5e+54) || (!(x <= 3.5e+267) && (x <= 7.3e+295))) {
tmp = (Math.exp((x * (-1.0 + eps_m))) - -1.0) / 2.0;
} else {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1.05e-215: tmp = (1.0 + math.exp((x * -eps_m))) / 2.0 elif (x <= 2.5e+54) or (not (x <= 3.5e+267) and (x <= 7.3e+295)): tmp = (math.exp((x * (-1.0 + eps_m))) - -1.0) / 2.0 else: tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.05e-215) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps_m)))) / 2.0); elseif ((x <= 2.5e+54) || (!(x <= 3.5e+267) && (x <= 7.3e+295))) tmp = Float64(Float64(exp(Float64(x * Float64(-1.0 + eps_m))) - -1.0) / 2.0); else tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(Float64(-1.0 / eps_m) - -1.0)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -1.05e-215) tmp = (1.0 + exp((x * -eps_m))) / 2.0; elseif ((x <= 2.5e+54) || (~((x <= 3.5e+267)) && (x <= 7.3e+295))) tmp = (exp((x * (-1.0 + eps_m))) - -1.0) / 2.0; else tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.05e-215], N[(N[(1.0 + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 2.5e+54], And[N[Not[LessEqual[x, 3.5e+267]], $MachinePrecision], LessEqual[x, 7.3e+295]]], N[(N[(N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{-215}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-eps_m\right)}}{2}\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+54} \lor \neg \left(x \leq 3.5 \cdot 10^{+267}\right) \land x \leq 7.3 \cdot 10^{+295}:\\
\;\;\;\;\frac{e^{x \cdot \left(-1 + eps_m\right)} - -1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\end{array}
\end{array}
if x < -1.05e-215Initial program 65.9%
fma-neg66.0%
/-rgt-identity66.0%
fma-neg65.9%
/-rgt-identity65.9%
distribute-rgt-neg-in65.9%
sub-neg65.9%
metadata-eval65.9%
distribute-rgt-neg-in65.9%
Simplified65.9%
Taylor expanded in x around 0 38.6%
Taylor expanded in eps around inf 70.3%
Taylor expanded in eps around inf 71.3%
*-commutative97.6%
Simplified71.3%
if -1.05e-215 < x < 2.50000000000000003e54 or 3.4999999999999999e267 < x < 7.2999999999999996e295Initial program 63.5%
fma-neg63.4%
/-rgt-identity63.4%
fma-neg63.5%
/-rgt-identity63.5%
distribute-rgt-neg-in63.5%
sub-neg63.5%
metadata-eval63.5%
distribute-rgt-neg-in63.5%
Simplified63.5%
Taylor expanded in eps around inf 98.5%
Taylor expanded in eps around inf 95.1%
*-commutative95.1%
Simplified95.1%
Taylor expanded in x around inf 95.1%
associate-*r*95.1%
neg-mul-195.1%
*-commutative95.1%
mul-1-neg95.1%
mul-1-neg95.1%
distribute-rgt-neg-in95.1%
Simplified95.1%
Taylor expanded in eps around 0 82.9%
if 2.50000000000000003e54 < x < 3.4999999999999999e267 or 7.2999999999999996e295 < x Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 19.6%
Taylor expanded in x around 0 71.5%
Final simplification76.5%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (* x (+ -1.0 eps_m)))))
(if (<= x -1.1e-215)
(/ (+ 1.0 (exp (* x (- eps_m)))) 2.0)
(if (<= x 8.8e+17)
(/ (+ 1.0 (- t_0 (* x eps_m))) 2.0)
(if (or (<= x 4e+267) (not (<= x 1.4e+297)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (- (/ -1.0 eps_m) -1.0)) 2.0)
(/ (- t_0 -1.0) 2.0))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp((x * (-1.0 + eps_m)));
double tmp;
if (x <= -1.1e-215) {
tmp = (1.0 + exp((x * -eps_m))) / 2.0;
} else if (x <= 8.8e+17) {
tmp = (1.0 + (t_0 - (x * eps_m))) / 2.0;
} else if ((x <= 4e+267) || !(x <= 1.4e+297)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (t_0 - -1.0) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = exp((x * ((-1.0d0) + eps_m)))
if (x <= (-1.1d-215)) then
tmp = (1.0d0 + exp((x * -eps_m))) / 2.0d0
else if (x <= 8.8d+17) then
tmp = (1.0d0 + (t_0 - (x * eps_m))) / 2.0d0
else if ((x <= 4d+267) .or. (.not. (x <= 1.4d+297))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (((-1.0d0) / eps_m) - (-1.0d0))) / 2.0d0
else
tmp = (t_0 - (-1.0d0)) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = Math.exp((x * (-1.0 + eps_m)));
double tmp;
if (x <= -1.1e-215) {
tmp = (1.0 + Math.exp((x * -eps_m))) / 2.0;
} else if (x <= 8.8e+17) {
tmp = (1.0 + (t_0 - (x * eps_m))) / 2.0;
} else if ((x <= 4e+267) || !(x <= 1.4e+297)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (t_0 - -1.0) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp((x * (-1.0 + eps_m))) tmp = 0 if x <= -1.1e-215: tmp = (1.0 + math.exp((x * -eps_m))) / 2.0 elif x <= 8.8e+17: tmp = (1.0 + (t_0 - (x * eps_m))) / 2.0 elif (x <= 4e+267) or not (x <= 1.4e+297): tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0 else: tmp = (t_0 - -1.0) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(x * Float64(-1.0 + eps_m))) tmp = 0.0 if (x <= -1.1e-215) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps_m)))) / 2.0); elseif (x <= 8.8e+17) tmp = Float64(Float64(1.0 + Float64(t_0 - Float64(x * eps_m))) / 2.0); elseif ((x <= 4e+267) || !(x <= 1.4e+297)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(Float64(-1.0 / eps_m) - -1.0)) / 2.0); else tmp = Float64(Float64(t_0 - -1.0) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp((x * (-1.0 + eps_m))); tmp = 0.0; if (x <= -1.1e-215) tmp = (1.0 + exp((x * -eps_m))) / 2.0; elseif (x <= 8.8e+17) tmp = (1.0 + (t_0 - (x * eps_m))) / 2.0; elseif ((x <= 4e+267) || ~((x <= 1.4e+297))) tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0; else tmp = (t_0 - -1.0) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.1e-215], N[(N[(1.0 + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 8.8e+17], N[(N[(1.0 + N[(t$95$0 - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 4e+267], N[Not[LessEqual[x, 1.4e+297]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(-1 + eps_m\right)}\\
\mathbf{if}\;x \leq -1.1 \cdot 10^{-215}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-eps_m\right)}}{2}\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{+17}:\\
\;\;\;\;\frac{1 + \left(t_0 - x \cdot eps_m\right)}{2}\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+267} \lor \neg \left(x \leq 1.4 \cdot 10^{+297}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 - -1}{2}\\
\end{array}
\end{array}
if x < -1.09999999999999998e-215Initial program 65.9%
fma-neg66.0%
/-rgt-identity66.0%
fma-neg65.9%
/-rgt-identity65.9%
distribute-rgt-neg-in65.9%
sub-neg65.9%
metadata-eval65.9%
distribute-rgt-neg-in65.9%
Simplified65.9%
Taylor expanded in x around 0 38.6%
Taylor expanded in eps around inf 70.3%
Taylor expanded in eps around inf 71.3%
*-commutative97.6%
Simplified71.3%
if -1.09999999999999998e-215 < x < 8.8e17Initial program 57.9%
fma-neg57.9%
/-rgt-identity57.9%
fma-neg57.9%
/-rgt-identity57.9%
distribute-rgt-neg-in57.9%
sub-neg57.9%
metadata-eval57.9%
distribute-rgt-neg-in57.9%
Simplified57.9%
Taylor expanded in x around 0 48.3%
Taylor expanded in eps around inf 88.6%
exp-prod88.6%
sub-neg88.6%
mul-1-neg88.6%
exp-prod88.6%
mul-1-neg88.6%
*-commutative88.6%
mul-1-neg88.6%
sub-neg88.6%
distribute-rgt-neg-out88.6%
exp-prod57.8%
mul-1-neg57.8%
unsub-neg57.8%
Simplified88.6%
if 8.8e17 < x < 3.9999999999999999e267 or 1.4000000000000001e297 < x Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 22.2%
Taylor expanded in x around 0 68.8%
if 3.9999999999999999e267 < x < 1.4000000000000001e297Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
*-commutative100.0%
mul-1-neg100.0%
mul-1-neg100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in eps around 0 86.2%
Final simplification77.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (* x (+ -1.0 eps_m)))))
(if (<= x -1.2e-215)
(/ (+ 1.0 (exp (* x (- eps_m)))) 2.0)
(if (<= x 2.4e+17)
(/ (+ t_0 (- 1.0 (* x eps_m))) 2.0)
(if (or (<= x 2.6e+268) (not (<= x 1.08e+297)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (- (/ -1.0 eps_m) -1.0)) 2.0)
(/ (- t_0 -1.0) 2.0))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp((x * (-1.0 + eps_m)));
double tmp;
if (x <= -1.2e-215) {
tmp = (1.0 + exp((x * -eps_m))) / 2.0;
} else if (x <= 2.4e+17) {
tmp = (t_0 + (1.0 - (x * eps_m))) / 2.0;
} else if ((x <= 2.6e+268) || !(x <= 1.08e+297)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (t_0 - -1.0) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: t_0
real(8) :: tmp
t_0 = exp((x * ((-1.0d0) + eps_m)))
if (x <= (-1.2d-215)) then
tmp = (1.0d0 + exp((x * -eps_m))) / 2.0d0
else if (x <= 2.4d+17) then
tmp = (t_0 + (1.0d0 - (x * eps_m))) / 2.0d0
else if ((x <= 2.6d+268) .or. (.not. (x <= 1.08d+297))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (((-1.0d0) / eps_m) - (-1.0d0))) / 2.0d0
else
tmp = (t_0 - (-1.0d0)) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double t_0 = Math.exp((x * (-1.0 + eps_m)));
double tmp;
if (x <= -1.2e-215) {
tmp = (1.0 + Math.exp((x * -eps_m))) / 2.0;
} else if (x <= 2.4e+17) {
tmp = (t_0 + (1.0 - (x * eps_m))) / 2.0;
} else if ((x <= 2.6e+268) || !(x <= 1.08e+297)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (t_0 - -1.0) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp((x * (-1.0 + eps_m))) tmp = 0 if x <= -1.2e-215: tmp = (1.0 + math.exp((x * -eps_m))) / 2.0 elif x <= 2.4e+17: tmp = (t_0 + (1.0 - (x * eps_m))) / 2.0 elif (x <= 2.6e+268) or not (x <= 1.08e+297): tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0 else: tmp = (t_0 - -1.0) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(x * Float64(-1.0 + eps_m))) tmp = 0.0 if (x <= -1.2e-215) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps_m)))) / 2.0); elseif (x <= 2.4e+17) tmp = Float64(Float64(t_0 + Float64(1.0 - Float64(x * eps_m))) / 2.0); elseif ((x <= 2.6e+268) || !(x <= 1.08e+297)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(Float64(-1.0 / eps_m) - -1.0)) / 2.0); else tmp = Float64(Float64(t_0 - -1.0) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp((x * (-1.0 + eps_m))); tmp = 0.0; if (x <= -1.2e-215) tmp = (1.0 + exp((x * -eps_m))) / 2.0; elseif (x <= 2.4e+17) tmp = (t_0 + (1.0 - (x * eps_m))) / 2.0; elseif ((x <= 2.6e+268) || ~((x <= 1.08e+297))) tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0; else tmp = (t_0 - -1.0) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[N[(x * N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.2e-215], N[(N[(1.0 + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.4e+17], N[(N[(t$95$0 + N[(1.0 - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 2.6e+268], N[Not[LessEqual[x, 1.08e+297]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(-1 + eps_m\right)}\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{-215}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-eps_m\right)}}{2}\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{+17}:\\
\;\;\;\;\frac{t_0 + \left(1 - x \cdot eps_m\right)}{2}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+268} \lor \neg \left(x \leq 1.08 \cdot 10^{+297}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 - -1}{2}\\
\end{array}
\end{array}
if x < -1.20000000000000005e-215Initial program 65.9%
fma-neg66.0%
/-rgt-identity66.0%
fma-neg65.9%
/-rgt-identity65.9%
distribute-rgt-neg-in65.9%
sub-neg65.9%
metadata-eval65.9%
distribute-rgt-neg-in65.9%
Simplified65.9%
Taylor expanded in x around 0 38.6%
Taylor expanded in eps around inf 70.3%
Taylor expanded in eps around inf 71.3%
*-commutative97.6%
Simplified71.3%
if -1.20000000000000005e-215 < x < 2.4e17Initial program 57.9%
fma-neg57.9%
/-rgt-identity57.9%
fma-neg57.9%
/-rgt-identity57.9%
distribute-rgt-neg-in57.9%
sub-neg57.9%
metadata-eval57.9%
distribute-rgt-neg-in57.9%
Simplified57.9%
Taylor expanded in eps around inf 98.3%
Taylor expanded in eps around inf 98.2%
*-commutative98.2%
Simplified98.2%
Taylor expanded in x around inf 98.2%
associate-*r*98.2%
neg-mul-198.2%
*-commutative98.2%
mul-1-neg98.2%
mul-1-neg98.2%
distribute-rgt-neg-in98.2%
Simplified98.2%
Taylor expanded in eps around 0 88.6%
mul-1-neg88.6%
unsub-neg88.6%
Simplified88.6%
if 2.4e17 < x < 2.59999999999999993e268 or 1.07999999999999994e297 < x Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 22.2%
Taylor expanded in x around 0 68.8%
if 2.59999999999999993e268 < x < 1.07999999999999994e297Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r*100.0%
neg-mul-1100.0%
*-commutative100.0%
mul-1-neg100.0%
mul-1-neg100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in eps around 0 86.2%
Final simplification77.8%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 1.35e-18)
(/ (+ 1.0 (exp (* x (- eps_m)))) 2.0)
(if (or (<= x 3.4e+267) (not (<= x 1.12e+295)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (- (/ -1.0 eps_m) -1.0)) 2.0)
(/ (* x eps_m) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 1.35e-18) {
tmp = (1.0 + exp((x * -eps_m))) / 2.0;
} else if ((x <= 3.4e+267) || !(x <= 1.12e+295)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 1.35d-18) then
tmp = (1.0d0 + exp((x * -eps_m))) / 2.0d0
else if ((x <= 3.4d+267) .or. (.not. (x <= 1.12d+295))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (((-1.0d0) / eps_m) - (-1.0d0))) / 2.0d0
else
tmp = (x * eps_m) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 1.35e-18) {
tmp = (1.0 + Math.exp((x * -eps_m))) / 2.0;
} else if ((x <= 3.4e+267) || !(x <= 1.12e+295)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 1.35e-18: tmp = (1.0 + math.exp((x * -eps_m))) / 2.0 elif (x <= 3.4e+267) or not (x <= 1.12e+295): tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0 else: tmp = (x * eps_m) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 1.35e-18) tmp = Float64(Float64(1.0 + exp(Float64(x * Float64(-eps_m)))) / 2.0); elseif ((x <= 3.4e+267) || !(x <= 1.12e+295)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(Float64(-1.0 / eps_m) - -1.0)) / 2.0); else tmp = Float64(Float64(x * eps_m) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 1.35e-18) tmp = (1.0 + exp((x * -eps_m))) / 2.0; elseif ((x <= 3.4e+267) || ~((x <= 1.12e+295))) tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0; else tmp = (x * eps_m) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 1.35e-18], N[(N[(1.0 + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 3.4e+267], N[Not[LessEqual[x, 1.12e+295]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{-18}:\\
\;\;\;\;\frac{1 + e^{x \cdot \left(-eps_m\right)}}{2}\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+267} \lor \neg \left(x \leq 1.12 \cdot 10^{+295}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps_m}{2}\\
\end{array}
\end{array}
if x < 1.34999999999999994e-18Initial program 61.6%
fma-neg61.6%
/-rgt-identity61.6%
fma-neg61.6%
/-rgt-identity61.6%
distribute-rgt-neg-in61.6%
sub-neg61.6%
metadata-eval61.6%
distribute-rgt-neg-in61.6%
Simplified61.6%
Taylor expanded in x around 0 44.5%
Taylor expanded in eps around inf 81.7%
Taylor expanded in eps around inf 82.2%
*-commutative98.8%
Simplified82.2%
if 1.34999999999999994e-18 < x < 3.39999999999999982e267 or 1.11999999999999992e295 < x Initial program 97.0%
fma-neg96.9%
/-rgt-identity96.9%
fma-neg97.0%
/-rgt-identity97.0%
distribute-rgt-neg-in97.0%
sub-neg97.0%
metadata-eval97.0%
distribute-rgt-neg-in97.0%
Simplified97.0%
Taylor expanded in x around 0 22.6%
Taylor expanded in x around 0 63.9%
if 3.39999999999999982e267 < x < 1.11999999999999992e295Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 86.0%
Taylor expanded in x around inf 86.0%
*-commutative86.0%
neg-mul-186.0%
distribute-rgt-neg-in86.0%
distribute-rgt-neg-in86.0%
distribute-neg-in86.0%
metadata-eval86.0%
distribute-neg-frac86.0%
metadata-eval86.0%
Simplified86.0%
Taylor expanded in eps around inf 86.0%
Final simplification77.7%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 360.0)
(/ (+ 1.0 (exp (- x))) 2.0)
(if (or (<= x 1.12e+268) (not (<= x 7.4e+296)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (- (/ -1.0 eps_m) -1.0)) 2.0)
(/ (* x eps_m) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 360.0) {
tmp = (1.0 + exp(-x)) / 2.0;
} else if ((x <= 1.12e+268) || !(x <= 7.4e+296)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 360.0d0) then
tmp = (1.0d0 + exp(-x)) / 2.0d0
else if ((x <= 1.12d+268) .or. (.not. (x <= 7.4d+296))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (((-1.0d0) / eps_m) - (-1.0d0))) / 2.0d0
else
tmp = (x * eps_m) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 360.0) {
tmp = (1.0 + Math.exp(-x)) / 2.0;
} else if ((x <= 1.12e+268) || !(x <= 7.4e+296)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 360.0: tmp = (1.0 + math.exp(-x)) / 2.0 elif (x <= 1.12e+268) or not (x <= 7.4e+296): tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0 else: tmp = (x * eps_m) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 360.0) tmp = Float64(Float64(1.0 + exp(Float64(-x))) / 2.0); elseif ((x <= 1.12e+268) || !(x <= 7.4e+296)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(Float64(-1.0 / eps_m) - -1.0)) / 2.0); else tmp = Float64(Float64(x * eps_m) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 360.0) tmp = (1.0 + exp(-x)) / 2.0; elseif ((x <= 1.12e+268) || ~((x <= 7.4e+296))) tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0; else tmp = (x * eps_m) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 360.0], N[(N[(1.0 + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 1.12e+268], N[Not[LessEqual[x, 7.4e+296]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 360:\\
\;\;\;\;\frac{1 + e^{-x}}{2}\\
\mathbf{elif}\;x \leq 1.12 \cdot 10^{+268} \lor \neg \left(x \leq 7.4 \cdot 10^{+296}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps_m}{2}\\
\end{array}
\end{array}
if x < 360Initial program 61.6%
fma-neg61.5%
/-rgt-identity61.5%
fma-neg61.6%
/-rgt-identity61.6%
distribute-rgt-neg-in61.6%
sub-neg61.6%
metadata-eval61.6%
distribute-rgt-neg-in61.6%
Simplified61.6%
Taylor expanded in eps around inf 97.9%
Taylor expanded in eps around inf 97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in eps around 0 84.6%
neg-mul-184.6%
Simplified84.6%
if 360 < x < 1.12000000000000008e268 or 7.39999999999999932e296 < x Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 21.9%
Taylor expanded in x around 0 67.7%
if 1.12000000000000008e268 < x < 7.39999999999999932e296Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 86.0%
Taylor expanded in x around inf 86.0%
*-commutative86.0%
neg-mul-186.0%
distribute-rgt-neg-in86.0%
distribute-rgt-neg-in86.0%
distribute-neg-in86.0%
metadata-eval86.0%
distribute-neg-frac86.0%
metadata-eval86.0%
Simplified86.0%
Taylor expanded in eps around inf 86.0%
Final simplification80.7%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 1.35e-18)
(/ (- 2.0 (* x eps_m)) 2.0)
(if (or (<= x 1.5e+268) (not (<= x 1e+295)))
(/ (+ (+ 1.0 (/ 1.0 eps_m)) (- (/ -1.0 eps_m) -1.0)) 2.0)
(/ (* x eps_m) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 1.35e-18) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else if ((x <= 1.5e+268) || !(x <= 1e+295)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= 1.35d-18) then
tmp = (2.0d0 - (x * eps_m)) / 2.0d0
else if ((x <= 1.5d+268) .or. (.not. (x <= 1d+295))) then
tmp = ((1.0d0 + (1.0d0 / eps_m)) + (((-1.0d0) / eps_m) - (-1.0d0))) / 2.0d0
else
tmp = (x * eps_m) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 1.35e-18) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else if ((x <= 1.5e+268) || !(x <= 1e+295)) {
tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 1.35e-18: tmp = (2.0 - (x * eps_m)) / 2.0 elif (x <= 1.5e+268) or not (x <= 1e+295): tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0 else: tmp = (x * eps_m) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 1.35e-18) tmp = Float64(Float64(2.0 - Float64(x * eps_m)) / 2.0); elseif ((x <= 1.5e+268) || !(x <= 1e+295)) tmp = Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) + Float64(Float64(-1.0 / eps_m) - -1.0)) / 2.0); else tmp = Float64(Float64(x * eps_m) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 1.35e-18) tmp = (2.0 - (x * eps_m)) / 2.0; elseif ((x <= 1.5e+268) || ~((x <= 1e+295))) tmp = ((1.0 + (1.0 / eps_m)) + ((-1.0 / eps_m) - -1.0)) / 2.0; else tmp = (x * eps_m) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 1.35e-18], N[(N[(2.0 - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[Or[LessEqual[x, 1.5e+268], N[Not[LessEqual[x, 1e+295]], $MachinePrecision]], N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 / eps$95$m), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x * eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{-18}:\\
\;\;\;\;\frac{2 - x \cdot eps_m}{2}\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+268} \lor \neg \left(x \leq 10^{+295}\right):\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps_m}\right) + \left(\frac{-1}{eps_m} - -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps_m}{2}\\
\end{array}
\end{array}
if x < 1.34999999999999994e-18Initial program 61.6%
fma-neg61.6%
/-rgt-identity61.6%
fma-neg61.6%
/-rgt-identity61.6%
distribute-rgt-neg-in61.6%
sub-neg61.6%
metadata-eval61.6%
distribute-rgt-neg-in61.6%
Simplified61.6%
Taylor expanded in x around 0 44.5%
Taylor expanded in eps around inf 81.7%
Taylor expanded in x around 0 68.8%
associate-*r*68.8%
neg-mul-168.8%
Simplified68.8%
Taylor expanded in eps around inf 69.3%
associate-*r*69.3%
neg-mul-169.3%
Simplified69.3%
if 1.34999999999999994e-18 < x < 1.49999999999999996e268 or 9.9999999999999998e294 < x Initial program 97.0%
fma-neg96.9%
/-rgt-identity96.9%
fma-neg97.0%
/-rgt-identity97.0%
distribute-rgt-neg-in97.0%
sub-neg97.0%
metadata-eval97.0%
distribute-rgt-neg-in97.0%
Simplified97.0%
Taylor expanded in x around 0 22.6%
Taylor expanded in x around 0 63.9%
if 1.49999999999999996e268 < x < 9.9999999999999998e294Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 86.0%
Taylor expanded in x around inf 86.0%
*-commutative86.0%
neg-mul-186.0%
distribute-rgt-neg-in86.0%
distribute-rgt-neg-in86.0%
distribute-neg-in86.0%
metadata-eval86.0%
distribute-neg-frac86.0%
metadata-eval86.0%
Simplified86.0%
Taylor expanded in eps around inf 86.0%
Final simplification68.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -1.0) (* x (/ eps_m -2.0)) (if (<= x 74.0) 1.0 (/ (* x eps_m) 2.0))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.0) {
tmp = x * (eps_m / -2.0);
} else if (x <= 74.0) {
tmp = 1.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = x * (eps_m / (-2.0d0))
else if (x <= 74.0d0) then
tmp = 1.0d0
else
tmp = (x * eps_m) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -1.0) {
tmp = x * (eps_m / -2.0);
} else if (x <= 74.0) {
tmp = 1.0;
} else {
tmp = (x * eps_m) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1.0: tmp = x * (eps_m / -2.0) elif x <= 74.0: tmp = 1.0 else: tmp = (x * eps_m) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.0) tmp = Float64(x * Float64(eps_m / -2.0)); elseif (x <= 74.0) tmp = 1.0; else tmp = Float64(Float64(x * eps_m) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -1.0) tmp = x * (eps_m / -2.0); elseif (x <= 74.0) tmp = 1.0; else tmp = (x * eps_m) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.0], N[(x * N[(eps$95$m / -2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 74.0], 1.0, N[(N[(x * eps$95$m), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;x \cdot \frac{eps_m}{-2}\\
\mathbf{elif}\;x \leq 74:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot eps_m}{2}\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 62.9%
Taylor expanded in x around inf 36.8%
*-commutative36.8%
neg-mul-136.8%
distribute-rgt-neg-in36.8%
distribute-rgt-neg-in36.8%
distribute-neg-in36.8%
metadata-eval36.8%
distribute-neg-frac36.8%
metadata-eval36.8%
Simplified36.8%
Taylor expanded in eps around inf 36.8%
expm1-log1p-u36.7%
expm1-udef36.7%
frac-2neg36.7%
*-commutative36.7%
distribute-rgt-neg-out36.7%
associate-/l*36.7%
metadata-eval36.7%
add-sqr-sqrt36.7%
sqrt-unprod41.0%
sqr-neg41.0%
sqrt-unprod0.0%
add-sqr-sqrt25.5%
Applied egg-rr25.5%
expm1-def25.5%
expm1-log1p25.5%
associate-/r/25.5%
Simplified25.5%
if -1 < x < 74Initial program 50.6%
fma-neg50.6%
/-rgt-identity50.6%
fma-neg50.6%
/-rgt-identity50.6%
distribute-rgt-neg-in50.6%
sub-neg50.6%
metadata-eval50.6%
distribute-rgt-neg-in50.6%
Simplified50.6%
Taylor expanded in x around 0 80.8%
if 74 < x Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 19.5%
Taylor expanded in x around inf 15.0%
*-commutative15.0%
neg-mul-115.0%
distribute-rgt-neg-in15.0%
distribute-rgt-neg-in15.0%
distribute-neg-in15.0%
metadata-eval15.0%
distribute-neg-frac15.0%
metadata-eval15.0%
Simplified15.0%
Taylor expanded in eps around inf 16.0%
Final simplification54.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -0.95) (* x (/ eps_m -2.0)) (/ (+ 2.0 (* x eps_m)) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -0.95) {
tmp = x * (eps_m / -2.0);
} else {
tmp = (2.0 + (x * eps_m)) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-0.95d0)) then
tmp = x * (eps_m / (-2.0d0))
else
tmp = (2.0d0 + (x * eps_m)) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -0.95) {
tmp = x * (eps_m / -2.0);
} else {
tmp = (2.0 + (x * eps_m)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -0.95: tmp = x * (eps_m / -2.0) else: tmp = (2.0 + (x * eps_m)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -0.95) tmp = Float64(x * Float64(eps_m / -2.0)); else tmp = Float64(Float64(2.0 + Float64(x * eps_m)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -0.95) tmp = x * (eps_m / -2.0); else tmp = (2.0 + (x * eps_m)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -0.95], N[(x * N[(eps$95$m / -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.95:\\
\;\;\;\;x \cdot \frac{eps_m}{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + x \cdot eps_m}{2}\\
\end{array}
\end{array}
if x < -0.94999999999999996Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 62.9%
Taylor expanded in x around inf 36.8%
*-commutative36.8%
neg-mul-136.8%
distribute-rgt-neg-in36.8%
distribute-rgt-neg-in36.8%
distribute-neg-in36.8%
metadata-eval36.8%
distribute-neg-frac36.8%
metadata-eval36.8%
Simplified36.8%
Taylor expanded in eps around inf 36.8%
expm1-log1p-u36.7%
expm1-udef36.7%
frac-2neg36.7%
*-commutative36.7%
distribute-rgt-neg-out36.7%
associate-/l*36.7%
metadata-eval36.7%
add-sqr-sqrt36.7%
sqrt-unprod41.0%
sqr-neg41.0%
sqrt-unprod0.0%
add-sqr-sqrt25.5%
Applied egg-rr25.5%
expm1-def25.5%
expm1-log1p25.5%
associate-/r/25.5%
Simplified25.5%
if -0.94999999999999996 < x Initial program 66.0%
fma-neg66.0%
/-rgt-identity66.0%
fma-neg66.0%
/-rgt-identity66.0%
distribute-rgt-neg-in66.0%
sub-neg66.0%
metadata-eval66.0%
distribute-rgt-neg-in66.0%
Simplified66.0%
Taylor expanded in x around 0 35.5%
Taylor expanded in x around 0 27.1%
Taylor expanded in eps around inf 59.9%
+-commutative59.9%
Simplified59.9%
Final simplification54.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -1.05e-215) (/ (- 2.0 (* x eps_m)) 2.0) (/ (+ 2.0 (* x eps_m)) 2.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.05e-215) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else {
tmp = (2.0 + (x * eps_m)) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-1.05d-215)) then
tmp = (2.0d0 - (x * eps_m)) / 2.0d0
else
tmp = (2.0d0 + (x * eps_m)) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -1.05e-215) {
tmp = (2.0 - (x * eps_m)) / 2.0;
} else {
tmp = (2.0 + (x * eps_m)) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1.05e-215: tmp = (2.0 - (x * eps_m)) / 2.0 else: tmp = (2.0 + (x * eps_m)) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.05e-215) tmp = Float64(Float64(2.0 - Float64(x * eps_m)) / 2.0); else tmp = Float64(Float64(2.0 + Float64(x * eps_m)) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -1.05e-215) tmp = (2.0 - (x * eps_m)) / 2.0; else tmp = (2.0 + (x * eps_m)) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.05e-215], N[(N[(2.0 - N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(2.0 + N[(x * eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{-215}:\\
\;\;\;\;\frac{2 - x \cdot eps_m}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + x \cdot eps_m}{2}\\
\end{array}
\end{array}
if x < -1.05e-215Initial program 65.9%
fma-neg66.0%
/-rgt-identity66.0%
fma-neg65.9%
/-rgt-identity65.9%
distribute-rgt-neg-in65.9%
sub-neg65.9%
metadata-eval65.9%
distribute-rgt-neg-in65.9%
Simplified65.9%
Taylor expanded in x around 0 38.6%
Taylor expanded in eps around inf 70.3%
Taylor expanded in x around 0 52.9%
associate-*r*52.9%
neg-mul-152.9%
Simplified52.9%
Taylor expanded in eps around inf 53.9%
associate-*r*53.9%
neg-mul-153.9%
Simplified53.9%
if -1.05e-215 < x Initial program 74.8%
fma-neg74.7%
/-rgt-identity74.7%
fma-neg74.8%
/-rgt-identity74.8%
distribute-rgt-neg-in74.8%
sub-neg74.8%
metadata-eval74.8%
distribute-rgt-neg-in74.8%
Simplified74.8%
Taylor expanded in x around 0 37.4%
Taylor expanded in x around 0 30.0%
Taylor expanded in eps around inf 54.4%
+-commutative54.4%
Simplified54.4%
Final simplification54.2%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -1.0) (* x (/ eps_m -2.0)) 1.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.0) {
tmp = x * (eps_m / -2.0);
} else {
tmp = 1.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (x <= (-1.0d0)) then
tmp = x * (eps_m / (-2.0d0))
else
tmp = 1.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -1.0) {
tmp = x * (eps_m / -2.0);
} else {
tmp = 1.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1.0: tmp = x * (eps_m / -2.0) else: tmp = 1.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.0) tmp = Float64(x * Float64(eps_m / -2.0)); else tmp = 1.0; end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -1.0) tmp = x * (eps_m / -2.0); else tmp = 1.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.0], N[(x * N[(eps$95$m / -2.0), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;x \cdot \frac{eps_m}{-2}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
fma-neg100.0%
/-rgt-identity100.0%
fma-neg100.0%
/-rgt-identity100.0%
distribute-rgt-neg-in100.0%
sub-neg100.0%
metadata-eval100.0%
distribute-rgt-neg-in100.0%
Simplified100.0%
Taylor expanded in x around 0 62.9%
Taylor expanded in x around inf 36.8%
*-commutative36.8%
neg-mul-136.8%
distribute-rgt-neg-in36.8%
distribute-rgt-neg-in36.8%
distribute-neg-in36.8%
metadata-eval36.8%
distribute-neg-frac36.8%
metadata-eval36.8%
Simplified36.8%
Taylor expanded in eps around inf 36.8%
expm1-log1p-u36.7%
expm1-udef36.7%
frac-2neg36.7%
*-commutative36.7%
distribute-rgt-neg-out36.7%
associate-/l*36.7%
metadata-eval36.7%
add-sqr-sqrt36.7%
sqrt-unprod41.0%
sqr-neg41.0%
sqrt-unprod0.0%
add-sqr-sqrt25.5%
Applied egg-rr25.5%
expm1-def25.5%
expm1-log1p25.5%
associate-/r/25.5%
Simplified25.5%
if -1 < x Initial program 66.0%
fma-neg66.0%
/-rgt-identity66.0%
fma-neg66.0%
/-rgt-identity66.0%
distribute-rgt-neg-in66.0%
sub-neg66.0%
metadata-eval66.0%
distribute-rgt-neg-in66.0%
Simplified66.0%
Taylor expanded in x around 0 56.5%
Final simplification51.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 1.0)
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 1.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = 1.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 1.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return 1.0
eps_m = abs(eps) function code(x, eps_m) return 1.0 end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 1.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := 1.0
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
1
\end{array}
Initial program 71.6%
fma-neg71.6%
/-rgt-identity71.6%
fma-neg71.6%
/-rgt-identity71.6%
distribute-rgt-neg-in71.6%
sub-neg71.6%
metadata-eval71.6%
distribute-rgt-neg-in71.6%
Simplified71.6%
Taylor expanded in x around 0 47.7%
Final simplification47.7%
herbie shell --seed 2024024
(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))