
(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 15 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 (if (<= eps_m 1.0) (* 0.5 (* 2.0 (* (exp (- x)) (+ x 1.0)))) (* 0.5 (+ (exp (* x eps_m)) (exp (* x (- -1.0 eps_m)))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.0) {
tmp = 0.5 * (2.0 * (exp(-x) * (x + 1.0)));
} else {
tmp = 0.5 * (exp((x * eps_m)) + exp((x * (-1.0 - eps_m))));
}
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 <= 1.0d0) then
tmp = 0.5d0 * (2.0d0 * (exp(-x) * (x + 1.0d0)))
else
tmp = 0.5d0 * (exp((x * eps_m)) + exp((x * ((-1.0d0) - eps_m))))
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 <= 1.0) {
tmp = 0.5 * (2.0 * (Math.exp(-x) * (x + 1.0)));
} else {
tmp = 0.5 * (Math.exp((x * eps_m)) + Math.exp((x * (-1.0 - eps_m))));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.0: tmp = 0.5 * (2.0 * (math.exp(-x) * (x + 1.0))) else: tmp = 0.5 * (math.exp((x * eps_m)) + math.exp((x * (-1.0 - eps_m)))) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.0) tmp = Float64(0.5 * Float64(2.0 * Float64(exp(Float64(-x)) * Float64(x + 1.0)))); else tmp = Float64(0.5 * Float64(exp(Float64(x * eps_m)) + exp(Float64(x * Float64(-1.0 - eps_m))))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 1.0) tmp = 0.5 * (2.0 * (exp(-x) * (x + 1.0))); else tmp = 0.5 * (exp((x * eps_m)) + exp((x * (-1.0 - eps_m)))); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.0], N[(0.5 * N[(2.0 * N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[N[(x * eps$95$m), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \left(e^{-x} \cdot \left(x + 1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{x \cdot eps\_m} + e^{x \cdot \left(-1 - eps\_m\right)}\right)\\
\end{array}
\end{array}
if eps < 1Initial program 70.9%
Taylor expanded in eps around 0
lower-*.f64N/A
distribute-lft-outN/A
cancel-sign-sub-invN/A
metadata-evalN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f64N/A
distribute-rgt1-inN/A
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f6469.1
Applied rewrites69.1%
if 1 < eps Initial program 100.0%
Taylor expanded in eps around inf
lower-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f64N/A
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps_m)) (exp (* x (+ eps_m -1.0))))
(* (exp (* x (- -1.0 eps_m))) (+ 1.0 (/ -1.0 eps_m))))
2.0000004)
(* 0.5 (* 2.0 (* (exp (- x)) (+ x 1.0))))
(fma
0.5
(*
x
(/
(+
1.0
(+
(* x -0.5)
(fma
eps_m
(fma
x
-0.5
(fma eps_m (fma x -0.5 (fma x eps_m (* 0.5 x))) (* x -0.5)))
(fma 0.5 x -1.0))))
eps_m))
1.0)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if ((((1.0 + (1.0 / eps_m)) * exp((x * (eps_m + -1.0)))) + (exp((x * (-1.0 - eps_m))) * (1.0 + (-1.0 / eps_m)))) <= 2.0000004) {
tmp = 0.5 * (2.0 * (exp(-x) * (x + 1.0)));
} else {
tmp = fma(0.5, (x * ((1.0 + ((x * -0.5) + fma(eps_m, fma(x, -0.5, fma(eps_m, fma(x, -0.5, fma(x, eps_m, (0.5 * x))), (x * -0.5))), fma(0.5, x, -1.0)))) / eps_m)), 1.0);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * exp(Float64(x * Float64(eps_m + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps_m))) * Float64(1.0 + Float64(-1.0 / eps_m)))) <= 2.0000004) tmp = Float64(0.5 * Float64(2.0 * Float64(exp(Float64(-x)) * Float64(x + 1.0)))); else tmp = fma(0.5, Float64(x * Float64(Float64(1.0 + Float64(Float64(x * -0.5) + fma(eps_m, fma(x, -0.5, fma(eps_m, fma(x, -0.5, fma(x, eps_m, Float64(0.5 * x))), Float64(x * -0.5))), fma(0.5, x, -1.0)))) / eps_m)), 1.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0000004], N[(0.5 * N[(2.0 * N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * N[(N[(1.0 + N[(N[(x * -0.5), $MachinePrecision] + N[(eps$95$m * N[(x * -0.5 + N[(eps$95$m * N[(x * -0.5 + N[(x * eps$95$m + N[(0.5 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{eps\_m}\right) \cdot e^{x \cdot \left(eps\_m + -1\right)} + e^{x \cdot \left(-1 - eps\_m\right)} \cdot \left(1 + \frac{-1}{eps\_m}\right) \leq 2.0000004:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \left(e^{-x} \cdot \left(x + 1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, x \cdot \frac{1 + \left(x \cdot -0.5 + \mathsf{fma}\left(eps\_m, \mathsf{fma}\left(x, -0.5, \mathsf{fma}\left(eps\_m, \mathsf{fma}\left(x, -0.5, \mathsf{fma}\left(x, eps\_m, 0.5 \cdot x\right)\right), x \cdot -0.5\right)\right), \mathsf{fma}\left(0.5, x, -1\right)\right)\right)}{eps\_m}, 1\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 2.00000039999999979Initial program 63.6%
Taylor expanded in eps around 0
lower-*.f64N/A
distribute-lft-outN/A
cancel-sign-sub-invN/A
metadata-evalN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f64N/A
distribute-rgt1-inN/A
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f6499.6
Applied rewrites99.6%
if 2.00000039999999979 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 99.1%
Taylor expanded in x around 0
Applied rewrites79.4%
Taylor expanded in eps around 0
Applied rewrites89.9%
Final simplification95.3%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps_m)) (exp (* x (+ eps_m -1.0))))
(* (exp (* x (- -1.0 eps_m))) (+ 1.0 (/ -1.0 eps_m))))
2.0000004)
(exp (- x))
(fma
0.5
(*
x
(/
(+
1.0
(+
(* x -0.5)
(fma
eps_m
(fma
x
-0.5
(fma eps_m (fma x -0.5 (fma x eps_m (* 0.5 x))) (* x -0.5)))
(fma 0.5 x -1.0))))
eps_m))
1.0)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if ((((1.0 + (1.0 / eps_m)) * exp((x * (eps_m + -1.0)))) + (exp((x * (-1.0 - eps_m))) * (1.0 + (-1.0 / eps_m)))) <= 2.0000004) {
tmp = exp(-x);
} else {
tmp = fma(0.5, (x * ((1.0 + ((x * -0.5) + fma(eps_m, fma(x, -0.5, fma(eps_m, fma(x, -0.5, fma(x, eps_m, (0.5 * x))), (x * -0.5))), fma(0.5, x, -1.0)))) / eps_m)), 1.0);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * exp(Float64(x * Float64(eps_m + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps_m))) * Float64(1.0 + Float64(-1.0 / eps_m)))) <= 2.0000004) tmp = exp(Float64(-x)); else tmp = fma(0.5, Float64(x * Float64(Float64(1.0 + Float64(Float64(x * -0.5) + fma(eps_m, fma(x, -0.5, fma(eps_m, fma(x, -0.5, fma(x, eps_m, Float64(0.5 * x))), Float64(x * -0.5))), fma(0.5, x, -1.0)))) / eps_m)), 1.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0000004], N[Exp[(-x)], $MachinePrecision], N[(0.5 * N[(x * N[(N[(1.0 + N[(N[(x * -0.5), $MachinePrecision] + N[(eps$95$m * N[(x * -0.5 + N[(eps$95$m * N[(x * -0.5 + N[(x * eps$95$m + N[(0.5 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{eps\_m}\right) \cdot e^{x \cdot \left(eps\_m + -1\right)} + e^{x \cdot \left(-1 - eps\_m\right)} \cdot \left(1 + \frac{-1}{eps\_m}\right) \leq 2.0000004:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, x \cdot \frac{1 + \left(x \cdot -0.5 + \mathsf{fma}\left(eps\_m, \mathsf{fma}\left(x, -0.5, \mathsf{fma}\left(eps\_m, \mathsf{fma}\left(x, -0.5, \mathsf{fma}\left(x, eps\_m, 0.5 \cdot x\right)\right), x \cdot -0.5\right)\right), \mathsf{fma}\left(0.5, x, -1\right)\right)\right)}{eps\_m}, 1\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 2.00000039999999979Initial program 63.6%
Taylor expanded in eps around inf
lower-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f64N/A
Applied rewrites98.9%
Taylor expanded in eps around 0
distribute-rgt-inN/A
neg-mul-1N/A
distribute-lft-outN/A
metadata-evalN/A
lower-*.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6498.6
Applied rewrites98.6%
lift-neg.f64N/A
lift-exp.f64N/A
*-rgt-identity98.6
Applied rewrites98.6%
if 2.00000039999999979 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 99.1%
Taylor expanded in x around 0
Applied rewrites79.4%
Taylor expanded in eps around 0
Applied rewrites89.9%
Final simplification94.7%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps_m)) (exp (* x (+ eps_m -1.0))))
(* (exp (* x (- -1.0 eps_m))) (+ 1.0 (/ -1.0 eps_m))))
10.0)
1.0
(* 0.25 (* (* eps_m eps_m) (* x x)))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if ((((1.0 + (1.0 / eps_m)) * exp((x * (eps_m + -1.0)))) + (exp((x * (-1.0 - eps_m))) * (1.0 + (-1.0 / eps_m)))) <= 10.0) {
tmp = 1.0;
} else {
tmp = 0.25 * ((eps_m * eps_m) * (x * 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 ((((1.0d0 + (1.0d0 / eps_m)) * exp((x * (eps_m + (-1.0d0))))) + (exp((x * ((-1.0d0) - eps_m))) * (1.0d0 + ((-1.0d0) / eps_m)))) <= 10.0d0) then
tmp = 1.0d0
else
tmp = 0.25d0 * ((eps_m * eps_m) * (x * x))
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if ((((1.0 + (1.0 / eps_m)) * Math.exp((x * (eps_m + -1.0)))) + (Math.exp((x * (-1.0 - eps_m))) * (1.0 + (-1.0 / eps_m)))) <= 10.0) {
tmp = 1.0;
} else {
tmp = 0.25 * ((eps_m * eps_m) * (x * x));
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if (((1.0 + (1.0 / eps_m)) * math.exp((x * (eps_m + -1.0)))) + (math.exp((x * (-1.0 - eps_m))) * (1.0 + (-1.0 / eps_m)))) <= 10.0: tmp = 1.0 else: tmp = 0.25 * ((eps_m * eps_m) * (x * x)) return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * exp(Float64(x * Float64(eps_m + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps_m))) * Float64(1.0 + Float64(-1.0 / eps_m)))) <= 10.0) tmp = 1.0; else tmp = Float64(0.25 * Float64(Float64(eps_m * eps_m) * Float64(x * x))); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if ((((1.0 + (1.0 / eps_m)) * exp((x * (eps_m + -1.0)))) + (exp((x * (-1.0 - eps_m))) * (1.0 + (-1.0 / eps_m)))) <= 10.0) tmp = 1.0; else tmp = 0.25 * ((eps_m * eps_m) * (x * x)); end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 10.0], 1.0, N[(0.25 * N[(N[(eps$95$m * eps$95$m), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{eps\_m}\right) \cdot e^{x \cdot \left(eps\_m + -1\right)} + e^{x \cdot \left(-1 - eps\_m\right)} \cdot \left(1 + \frac{-1}{eps\_m}\right) \leq 10:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\left(eps\_m \cdot eps\_m\right) \cdot \left(x \cdot x\right)\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 10Initial program 64.3%
Taylor expanded in x around 0
Applied rewrites65.3%
if 10 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 99.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate--l+N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-lft1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f6489.0
Applied rewrites89.0%
Taylor expanded in eps around inf
unpow2N/A
*-rgt-identityN/A
metadata-evalN/A
distribute-rgt-outN/A
distribute-rgt-outN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-out--N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f64N/A
Applied rewrites87.3%
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6484.7
Applied rewrites84.7%
Final simplification73.8%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (* 0.5 (+ (exp (fma x eps_m (- x))) (exp (* x (- -1.0 eps_m))))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 0.5 * (exp(fma(x, eps_m, -x)) + exp((x * (-1.0 - eps_m))));
}
eps_m = abs(eps) function code(x, eps_m) return Float64(0.5 * Float64(exp(fma(x, eps_m, Float64(-x))) + exp(Float64(x * Float64(-1.0 - eps_m))))) end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(0.5 * N[(N[Exp[N[(x * eps$95$m + (-x)), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
0.5 \cdot \left(e^{\mathsf{fma}\left(x, eps\_m, -x\right)} + e^{x \cdot \left(-1 - eps\_m\right)}\right)
\end{array}
Initial program 79.5%
Taylor expanded in eps around inf
lower-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f64N/A
Applied rewrites99.0%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 1.0)
(* 0.5 (* 2.0 (* (exp (- x)) (+ x 1.0))))
(/
(+
(*
(+ 1.0 (/ 1.0 eps_m))
(fma x (* (fma (* 0.5 x) (+ eps_m -1.0) 1.0) (+ eps_m -1.0)) 1.0))
(* (exp (* x (- -1.0 eps_m))) (+ 1.0 (/ -1.0 eps_m))))
2.0)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.0) {
tmp = 0.5 * (2.0 * (exp(-x) * (x + 1.0)));
} else {
tmp = (((1.0 + (1.0 / eps_m)) * fma(x, (fma((0.5 * x), (eps_m + -1.0), 1.0) * (eps_m + -1.0)), 1.0)) + (exp((x * (-1.0 - eps_m))) * (1.0 + (-1.0 / eps_m)))) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.0) tmp = Float64(0.5 * Float64(2.0 * Float64(exp(Float64(-x)) * Float64(x + 1.0)))); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps_m)) * fma(x, Float64(fma(Float64(0.5 * x), Float64(eps_m + -1.0), 1.0) * Float64(eps_m + -1.0)), 1.0)) + Float64(exp(Float64(x * Float64(-1.0 - eps_m))) * Float64(1.0 + Float64(-1.0 / eps_m)))) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.0], N[(0.5 * N[(2.0 * N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 + N[(1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision] * N[(x * N[(N[(N[(0.5 * x), $MachinePrecision] * N[(eps$95$m + -1.0), $MachinePrecision] + 1.0), $MachinePrecision] * N[(eps$95$m + -1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \left(e^{-x} \cdot \left(x + 1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{eps\_m}\right) \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(0.5 \cdot x, eps\_m + -1, 1\right) \cdot \left(eps\_m + -1\right), 1\right) + e^{x \cdot \left(-1 - eps\_m\right)} \cdot \left(1 + \frac{-1}{eps\_m}\right)}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 70.9%
Taylor expanded in eps around 0
lower-*.f64N/A
distribute-lft-outN/A
cancel-sign-sub-invN/A
metadata-evalN/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f64N/A
distribute-rgt1-inN/A
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f6469.1
Applied rewrites69.1%
if 1 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate--l+N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-lft1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f6490.9
Applied rewrites90.9%
Final simplification75.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 720.0)
(fma
0.5
(*
x
(/
(+
1.0
(+
(* x -0.5)
(fma
eps_m
(fma
x
-0.5
(fma eps_m (fma x -0.5 (fma x eps_m (* 0.5 x))) (* x -0.5)))
(fma 0.5 x -1.0))))
eps_m))
1.0)
(* 0.5 (* x (* x (* eps_m eps_m))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 720.0) {
tmp = fma(0.5, (x * ((1.0 + ((x * -0.5) + fma(eps_m, fma(x, -0.5, fma(eps_m, fma(x, -0.5, fma(x, eps_m, (0.5 * x))), (x * -0.5))), fma(0.5, x, -1.0)))) / eps_m)), 1.0);
} else {
tmp = 0.5 * (x * (x * (eps_m * eps_m)));
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 720.0) tmp = fma(0.5, Float64(x * Float64(Float64(1.0 + Float64(Float64(x * -0.5) + fma(eps_m, fma(x, -0.5, fma(eps_m, fma(x, -0.5, fma(x, eps_m, Float64(0.5 * x))), Float64(x * -0.5))), fma(0.5, x, -1.0)))) / eps_m)), 1.0); else tmp = Float64(0.5 * Float64(x * Float64(x * Float64(eps_m * eps_m)))); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 720.0], N[(0.5 * N[(x * N[(N[(1.0 + N[(N[(x * -0.5), $MachinePrecision] + N[(eps$95$m * N[(x * -0.5 + N[(eps$95$m * N[(x * -0.5 + N[(x * eps$95$m + N[(0.5 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / eps$95$m), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(0.5 * N[(x * N[(x * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 720:\\
\;\;\;\;\mathsf{fma}\left(0.5, x \cdot \frac{1 + \left(x \cdot -0.5 + \mathsf{fma}\left(eps\_m, \mathsf{fma}\left(x, -0.5, \mathsf{fma}\left(eps\_m, \mathsf{fma}\left(x, -0.5, \mathsf{fma}\left(x, eps\_m, 0.5 \cdot x\right)\right), x \cdot -0.5\right)\right), \mathsf{fma}\left(0.5, x, -1\right)\right)\right)}{eps\_m}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \left(x \cdot \left(eps\_m \cdot eps\_m\right)\right)\right)\\
\end{array}
\end{array}
if x < 720Initial program 70.1%
Taylor expanded in x around 0
Applied rewrites86.2%
Taylor expanded in eps around 0
Applied rewrites89.8%
if 720 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.7%
Taylor expanded in eps around inf
Applied rewrites40.7%
Taylor expanded in eps around inf
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6471.3
Applied rewrites71.3%
Final simplification84.0%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -1.75e-85)
(* 0.5 (* x (* x (fma eps_m eps_m eps_m))))
(if (<= x 1.45e-45)
(fma (* x x) (fma eps_m 0.5 0.25) 1.0)
(* 0.5 (* x (* x (* eps_m eps_m)))))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.75e-85) {
tmp = 0.5 * (x * (x * fma(eps_m, eps_m, eps_m)));
} else if (x <= 1.45e-45) {
tmp = fma((x * x), fma(eps_m, 0.5, 0.25), 1.0);
} else {
tmp = 0.5 * (x * (x * (eps_m * eps_m)));
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.75e-85) tmp = Float64(0.5 * Float64(x * Float64(x * fma(eps_m, eps_m, eps_m)))); elseif (x <= 1.45e-45) tmp = fma(Float64(x * x), fma(eps_m, 0.5, 0.25), 1.0); else tmp = Float64(0.5 * Float64(x * Float64(x * Float64(eps_m * eps_m)))); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.75e-85], N[(0.5 * N[(x * N[(x * N[(eps$95$m * eps$95$m + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-45], N[(N[(x * x), $MachinePrecision] * N[(eps$95$m * 0.5 + 0.25), $MachinePrecision] + 1.0), $MachinePrecision], N[(0.5 * N[(x * N[(x * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{-85}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \left(x \cdot \mathsf{fma}\left(eps\_m, eps\_m, eps\_m\right)\right)\right)\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-45}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(eps\_m, 0.5, 0.25\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \left(x \cdot \left(eps\_m \cdot eps\_m\right)\right)\right)\\
\end{array}
\end{array}
if x < -1.74999999999999989e-85Initial program 92.3%
Taylor expanded in x around 0
Applied rewrites80.6%
Taylor expanded in eps around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6478.6
Applied rewrites78.6%
Taylor expanded in eps around inf
Applied rewrites84.3%
Taylor expanded in x around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
unpow2N/A
unpow2N/A
Applied rewrites75.9%
if -1.74999999999999989e-85 < x < 1.45e-45Initial program 54.0%
Taylor expanded in x around 0
Applied rewrites93.2%
Taylor expanded in eps around inf
Applied rewrites93.2%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
lower-+.f6492.4
Applied rewrites92.4%
Taylor expanded in eps around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6485.5
Applied rewrites85.5%
if 1.45e-45 < x Initial program 97.9%
Taylor expanded in x around 0
Applied rewrites43.3%
Taylor expanded in eps around inf
Applied rewrites42.8%
Taylor expanded in eps around inf
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6469.2
Applied rewrites69.2%
Final simplification77.1%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (* 0.5 (* x (* x (* eps_m eps_m))))))
(if (<= x -1.75e-85)
t_0
(if (<= x 1.45e-45) (fma (* x x) (fma eps_m 0.5 0.25) 1.0) t_0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = 0.5 * (x * (x * (eps_m * eps_m)));
double tmp;
if (x <= -1.75e-85) {
tmp = t_0;
} else if (x <= 1.45e-45) {
tmp = fma((x * x), fma(eps_m, 0.5, 0.25), 1.0);
} else {
tmp = t_0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(0.5 * Float64(x * Float64(x * Float64(eps_m * eps_m)))) tmp = 0.0 if (x <= -1.75e-85) tmp = t_0; elseif (x <= 1.45e-45) tmp = fma(Float64(x * x), fma(eps_m, 0.5, 0.25), 1.0); else tmp = t_0; end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(0.5 * N[(x * N[(x * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.75e-85], t$95$0, If[LessEqual[x, 1.45e-45], N[(N[(x * x), $MachinePrecision] * N[(eps$95$m * 0.5 + 0.25), $MachinePrecision] + 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(x \cdot \left(x \cdot \left(eps\_m \cdot eps\_m\right)\right)\right)\\
\mathbf{if}\;x \leq -1.75 \cdot 10^{-85}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-45}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(eps\_m, 0.5, 0.25\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.74999999999999989e-85 or 1.45e-45 < x Initial program 95.7%
Taylor expanded in x around 0
Applied rewrites58.3%
Taylor expanded in eps around inf
Applied rewrites57.2%
Taylor expanded in eps around inf
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6471.9
Applied rewrites71.9%
if -1.74999999999999989e-85 < x < 1.45e-45Initial program 54.0%
Taylor expanded in x around 0
Applied rewrites93.2%
Taylor expanded in eps around inf
Applied rewrites93.2%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
lower-+.f6492.4
Applied rewrites92.4%
Taylor expanded in eps around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6485.5
Applied rewrites85.5%
Final simplification77.1%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x -1.75e-85)
(* 0.25 (* (* eps_m eps_m) (* x x)))
(if (<= x 1.45e-45)
(fma (* x x) (fma eps_m 0.5 0.25) 1.0)
(* (* x (* x (* eps_m eps_m))) 0.25))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -1.75e-85) {
tmp = 0.25 * ((eps_m * eps_m) * (x * x));
} else if (x <= 1.45e-45) {
tmp = fma((x * x), fma(eps_m, 0.5, 0.25), 1.0);
} else {
tmp = (x * (x * (eps_m * eps_m))) * 0.25;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -1.75e-85) tmp = Float64(0.25 * Float64(Float64(eps_m * eps_m) * Float64(x * x))); elseif (x <= 1.45e-45) tmp = fma(Float64(x * x), fma(eps_m, 0.5, 0.25), 1.0); else tmp = Float64(Float64(x * Float64(x * Float64(eps_m * eps_m))) * 0.25); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -1.75e-85], N[(0.25 * N[(N[(eps$95$m * eps$95$m), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-45], N[(N[(x * x), $MachinePrecision] * N[(eps$95$m * 0.5 + 0.25), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x * N[(x * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{-85}:\\
\;\;\;\;0.25 \cdot \left(\left(eps\_m \cdot eps\_m\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-45}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(eps\_m, 0.5, 0.25\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(x \cdot \left(eps\_m \cdot eps\_m\right)\right)\right) \cdot 0.25\\
\end{array}
\end{array}
if x < -1.74999999999999989e-85Initial program 92.3%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate--l+N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-lft1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f6485.7
Applied rewrites85.7%
Taylor expanded in eps around inf
unpow2N/A
*-rgt-identityN/A
metadata-evalN/A
distribute-rgt-outN/A
distribute-rgt-outN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-out--N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f64N/A
Applied rewrites76.0%
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6476.0
Applied rewrites76.0%
if -1.74999999999999989e-85 < x < 1.45e-45Initial program 54.0%
Taylor expanded in x around 0
Applied rewrites93.2%
Taylor expanded in eps around inf
Applied rewrites93.2%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
lower-+.f6492.4
Applied rewrites92.4%
Taylor expanded in eps around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6485.5
Applied rewrites85.5%
if 1.45e-45 < x Initial program 97.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate--l+N/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-lft1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f6442.8
Applied rewrites42.8%
Taylor expanded in eps around inf
unpow2N/A
*-rgt-identityN/A
metadata-evalN/A
distribute-rgt-outN/A
distribute-rgt-outN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-out--N/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f64N/A
Applied rewrites69.2%
Final simplification77.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (let* ((t_0 (* x (* x (* eps_m eps_m))))) (if (<= x 29.0) (fma 0.5 t_0 1.0) (* 0.5 t_0))))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = x * (x * (eps_m * eps_m));
double tmp;
if (x <= 29.0) {
tmp = fma(0.5, t_0, 1.0);
} else {
tmp = 0.5 * t_0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(x * Float64(x * Float64(eps_m * eps_m))) tmp = 0.0 if (x <= 29.0) tmp = fma(0.5, t_0, 1.0); else tmp = Float64(0.5 * t_0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(x * N[(x * N[(eps$95$m * eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 29.0], N[(0.5 * t$95$0 + 1.0), $MachinePrecision], N[(0.5 * t$95$0), $MachinePrecision]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \left(eps\_m \cdot eps\_m\right)\right)\\
\mathbf{if}\;x \leq 29:\\
\;\;\;\;\mathsf{fma}\left(0.5, t\_0, 1\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot t\_0\\
\end{array}
\end{array}
if x < 29Initial program 69.9%
Taylor expanded in x around 0
Applied rewrites86.7%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.0
Applied rewrites87.0%
if 29 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites40.2%
Taylor expanded in eps around inf
Applied rewrites40.2%
Taylor expanded in eps around inf
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-outN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6470.5
Applied rewrites70.5%
Final simplification81.7%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (fma (* x x) (fma eps_m 0.5 0.25) 1.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return fma((x * x), fma(eps_m, 0.5, 0.25), 1.0);
}
eps_m = abs(eps) function code(x, eps_m) return fma(Float64(x * x), fma(eps_m, 0.5, 0.25), 1.0) end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(x * x), $MachinePrecision] * N[(eps$95$m * 0.5 + 0.25), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(eps\_m, 0.5, 0.25\right), 1\right)
\end{array}
Initial program 79.5%
Taylor expanded in x around 0
Applied rewrites71.8%
Taylor expanded in eps around inf
Applied rewrites71.2%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
lower-+.f6471.5
Applied rewrites71.5%
Taylor expanded in eps around 0
+-commutativeN/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6449.3
Applied rewrites49.3%
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.7%
Taylor expanded in x around 0
Applied rewrites91.5%
Taylor expanded in eps around 0
Applied rewrites28.8%
Taylor expanded in eps around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6428.8
Applied rewrites28.8%
if -1 < x Initial program 75.8%
Taylor expanded in x around 0
Applied rewrites45.3%
Final simplification42.5%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (fma x (* x 0.25) 1.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return fma(x, (x * 0.25), 1.0);
}
eps_m = abs(eps) function code(x, eps_m) return fma(x, Float64(x * 0.25), 1.0) end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(x * N[(x * 0.25), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\mathsf{fma}\left(x, x \cdot 0.25, 1\right)
\end{array}
Initial program 79.5%
Taylor expanded in x around 0
Applied rewrites71.8%
Taylor expanded in eps around inf
Applied rewrites71.2%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
lower-+.f6471.5
Applied rewrites71.5%
Taylor expanded in eps around 0
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6455.2
Applied rewrites55.2%
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 79.5%
Taylor expanded in x around 0
Applied rewrites38.1%
herbie shell --seed 2024219
(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))