
(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 12 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 6.2e-5)
(/ (+ t_0 t_0) 2.0)
(/ (+ (exp (* x 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 <= 6.2e-5) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (exp((x * 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 <= 6.2d-5) then
tmp = (t_0 + t_0) / 2.0d0
else
tmp = (exp((x * 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 <= 6.2e-5) {
tmp = (t_0 + t_0) / 2.0;
} else {
tmp = (Math.exp((x * 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 <= 6.2e-5: tmp = (t_0 + t_0) / 2.0 else: tmp = (math.exp((x * 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 <= 6.2e-5) tmp = Float64(Float64(t_0 + t_0) / 2.0); else tmp = Float64(Float64(exp(Float64(x * 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 <= 6.2e-5) tmp = (t_0 + t_0) / 2.0; else tmp = (exp((x * 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, 6.2e-5], N[(N[(t$95$0 + t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $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 6.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{t\_0 + t\_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 6.20000000000000027e-5Initial program 62.1%
Simplified62.1%
Taylor expanded in eps around 0 66.9%
distribute-rgt1-in66.9%
mul-1-neg66.9%
distribute-lft-out66.9%
distribute-rgt1-in67.5%
mul-1-neg67.5%
Simplified67.5%
if 6.20000000000000027e-5 < eps Initial program 99.9%
Simplified99.9%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around -inf 100.0%
mul-1-neg100.0%
associate-*r*100.0%
sub-neg100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-in100.0%
metadata-eval100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
mul-1-neg100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
Simplified100.0%
Final simplification77.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= eps_m 6.2e-5)
(/ (+ (* t_0 (+ (+ x 1.0) 1.0)) (* x t_0)) 2.0)
(/ (+ (exp (* x eps_m)) (exp (* x (- eps_m)))) 2.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (eps_m <= 6.2e-5) {
tmp = ((t_0 * ((x + 1.0) + 1.0)) + (x * t_0)) / 2.0;
} else {
tmp = (exp((x * 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 = exp(-x)
if (eps_m <= 6.2d-5) then
tmp = ((t_0 * ((x + 1.0d0) + 1.0d0)) + (x * t_0)) / 2.0d0
else
tmp = (exp((x * 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 = Math.exp(-x);
double tmp;
if (eps_m <= 6.2e-5) {
tmp = ((t_0 * ((x + 1.0) + 1.0)) + (x * t_0)) / 2.0;
} else {
tmp = (Math.exp((x * eps_m)) + Math.exp((x * -eps_m))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp(-x) tmp = 0 if eps_m <= 6.2e-5: tmp = ((t_0 * ((x + 1.0) + 1.0)) + (x * t_0)) / 2.0 else: tmp = (math.exp((x * eps_m)) + math.exp((x * -eps_m))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (eps_m <= 6.2e-5) tmp = Float64(Float64(Float64(t_0 * Float64(Float64(x + 1.0) + 1.0)) + Float64(x * t_0)) / 2.0); else tmp = Float64(Float64(exp(Float64(x * 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 = exp(-x); tmp = 0.0; if (eps_m <= 6.2e-5) tmp = ((t_0 * ((x + 1.0) + 1.0)) + (x * t_0)) / 2.0; else tmp = (exp((x * 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[Exp[(-x)], $MachinePrecision]}, If[LessEqual[eps$95$m, 6.2e-5], N[(N[(N[(t$95$0 * N[(N[(x + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[Exp[N[(x * eps$95$m), $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 := e^{-x}\\
\mathbf{if}\;eps\_m \leq 6.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{t\_0 \cdot \left(\left(x + 1\right) + 1\right) + x \cdot t\_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\end{array}
\end{array}
if eps < 6.20000000000000027e-5Initial program 62.1%
Simplified62.1%
Taylor expanded in eps around 0 66.9%
associate--r+66.9%
associate-*r*66.9%
cancel-sign-sub-inv66.9%
distribute-rgt1-in66.9%
distribute-rgt-out--67.5%
mul-1-neg67.5%
mul-1-neg67.5%
remove-double-neg67.5%
mul-1-neg67.5%
Simplified67.5%
if 6.20000000000000027e-5 < eps Initial program 99.9%
Simplified99.9%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around -inf 100.0%
mul-1-neg100.0%
associate-*r*100.0%
sub-neg100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
associate-*l*100.0%
distribute-lft-in100.0%
metadata-eval100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
mul-1-neg100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
Simplified100.0%
Final simplification77.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 4.8e+127) (/ (+ (exp (* x eps_m)) (exp (* x (- eps_m)))) 2.0) (* x (exp (- x)))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 4.8e+127) {
tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0;
} else {
tmp = x * exp(-x);
}
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 <= 4.8d+127) then
tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0d0
else
tmp = x * exp(-x)
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= 4.8e+127) {
tmp = (Math.exp((x * eps_m)) + Math.exp((x * -eps_m))) / 2.0;
} else {
tmp = x * Math.exp(-x);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= 4.8e+127: tmp = (math.exp((x * eps_m)) + math.exp((x * -eps_m))) / 2.0 else: tmp = x * math.exp(-x) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 4.8e+127) tmp = Float64(Float64(exp(Float64(x * eps_m)) + exp(Float64(x * Float64(-eps_m)))) / 2.0); else tmp = Float64(x * exp(Float64(-x))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= 4.8e+127) tmp = (exp((x * eps_m)) + exp((x * -eps_m))) / 2.0; else tmp = x * exp(-x); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 4.8e+127], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * (-eps$95$m)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(x * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.8 \cdot 10^{+127}:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + e^{x \cdot \left(-eps\_m\right)}}{2}\\
\mathbf{else}:\\
\;\;\;\;x \cdot e^{-x}\\
\end{array}
\end{array}
if x < 4.8000000000000004e127Initial program 69.3%
Simplified69.3%
Taylor expanded in eps around inf 99.2%
Taylor expanded in eps around inf 94.4%
Taylor expanded in eps around -inf 94.4%
mul-1-neg94.4%
associate-*r*94.4%
sub-neg94.4%
mul-1-neg94.4%
remove-double-neg94.4%
*-commutative94.4%
associate-*l*94.4%
distribute-lft-in94.4%
metadata-eval94.4%
mul-1-neg94.4%
unsub-neg94.4%
Simplified94.4%
Taylor expanded in eps around inf 94.5%
mul-1-neg94.5%
distribute-lft-neg-out94.5%
*-commutative94.5%
Simplified94.5%
if 4.8000000000000004e127 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 60.6%
associate--r+60.6%
associate-*r*60.6%
cancel-sign-sub-inv60.6%
distribute-rgt1-in60.6%
distribute-rgt-out--60.6%
mul-1-neg60.6%
mul-1-neg60.6%
remove-double-neg60.6%
mul-1-neg60.6%
Simplified60.6%
Taylor expanded in x around inf 60.6%
Final simplification89.9%
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 73.5%
Simplified73.5%
Taylor expanded in eps around inf 99.3%
Final simplification99.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -10000000.0)
(/ (+ t_0 1.0) 2.0)
(if (<= x -1e-279)
(/ (+ (+ (* x eps_m) 1.0) (exp (* x (- -1.0 eps_m)))) 2.0)
(if (<= x 2.6e+127) (/ (+ (exp (* x eps_m)) 1.0) 2.0) (* x t_0))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (x <= -10000000.0) {
tmp = (t_0 + 1.0) / 2.0;
} else if (x <= -1e-279) {
tmp = (((x * eps_m) + 1.0) + exp((x * (-1.0 - eps_m)))) / 2.0;
} else if (x <= 2.6e+127) {
tmp = (exp((x * eps_m)) + 1.0) / 2.0;
} else {
tmp = x * t_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)
if (x <= (-10000000.0d0)) then
tmp = (t_0 + 1.0d0) / 2.0d0
else if (x <= (-1d-279)) then
tmp = (((x * eps_m) + 1.0d0) + exp((x * ((-1.0d0) - eps_m)))) / 2.0d0
else if (x <= 2.6d+127) then
tmp = (exp((x * eps_m)) + 1.0d0) / 2.0d0
else
tmp = x * t_0
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);
double tmp;
if (x <= -10000000.0) {
tmp = (t_0 + 1.0) / 2.0;
} else if (x <= -1e-279) {
tmp = (((x * eps_m) + 1.0) + Math.exp((x * (-1.0 - eps_m)))) / 2.0;
} else if (x <= 2.6e+127) {
tmp = (Math.exp((x * eps_m)) + 1.0) / 2.0;
} else {
tmp = x * t_0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp(-x) tmp = 0 if x <= -10000000.0: tmp = (t_0 + 1.0) / 2.0 elif x <= -1e-279: tmp = (((x * eps_m) + 1.0) + math.exp((x * (-1.0 - eps_m)))) / 2.0 elif x <= 2.6e+127: tmp = (math.exp((x * eps_m)) + 1.0) / 2.0 else: tmp = x * t_0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -10000000.0) tmp = Float64(Float64(t_0 + 1.0) / 2.0); elseif (x <= -1e-279) tmp = Float64(Float64(Float64(Float64(x * eps_m) + 1.0) + exp(Float64(x * Float64(-1.0 - eps_m)))) / 2.0); elseif (x <= 2.6e+127) tmp = Float64(Float64(exp(Float64(x * eps_m)) + 1.0) / 2.0); else tmp = Float64(x * t_0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp(-x); tmp = 0.0; if (x <= -10000000.0) tmp = (t_0 + 1.0) / 2.0; elseif (x <= -1e-279) tmp = (((x * eps_m) + 1.0) + exp((x * (-1.0 - eps_m)))) / 2.0; elseif (x <= 2.6e+127) tmp = (exp((x * eps_m)) + 1.0) / 2.0; else tmp = x * t_0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -10000000.0], N[(N[(t$95$0 + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1e-279], N[(N[(N[(N[(x * eps$95$m), $MachinePrecision] + 1.0), $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 2.6e+127], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -10000000:\\
\;\;\;\;\frac{t\_0 + 1}{2}\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-279}:\\
\;\;\;\;\frac{\left(x \cdot eps\_m + 1\right) + e^{x \cdot \left(-1 - eps\_m\right)}}{2}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+127}:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + 1}{2}\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if x < -1e7Initial program 97.4%
Simplified97.4%
Taylor expanded in eps around inf 97.4%
Taylor expanded in eps around inf 97.4%
Taylor expanded in eps around 0 97.4%
sub-neg97.4%
mul-1-neg97.4%
remove-double-neg97.4%
neg-mul-197.4%
Simplified97.4%
if -1e7 < x < -1.00000000000000006e-279Initial program 52.4%
Simplified52.4%
Taylor expanded in eps around inf 98.9%
Taylor expanded in eps around inf 98.9%
Taylor expanded in eps around -inf 98.9%
mul-1-neg98.9%
associate-*r*98.9%
sub-neg98.9%
mul-1-neg98.9%
remove-double-neg98.9%
*-commutative98.9%
associate-*l*98.9%
distribute-lft-in98.9%
metadata-eval98.9%
mul-1-neg98.9%
unsub-neg98.9%
Simplified98.9%
Taylor expanded in eps around 0 85.2%
if -1.00000000000000006e-279 < x < 2.6000000000000002e127Initial program 68.7%
Simplified68.7%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 91.4%
Taylor expanded in x around 0 71.2%
if 2.6000000000000002e127 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 60.6%
associate--r+60.6%
associate-*r*60.6%
cancel-sign-sub-inv60.6%
distribute-rgt1-in60.6%
distribute-rgt-out--60.6%
mul-1-neg60.6%
mul-1-neg60.6%
remove-double-neg60.6%
mul-1-neg60.6%
Simplified60.6%
Taylor expanded in x around inf 60.6%
Final simplification76.9%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -2e-280)
(/ (+ t_0 1.0) 2.0)
(if (<= x 6e+127) (/ (+ (exp (* x eps_m)) 1.0) 2.0) (* x t_0)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (x <= -2e-280) {
tmp = (t_0 + 1.0) / 2.0;
} else if (x <= 6e+127) {
tmp = (exp((x * eps_m)) + 1.0) / 2.0;
} else {
tmp = x * t_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)
if (x <= (-2d-280)) then
tmp = (t_0 + 1.0d0) / 2.0d0
else if (x <= 6d+127) then
tmp = (exp((x * eps_m)) + 1.0d0) / 2.0d0
else
tmp = x * t_0
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);
double tmp;
if (x <= -2e-280) {
tmp = (t_0 + 1.0) / 2.0;
} else if (x <= 6e+127) {
tmp = (Math.exp((x * eps_m)) + 1.0) / 2.0;
} else {
tmp = x * t_0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp(-x) tmp = 0 if x <= -2e-280: tmp = (t_0 + 1.0) / 2.0 elif x <= 6e+127: tmp = (math.exp((x * eps_m)) + 1.0) / 2.0 else: tmp = x * t_0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -2e-280) tmp = Float64(Float64(t_0 + 1.0) / 2.0); elseif (x <= 6e+127) tmp = Float64(Float64(exp(Float64(x * eps_m)) + 1.0) / 2.0); else tmp = Float64(x * t_0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp(-x); tmp = 0.0; if (x <= -2e-280) tmp = (t_0 + 1.0) / 2.0; elseif (x <= 6e+127) tmp = (exp((x * eps_m)) + 1.0) / 2.0; else tmp = x * t_0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -2e-280], N[(N[(t$95$0 + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 6e+127], N[(N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-280}:\\
\;\;\;\;\frac{t\_0 + 1}{2}\\
\mathbf{elif}\;x \leq 6 \cdot 10^{+127}:\\
\;\;\;\;\frac{e^{x \cdot eps\_m} + 1}{2}\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if x < -1.9999999999999999e-280Initial program 70.0%
Simplified70.0%
Taylor expanded in eps around inf 98.3%
Taylor expanded in eps around inf 98.3%
Taylor expanded in eps around 0 83.9%
sub-neg83.9%
mul-1-neg83.9%
remove-double-neg83.9%
neg-mul-183.9%
Simplified83.9%
if -1.9999999999999999e-280 < x < 6.0000000000000005e127Initial program 68.7%
Simplified68.7%
Taylor expanded in eps around inf 100.0%
Taylor expanded in eps around inf 91.4%
Taylor expanded in x around 0 71.2%
if 6.0000000000000005e127 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 60.6%
associate--r+60.6%
associate-*r*60.6%
cancel-sign-sub-inv60.6%
distribute-rgt1-in60.6%
distribute-rgt-out--60.6%
mul-1-neg60.6%
mul-1-neg60.6%
remove-double-neg60.6%
mul-1-neg60.6%
Simplified60.6%
Taylor expanded in x around inf 60.6%
Final simplification74.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -3.8e-32)
(/ (* x (/ (- 1.0 (* eps_m eps_m)) (+ -1.0 eps_m))) 2.0)
(if (<= x 1.5e+32)
(+ (* (* x x) (- (* x 0.3333333333333333) 0.5)) 1.0)
(* x (exp (- x))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -3.8e-32) {
tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0;
} else if (x <= 1.5e+32) {
tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
} else {
tmp = x * exp(-x);
}
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 <= (-3.8d-32)) then
tmp = (x * ((1.0d0 - (eps_m * eps_m)) / ((-1.0d0) + eps_m))) / 2.0d0
else if (x <= 1.5d+32) then
tmp = ((x * x) * ((x * 0.3333333333333333d0) - 0.5d0)) + 1.0d0
else
tmp = x * exp(-x)
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (x <= -3.8e-32) {
tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0;
} else if (x <= 1.5e+32) {
tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
} else {
tmp = x * Math.exp(-x);
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -3.8e-32: tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0 elif x <= 1.5e+32: tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0 else: tmp = x * math.exp(-x) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -3.8e-32) tmp = Float64(Float64(x * Float64(Float64(1.0 - Float64(eps_m * eps_m)) / Float64(-1.0 + eps_m))) / 2.0); elseif (x <= 1.5e+32) tmp = Float64(Float64(Float64(x * x) * Float64(Float64(x * 0.3333333333333333) - 0.5)) + 1.0); else tmp = Float64(x * exp(Float64(-x))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -3.8e-32) tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0; elseif (x <= 1.5e+32) tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0; else tmp = x * exp(-x); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -3.8e-32], N[(N[(x * N[(N[(1.0 - N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.5e+32], N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(x * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{-32}:\\
\;\;\;\;\frac{x \cdot \frac{1 - eps\_m \cdot eps\_m}{-1 + eps\_m}}{2}\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+32}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333 - 0.5\right) + 1\\
\mathbf{else}:\\
\;\;\;\;x \cdot e^{-x}\\
\end{array}
\end{array}
if x < -3.80000000000000008e-32Initial program 95.2%
Simplified95.2%
Taylor expanded in eps around inf 96.0%
Taylor expanded in x around 0 48.9%
Taylor expanded in x around inf 28.9%
mul-1-neg28.9%
distribute-rgt-neg-in28.9%
distribute-neg-in28.9%
metadata-eval28.9%
unsub-neg28.9%
Simplified28.9%
sub-neg28.9%
flip-+37.6%
metadata-eval37.6%
Applied egg-rr37.6%
if -3.80000000000000008e-32 < x < 1.5e32Initial program 56.3%
Simplified56.3%
Taylor expanded in eps around 0 72.9%
associate--r+72.9%
associate-*r*72.9%
cancel-sign-sub-inv72.9%
distribute-rgt1-in72.9%
distribute-rgt-out--72.9%
mul-1-neg72.9%
mul-1-neg72.9%
remove-double-neg72.9%
mul-1-neg72.9%
Simplified72.9%
Taylor expanded in x around 0 73.0%
unpow273.0%
Applied egg-rr73.0%
if 1.5e32 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 50.8%
associate--r+50.8%
associate-*r*50.8%
cancel-sign-sub-inv50.8%
distribute-rgt1-in50.8%
distribute-rgt-out--50.8%
mul-1-neg50.8%
mul-1-neg50.8%
remove-double-neg50.8%
mul-1-neg50.8%
Simplified50.8%
Taylor expanded in x around inf 50.8%
Final simplification61.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (let* ((t_0 (exp (- x)))) (if (<= x 1.5e+32) (/ (+ t_0 1.0) 2.0) (* x t_0))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = exp(-x);
double tmp;
if (x <= 1.5e+32) {
tmp = (t_0 + 1.0) / 2.0;
} else {
tmp = x * t_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)
if (x <= 1.5d+32) then
tmp = (t_0 + 1.0d0) / 2.0d0
else
tmp = x * t_0
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);
double tmp;
if (x <= 1.5e+32) {
tmp = (t_0 + 1.0) / 2.0;
} else {
tmp = x * t_0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): t_0 = math.exp(-x) tmp = 0 if x <= 1.5e+32: tmp = (t_0 + 1.0) / 2.0 else: tmp = x * t_0 return tmp
eps_m = abs(eps) function code(x, eps_m) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= 1.5e+32) tmp = Float64(Float64(t_0 + 1.0) / 2.0); else tmp = Float64(x * t_0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) t_0 = exp(-x); tmp = 0.0; if (x <= 1.5e+32) tmp = (t_0 + 1.0) / 2.0; else tmp = x * t_0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, 1.5e+32], N[(N[(t$95$0 + 1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq 1.5 \cdot 10^{+32}:\\
\;\;\;\;\frac{t\_0 + 1}{2}\\
\mathbf{else}:\\
\;\;\;\;x \cdot t\_0\\
\end{array}
\end{array}
if x < 1.5e32Initial program 64.6%
Simplified64.6%
Taylor expanded in eps around inf 99.1%
Taylor expanded in eps around inf 99.1%
Taylor expanded in eps around 0 76.8%
sub-neg76.8%
mul-1-neg76.8%
remove-double-neg76.8%
neg-mul-176.8%
Simplified76.8%
if 1.5e32 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around 0 50.8%
associate--r+50.8%
associate-*r*50.8%
cancel-sign-sub-inv50.8%
distribute-rgt1-in50.8%
distribute-rgt-out--50.8%
mul-1-neg50.8%
mul-1-neg50.8%
remove-double-neg50.8%
mul-1-neg50.8%
Simplified50.8%
Taylor expanded in x around inf 50.8%
Final simplification70.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -1.02e-29) (/ (* x (/ (- 1.0 (* eps_m eps_m)) (+ -1.0 eps_m))) 2.0) (+ (* (* x x) (- (* x 0.3333333333333333) 0.5)) 1.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.02e-29) {
tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0;
} else {
tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 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.02d-29)) then
tmp = (x * ((1.0d0 - (eps_m * eps_m)) / ((-1.0d0) + eps_m))) / 2.0d0
else
tmp = ((x * x) * ((x * 0.3333333333333333d0) - 0.5d0)) + 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.02e-29) {
tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0;
} else {
tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -1.02e-29: tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0 else: tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.02e-29) tmp = Float64(Float64(x * Float64(Float64(1.0 - Float64(eps_m * eps_m)) / Float64(-1.0 + eps_m))) / 2.0); else tmp = Float64(Float64(Float64(x * x) * Float64(Float64(x * 0.3333333333333333) - 0.5)) + 1.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -1.02e-29) tmp = (x * ((1.0 - (eps_m * eps_m)) / (-1.0 + eps_m))) / 2.0; else tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.02e-29], N[(N[(x * N[(N[(1.0 - N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision] / N[(-1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.02 \cdot 10^{-29}:\\
\;\;\;\;\frac{x \cdot \frac{1 - eps\_m \cdot eps\_m}{-1 + eps\_m}}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333 - 0.5\right) + 1\\
\end{array}
\end{array}
if x < -1.01999999999999994e-29Initial program 95.2%
Simplified95.2%
Taylor expanded in eps around inf 96.0%
Taylor expanded in x around 0 48.9%
Taylor expanded in x around inf 28.9%
mul-1-neg28.9%
distribute-rgt-neg-in28.9%
distribute-neg-in28.9%
metadata-eval28.9%
unsub-neg28.9%
Simplified28.9%
sub-neg28.9%
flip-+37.6%
metadata-eval37.6%
Applied egg-rr37.6%
if -1.01999999999999994e-29 < x Initial program 69.3%
Simplified69.3%
Taylor expanded in eps around 0 66.3%
associate--r+66.3%
associate-*r*66.3%
cancel-sign-sub-inv66.3%
distribute-rgt1-in66.3%
distribute-rgt-out--66.3%
mul-1-neg66.3%
mul-1-neg66.3%
remove-double-neg66.3%
mul-1-neg66.3%
Simplified66.3%
Taylor expanded in x around 0 60.7%
unpow260.7%
Applied egg-rr60.7%
Final simplification57.0%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -14500000.0) (/ (* x (- -1.0 eps_m)) 2.0) (+ (* (* x x) (- (* x 0.3333333333333333) 0.5)) 1.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -14500000.0) {
tmp = (x * (-1.0 - eps_m)) / 2.0;
} else {
tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 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 <= (-14500000.0d0)) then
tmp = (x * ((-1.0d0) - eps_m)) / 2.0d0
else
tmp = ((x * x) * ((x * 0.3333333333333333d0) - 0.5d0)) + 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 <= -14500000.0) {
tmp = (x * (-1.0 - eps_m)) / 2.0;
} else {
tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if x <= -14500000.0: tmp = (x * (-1.0 - eps_m)) / 2.0 else: tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -14500000.0) tmp = Float64(Float64(x * Float64(-1.0 - eps_m)) / 2.0); else tmp = Float64(Float64(Float64(x * x) * Float64(Float64(x * 0.3333333333333333) - 0.5)) + 1.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (x <= -14500000.0) tmp = (x * (-1.0 - eps_m)) / 2.0; else tmp = ((x * x) * ((x * 0.3333333333333333) - 0.5)) + 1.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -14500000.0], N[(N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * 0.3333333333333333), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -14500000:\\
\;\;\;\;\frac{x \cdot \left(-1 - eps\_m\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot 0.3333333333333333 - 0.5\right) + 1\\
\end{array}
\end{array}
if x < -1.45e7Initial program 100.0%
Simplified100.0%
Taylor expanded in eps around inf 100.0%
Taylor expanded in x around 0 50.4%
Taylor expanded in x around inf 31.6%
mul-1-neg31.6%
distribute-rgt-neg-in31.6%
distribute-neg-in31.6%
metadata-eval31.6%
unsub-neg31.6%
Simplified31.6%
if -1.45e7 < x Initial program 69.0%
Simplified69.0%
Taylor expanded in eps around 0 65.6%
associate--r+65.6%
associate-*r*65.6%
cancel-sign-sub-inv65.6%
distribute-rgt1-in65.6%
distribute-rgt-out--66.0%
mul-1-neg66.0%
mul-1-neg66.0%
remove-double-neg66.0%
mul-1-neg66.0%
Simplified66.0%
Taylor expanded in x around 0 60.0%
unpow260.0%
Applied egg-rr60.0%
Final simplification55.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -1.0) (* x (* eps_m -0.5)) 1.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.0) {
tmp = x * (eps_m * -0.5);
} 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 * (-0.5d0))
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 * -0.5);
} 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 * -0.5) 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 * -0.5)); 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 * -0.5); 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 * -0.5), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;x \cdot \left(eps\_m \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -1Initial program 97.4%
Simplified97.4%
Taylor expanded in eps around inf 97.4%
Taylor expanded in x around 0 49.1%
Taylor expanded in x around inf 30.7%
mul-1-neg30.7%
distribute-rgt-neg-in30.7%
distribute-neg-in30.7%
metadata-eval30.7%
unsub-neg30.7%
Simplified30.7%
Taylor expanded in eps around inf 30.8%
*-commutative30.8%
associate-*r*30.8%
*-commutative30.8%
associate-*l*30.8%
Simplified30.8%
if -1 < x Initial program 69.3%
Simplified69.3%
Taylor expanded in eps around 0 65.9%
associate--r+65.9%
associate-*r*65.9%
cancel-sign-sub-inv65.9%
distribute-rgt1-in65.9%
distribute-rgt-out--65.9%
mul-1-neg65.9%
mul-1-neg65.9%
remove-double-neg65.9%
mul-1-neg65.9%
Simplified65.9%
Taylor expanded in x around 0 51.7%
Final simplification48.6%
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 73.5%
Simplified73.5%
Taylor expanded in eps around 0 56.1%
associate--r+56.1%
associate-*r*56.1%
cancel-sign-sub-inv56.1%
distribute-rgt1-in56.1%
distribute-rgt-out--56.5%
mul-1-neg56.5%
mul-1-neg56.5%
remove-double-neg56.5%
mul-1-neg56.5%
Simplified56.5%
Taylor expanded in x around 0 44.5%
herbie shell --seed 2024181
(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))