
(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}
(FPCore (x eps)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))
0.0)
(* 0.5 (* (exp (- x)) (+ x (+ x 2.0))))
(* 0.5 (+ (exp (* eps x)) (exp (* eps (- x)))))))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0) {
tmp = 0.5 * (exp(-x) * (x + (x + 2.0)));
} else {
tmp = 0.5 * (exp((eps * x)) + exp((eps * -x)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((((1.0d0 + (1.0d0 / eps)) * exp((x * (eps + (-1.0d0))))) + (exp((x * ((-1.0d0) - eps))) * (1.0d0 + ((-1.0d0) / eps)))) <= 0.0d0) then
tmp = 0.5d0 * (exp(-x) * (x + (x + 2.0d0)))
else
tmp = 0.5d0 * (exp((eps * x)) + exp((eps * -x)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * Math.exp((x * (eps + -1.0)))) + (Math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0) {
tmp = 0.5 * (Math.exp(-x) * (x + (x + 2.0)));
} else {
tmp = 0.5 * (Math.exp((eps * x)) + Math.exp((eps * -x)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (((1.0 + (1.0 / eps)) * math.exp((x * (eps + -1.0)))) + (math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0: tmp = 0.5 * (math.exp(-x) * (x + (x + 2.0))) else: tmp = 0.5 * (math.exp((eps * x)) + math.exp((eps * -x))) return tmp
function code(x, eps) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 0.0) tmp = Float64(0.5 * Float64(exp(Float64(-x)) * Float64(x + Float64(x + 2.0)))); else tmp = Float64(0.5 * Float64(exp(Float64(eps * x)) + exp(Float64(eps * Float64(-x))))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0) tmp = 0.5 * (exp(-x) * (x + (x + 2.0))); else tmp = 0.5 * (exp((eps * x)) + exp((eps * -x))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] * N[(x + N[(x + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(eps * (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 0:\\
\;\;\;\;0.5 \cdot \left(e^{-x} \cdot \left(x + \left(x + 2\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{\varepsilon \cdot x} + e^{\varepsilon \cdot \left(-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))))) < 0.0Initial program 33.8%
Taylor expanded in eps around 0
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
distribute-rgt1-inN/A
distribute-rgt-out--N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites100.0%
if 0.0 < (-.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 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
Applied rewrites100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))
2.005)
(* 0.5 (* (exp (- x)) (+ x (+ x 2.0))))
(fma x (* 0.5 (* x (* eps eps))) 1.0)))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 2.005) {
tmp = 0.5 * (exp(-x) * (x + (x + 2.0)));
} else {
tmp = fma(x, (0.5 * (x * (eps * eps))), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 2.005) tmp = Float64(0.5 * Float64(exp(Float64(-x)) * Float64(x + Float64(x + 2.0)))); else tmp = fma(x, Float64(0.5 * Float64(x * Float64(eps * eps))), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.005], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] * N[(x + N[(x + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(0.5 * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 2.005:\\
\;\;\;\;0.5 \cdot \left(e^{-x} \cdot \left(x + \left(x + 2\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 0.5 \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\right), 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.0049999999999999Initial program 53.6%
Taylor expanded in eps around 0
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
distribute-rgt1-inN/A
distribute-rgt-out--N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites99.6%
if 2.0049999999999999 < (-.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 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 x around 0
Applied rewrites85.2%
Taylor expanded in eps around inf
Applied rewrites85.2%
Final simplification93.3%
(FPCore (x eps)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))
2.005)
(exp (- x))
(fma x (* 0.5 (* x (* eps eps))) 1.0)))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 2.005) {
tmp = exp(-x);
} else {
tmp = fma(x, (0.5 * (x * (eps * eps))), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 2.005) tmp = exp(Float64(-x)); else tmp = fma(x, Float64(0.5 * Float64(x * Float64(eps * eps))), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.005], N[Exp[(-x)], $MachinePrecision], N[(x * N[(0.5 * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 2.005:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 0.5 \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\right), 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.0049999999999999Initial program 53.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 rewrites99.2%
Taylor expanded in eps around 0
Applied rewrites98.9%
if 2.0049999999999999 < (-.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 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 x around 0
Applied rewrites85.2%
Taylor expanded in eps around inf
Applied rewrites85.2%
Final simplification92.9%
(FPCore (x eps)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))
4.0)
1.0
(* eps (* eps (* x (* x 0.5))))))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0) {
tmp = 1.0;
} else {
tmp = eps * (eps * (x * (x * 0.5)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((((1.0d0 + (1.0d0 / eps)) * exp((x * (eps + (-1.0d0))))) + (exp((x * ((-1.0d0) - eps))) * (1.0d0 + ((-1.0d0) / eps)))) <= 4.0d0) then
tmp = 1.0d0
else
tmp = eps * (eps * (x * (x * 0.5d0)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * Math.exp((x * (eps + -1.0)))) + (Math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0) {
tmp = 1.0;
} else {
tmp = eps * (eps * (x * (x * 0.5)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (((1.0 + (1.0 / eps)) * math.exp((x * (eps + -1.0)))) + (math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0: tmp = 1.0 else: tmp = eps * (eps * (x * (x * 0.5))) return tmp
function code(x, eps) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 4.0) tmp = 1.0; else tmp = Float64(eps * Float64(eps * Float64(x * Float64(x * 0.5)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0) tmp = 1.0; else tmp = eps * (eps * (x * (x * 0.5))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0], 1.0, N[(eps * N[(eps * N[(x * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 4:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot \left(x \cdot \left(x \cdot 0.5\right)\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))))) < 4Initial program 53.9%
Taylor expanded in x around 0
Applied rewrites77.1%
if 4 < (-.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 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 x around 0
Applied rewrites85.6%
Taylor expanded in eps around inf
Applied rewrites61.4%
Final simplification70.3%
(FPCore (x eps) :precision binary64 (* 0.5 (+ (exp (- (* eps x) x)) (exp (* x (- -1.0 eps))))))
double code(double x, double eps) {
return 0.5 * (exp(((eps * x) - x)) + exp((x * (-1.0 - eps))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.5d0 * (exp(((eps * x) - x)) + exp((x * ((-1.0d0) - eps))))
end function
public static double code(double x, double eps) {
return 0.5 * (Math.exp(((eps * x) - x)) + Math.exp((x * (-1.0 - eps))));
}
def code(x, eps): return 0.5 * (math.exp(((eps * x) - x)) + math.exp((x * (-1.0 - eps))))
function code(x, eps) return Float64(0.5 * Float64(exp(Float64(Float64(eps * x) - x)) + exp(Float64(x * Float64(-1.0 - eps))))) end
function tmp = code(x, eps) tmp = 0.5 * (exp(((eps * x) - x)) + exp((x * (-1.0 - eps)))); end
code[x_, eps_] := N[(0.5 * N[(N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(e^{\varepsilon \cdot x - x} + e^{x \cdot \left(-1 - \varepsilon\right)}\right)
\end{array}
Initial program 73.9%
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.6%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(if (<= eps 2.8e-5)
(* 0.5 (* (exp (- x)) (+ x (+ x 2.0))))
(if (<= eps 3.5e+162)
(*
0.5
(+
(exp (* eps x))
(fma x (* (+ 1.0 eps) (fma (* x 0.5) (+ 1.0 eps) -1.0)) 1.0)))
(fma x (* 0.5 (* x (* eps eps))) 1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 2.8e-5) {
tmp = 0.5 * (exp(-x) * (x + (x + 2.0)));
} else if (eps <= 3.5e+162) {
tmp = 0.5 * (exp((eps * x)) + fma(x, ((1.0 + eps) * fma((x * 0.5), (1.0 + eps), -1.0)), 1.0));
} else {
tmp = fma(x, (0.5 * (x * (eps * eps))), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 2.8e-5) tmp = Float64(0.5 * Float64(exp(Float64(-x)) * Float64(x + Float64(x + 2.0)))); elseif (eps <= 3.5e+162) tmp = Float64(0.5 * Float64(exp(Float64(eps * x)) + fma(x, Float64(Float64(1.0 + eps) * fma(Float64(x * 0.5), Float64(1.0 + eps), -1.0)), 1.0))); else tmp = fma(x, Float64(0.5 * Float64(x * Float64(eps * eps))), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 2.8e-5], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] * N[(x + N[(x + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.5e+162], N[(0.5 * N[(N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision] + N[(x * N[(N[(1.0 + eps), $MachinePrecision] * N[(N[(x * 0.5), $MachinePrecision] * N[(1.0 + eps), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(0.5 * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 2.8 \cdot 10^{-5}:\\
\;\;\;\;0.5 \cdot \left(e^{-x} \cdot \left(x + \left(x + 2\right)\right)\right)\\
\mathbf{elif}\;\varepsilon \leq 3.5 \cdot 10^{+162}:\\
\;\;\;\;0.5 \cdot \left(e^{\varepsilon \cdot x} + \mathsf{fma}\left(x, \left(1 + \varepsilon\right) \cdot \mathsf{fma}\left(x \cdot 0.5, 1 + \varepsilon, -1\right), 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 0.5 \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\right), 1\right)\\
\end{array}
\end{array}
if eps < 2.79999999999999996e-5Initial program 64.8%
Taylor expanded in eps around 0
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
distribute-rgt1-inN/A
distribute-rgt-out--N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites67.5%
if 2.79999999999999996e-5 < eps < 3.50000000000000018e162Initial 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
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites87.6%
if 3.50000000000000018e162 < 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 x around 0
Applied rewrites97.3%
Taylor expanded in eps around inf
Applied rewrites97.3%
Final simplification74.0%
(FPCore (x eps)
:precision binary64
(if (<= x -6.2e-70)
(*
0.5
(+
1.0
(fma
x
(fma
x
(*
(* (- -1.0 eps) (- -1.0 eps))
(fma (* x -0.16666666666666666) (+ 1.0 eps) 0.5))
(- -1.0 eps))
1.0)))
(if (<= x 310.0)
(fma x (* 0.5 (* x (* eps eps))) 1.0)
(* eps (* eps (* x (* x 0.5)))))))
double code(double x, double eps) {
double tmp;
if (x <= -6.2e-70) {
tmp = 0.5 * (1.0 + fma(x, fma(x, (((-1.0 - eps) * (-1.0 - eps)) * fma((x * -0.16666666666666666), (1.0 + eps), 0.5)), (-1.0 - eps)), 1.0));
} else if (x <= 310.0) {
tmp = fma(x, (0.5 * (x * (eps * eps))), 1.0);
} else {
tmp = eps * (eps * (x * (x * 0.5)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -6.2e-70) tmp = Float64(0.5 * Float64(1.0 + fma(x, fma(x, Float64(Float64(Float64(-1.0 - eps) * Float64(-1.0 - eps)) * fma(Float64(x * -0.16666666666666666), Float64(1.0 + eps), 0.5)), Float64(-1.0 - eps)), 1.0))); elseif (x <= 310.0) tmp = fma(x, Float64(0.5 * Float64(x * Float64(eps * eps))), 1.0); else tmp = Float64(eps * Float64(eps * Float64(x * Float64(x * 0.5)))); end return tmp end
code[x_, eps_] := If[LessEqual[x, -6.2e-70], N[(0.5 * N[(1.0 + N[(x * N[(x * N[(N[(N[(-1.0 - eps), $MachinePrecision] * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision] * N[(N[(x * -0.16666666666666666), $MachinePrecision] * N[(1.0 + eps), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 310.0], N[(x * N[(0.5 * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(eps * N[(eps * N[(x * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{-70}:\\
\;\;\;\;0.5 \cdot \left(1 + \mathsf{fma}\left(x, \mathsf{fma}\left(x, \left(\left(-1 - \varepsilon\right) \cdot \left(-1 - \varepsilon\right)\right) \cdot \mathsf{fma}\left(x \cdot -0.16666666666666666, 1 + \varepsilon, 0.5\right), -1 - \varepsilon\right), 1\right)\right)\\
\mathbf{elif}\;x \leq 310:\\
\;\;\;\;\mathsf{fma}\left(x, 0.5 \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot \left(x \cdot \left(x \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if x < -6.2e-70Initial program 88.4%
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 x around 0
Applied rewrites47.7%
Taylor expanded in x around 0
Applied rewrites44.1%
if -6.2e-70 < x < 310Initial program 56.7%
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.2%
Taylor expanded in x around 0
Applied rewrites91.9%
Taylor expanded in eps around inf
Applied rewrites92.1%
if 310 < x 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 x around 0
Applied rewrites47.4%
Taylor expanded in eps around inf
Applied rewrites55.9%
Final simplification73.5%
(FPCore (x eps) :precision binary64 (if (<= x -0.85) (* x (* -0.16666666666666666 (* x x))) (if (<= x 1.6e+20) 1.0 (* x (fma x (fma 0.5 x -1.0) 1.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -0.85) {
tmp = x * (-0.16666666666666666 * (x * x));
} else if (x <= 1.6e+20) {
tmp = 1.0;
} else {
tmp = x * fma(x, fma(0.5, x, -1.0), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -0.85) tmp = Float64(x * Float64(-0.16666666666666666 * Float64(x * x))); elseif (x <= 1.6e+20) tmp = 1.0; else tmp = Float64(x * fma(x, fma(0.5, x, -1.0), 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[x, -0.85], N[(x * N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e+20], 1.0, N[(x * N[(x * N[(0.5 * x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.85:\\
\;\;\;\;x \cdot \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+20}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(0.5, x, -1\right), 1\right)\\
\end{array}
\end{array}
if x < -0.849999999999999978Initial 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 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites58.1%
Taylor expanded in x around inf
Applied rewrites58.1%
if -0.849999999999999978 < x < 1.6e20Initial program 59.0%
Taylor expanded in x around 0
Applied rewrites69.0%
if 1.6e20 < x Initial program 100.0%
Taylor expanded in eps around 0
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
distribute-rgt1-inN/A
distribute-rgt-out--N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites48.3%
Taylor expanded in x around inf
Applied rewrites48.3%
Taylor expanded in x around 0
Applied rewrites42.0%
Final simplification61.3%
(FPCore (x eps) :precision binary64 (if (<= x 310.0) (fma x (* 0.5 (* x (* eps eps))) 1.0) (* eps (* eps (* x (* x 0.5))))))
double code(double x, double eps) {
double tmp;
if (x <= 310.0) {
tmp = fma(x, (0.5 * (x * (eps * eps))), 1.0);
} else {
tmp = eps * (eps * (x * (x * 0.5)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 310.0) tmp = fma(x, Float64(0.5 * Float64(x * Float64(eps * eps))), 1.0); else tmp = Float64(eps * Float64(eps * Float64(x * Float64(x * 0.5)))); end return tmp end
code[x_, eps_] := If[LessEqual[x, 310.0], N[(x * N[(0.5 * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(eps * N[(eps * N[(x * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 310:\\
\;\;\;\;\mathsf{fma}\left(x, 0.5 \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot \left(x \cdot \left(x \cdot 0.5\right)\right)\right)\\
\end{array}
\end{array}
if x < 310Initial program 65.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 rewrites99.4%
Taylor expanded in x around 0
Applied rewrites89.6%
Taylor expanded in eps around inf
Applied rewrites89.8%
if 310 < x 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 x around 0
Applied rewrites47.4%
Taylor expanded in eps around inf
Applied rewrites55.9%
Final simplification81.2%
(FPCore (x eps) :precision binary64 (if (<= x -0.00062) (fma x (fma x (fma x -0.16666666666666666 0.5) -1.0) 1.0) (fma (* x x) (fma x 0.3333333333333333 -0.5) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -0.00062) {
tmp = fma(x, fma(x, fma(x, -0.16666666666666666, 0.5), -1.0), 1.0);
} else {
tmp = fma((x * x), fma(x, 0.3333333333333333, -0.5), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -0.00062) tmp = fma(x, fma(x, fma(x, -0.16666666666666666, 0.5), -1.0), 1.0); else tmp = fma(Float64(x * x), fma(x, 0.3333333333333333, -0.5), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -0.00062], N[(x * N[(x * N[(x * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(x * 0.3333333333333333 + -0.5), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00062:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.16666666666666666, 0.5\right), -1\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, 0.3333333333333333, -0.5\right), 1\right)\\
\end{array}
\end{array}
if x < -6.2e-4Initial 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 0
Applied rewrites97.2%
Taylor expanded in x around 0
Applied rewrites56.6%
if -6.2e-4 < x Initial program 69.8%
Taylor expanded in eps around 0
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
distribute-rgt1-inN/A
distribute-rgt-out--N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites65.9%
Taylor expanded in x around 0
Applied rewrites62.0%
(FPCore (x eps) :precision binary64 (if (<= x -0.00062) (fma x (fma x (* x -0.16666666666666666) -1.0) 1.0) (fma (* x x) (fma x 0.3333333333333333 -0.5) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -0.00062) {
tmp = fma(x, fma(x, (x * -0.16666666666666666), -1.0), 1.0);
} else {
tmp = fma((x * x), fma(x, 0.3333333333333333, -0.5), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -0.00062) tmp = fma(x, fma(x, Float64(x * -0.16666666666666666), -1.0), 1.0); else tmp = fma(Float64(x * x), fma(x, 0.3333333333333333, -0.5), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -0.00062], N[(x * N[(x * N[(x * -0.16666666666666666), $MachinePrecision] + -1.0), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(x * 0.3333333333333333 + -0.5), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00062:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, x \cdot -0.16666666666666666, -1\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, 0.3333333333333333, -0.5\right), 1\right)\\
\end{array}
\end{array}
if x < -6.2e-4Initial 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 0
Applied rewrites97.2%
Taylor expanded in x around 0
Applied rewrites56.6%
Taylor expanded in x around inf
Applied rewrites56.6%
if -6.2e-4 < x Initial program 69.8%
Taylor expanded in eps around 0
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
distribute-rgt1-inN/A
distribute-rgt-out--N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites65.9%
Taylor expanded in x around 0
Applied rewrites62.0%
(FPCore (x eps) :precision binary64 (if (<= x -440.0) (* x (* -0.16666666666666666 (* x x))) (fma (* x x) (fma x 0.3333333333333333 -0.5) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -440.0) {
tmp = x * (-0.16666666666666666 * (x * x));
} else {
tmp = fma((x * x), fma(x, 0.3333333333333333, -0.5), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -440.0) tmp = Float64(x * Float64(-0.16666666666666666 * Float64(x * x))); else tmp = fma(Float64(x * x), fma(x, 0.3333333333333333, -0.5), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -440.0], N[(x * N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(x * 0.3333333333333333 + -0.5), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -440:\\
\;\;\;\;x \cdot \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, 0.3333333333333333, -0.5\right), 1\right)\\
\end{array}
\end{array}
if x < -440Initial 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 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites58.1%
Taylor expanded in x around inf
Applied rewrites58.1%
if -440 < x Initial program 69.9%
Taylor expanded in eps around 0
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
distribute-rgt1-inN/A
distribute-rgt-out--N/A
*-commutativeN/A
distribute-lft-outN/A
lower-*.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-+.f64N/A
Applied rewrites65.6%
Taylor expanded in x around 0
Applied rewrites61.8%
Final simplification61.3%
(FPCore (x eps) :precision binary64 (if (<= x -4.5) (* x (* -0.16666666666666666 (* x x))) (fma x (fma 0.5 x -1.0) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -4.5) {
tmp = x * (-0.16666666666666666 * (x * x));
} else {
tmp = fma(x, fma(0.5, x, -1.0), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -4.5) tmp = Float64(x * Float64(-0.16666666666666666 * Float64(x * x))); else tmp = fma(x, fma(0.5, x, -1.0), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -4.5], N[(x * N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(0.5 * x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.5:\\
\;\;\;\;x \cdot \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(0.5, x, -1\right), 1\right)\\
\end{array}
\end{array}
if x < -4.5Initial 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 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites58.1%
Taylor expanded in x around inf
Applied rewrites58.1%
if -4.5 < x Initial program 69.9%
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.5%
Taylor expanded in eps around 0
Applied rewrites65.1%
Taylor expanded in x around 0
Applied rewrites58.8%
Final simplification58.7%
(FPCore (x eps) :precision binary64 (fma x (fma 0.5 x -1.0) 1.0))
double code(double x, double eps) {
return fma(x, fma(0.5, x, -1.0), 1.0);
}
function code(x, eps) return fma(x, fma(0.5, x, -1.0), 1.0) end
code[x_, eps_] := N[(x * N[(0.5 * x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \mathsf{fma}\left(0.5, x, -1\right), 1\right)
\end{array}
Initial program 73.9%
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.6%
Taylor expanded in eps around 0
Applied rewrites69.7%
Taylor expanded in x around 0
Applied rewrites56.5%
(FPCore (x eps) :precision binary64 1.0)
double code(double x, double eps) {
return 1.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0
end function
public static double code(double x, double eps) {
return 1.0;
}
def code(x, eps): return 1.0
function code(x, eps) return 1.0 end
function tmp = code(x, eps) tmp = 1.0; end
code[x_, eps_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 73.9%
Taylor expanded in x around 0
Applied rewrites45.0%
herbie shell --seed 2024233
(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))