
(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 16 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 (- (fma x eps x))) (exp (* x eps))))))
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(-fma(x, eps, x)) + exp((x * eps)));
}
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(-fma(x, eps, x))) + exp(Float64(x * eps)))); 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], 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[(x * eps + x), $MachinePrecision])], $MachinePrecision] + N[Exp[N[(x * eps), $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^{-\mathsf{fma}\left(x, \varepsilon, x\right)} + e^{x \cdot \varepsilon}\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 31.1%
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
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
*-commutativeN/A
lower-*.f64100.0
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.05)
(* 0.5 (* (exp (- x)) (+ x (+ x 2.0))))
(*
0.5
(+
(exp (- (* x eps) x))
(fma x (fma x (* (+ eps 1.0) (fma 0.5 eps 0.5)) (- -1.0 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.05) {
tmp = 0.5 * (exp(-x) * (x + (x + 2.0)));
} else {
tmp = 0.5 * (exp(((x * eps) - x)) + fma(x, fma(x, ((eps + 1.0) * fma(0.5, eps, 0.5)), (-1.0 - 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.05) tmp = Float64(0.5 * Float64(exp(Float64(-x)) * Float64(x + Float64(x + 2.0)))); else tmp = Float64(0.5 * Float64(exp(Float64(Float64(x * eps) - x)) + fma(x, fma(x, Float64(Float64(eps + 1.0) * fma(0.5, eps, 0.5)), Float64(-1.0 - 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.05], 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[(N[(x * eps), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[(x * N[(x * N[(N[(eps + 1.0), $MachinePrecision] * N[(0.5 * eps + 0.5), $MachinePrecision]), $MachinePrecision] + N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision] + 1.0), $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 2.05:\\
\;\;\;\;0.5 \cdot \left(e^{-x} \cdot \left(x + \left(x + 2\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{x \cdot \varepsilon - x} + \mathsf{fma}\left(x, \mathsf{fma}\left(x, \left(\varepsilon + 1\right) \cdot \mathsf{fma}\left(0.5, \varepsilon, 0.5\right), -1 - \varepsilon\right), 1\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))))) < 2.0499999999999998Initial program 51.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
Applied rewrites99.7%
if 2.0499999999999998 < (-.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
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites89.1%
Final simplification95.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.05)
(* 0.5 (* (exp (- x)) (+ x (+ x 2.0))))
(fma (* 0.5 x) (* 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.05) {
tmp = 0.5 * (exp(-x) * (x + (x + 2.0)));
} else {
tmp = fma((0.5 * x), (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.05) tmp = Float64(0.5 * Float64(exp(Float64(-x)) * Float64(x + Float64(x + 2.0)))); else tmp = fma(Float64(0.5 * x), 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.05], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] * N[(x + N[(x + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(x * N[(eps * eps), $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.05:\\
\;\;\;\;0.5 \cdot \left(e^{-x} \cdot \left(x + \left(x + 2\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, x \cdot \left(\varepsilon \cdot \varepsilon\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.0499999999999998Initial program 51.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
Applied rewrites99.7%
if 2.0499999999999998 < (-.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 x around 0
Applied rewrites84.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6484.7
Applied rewrites84.7%
Final simplification93.5%
(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.05)
(exp (- x))
(fma (* 0.5 x) (* 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.05) {
tmp = exp(-x);
} else {
tmp = fma((0.5 * x), (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.05) tmp = exp(Float64(-x)); else tmp = fma(Float64(0.5 * x), 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.05], N[Exp[(-x)], $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(x * N[(eps * eps), $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.05:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, x \cdot \left(\varepsilon \cdot \varepsilon\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.0499999999999998Initial program 51.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.2%
Taylor expanded in eps around 0
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6498.9
Applied rewrites98.9%
if 2.0499999999999998 < (-.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 x around 0
Applied rewrites84.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6484.7
Applied rewrites84.7%
Final simplification93.0%
(FPCore (x eps) :precision binary64 (* 0.5 (+ (exp (- (* x eps) x)) (pow (exp -1.0) (fma x eps x)))))
double code(double x, double eps) {
return 0.5 * (exp(((x * eps) - x)) + pow(exp(-1.0), fma(x, eps, x)));
}
function code(x, eps) return Float64(0.5 * Float64(exp(Float64(Float64(x * eps) - x)) + (exp(-1.0) ^ fma(x, eps, x)))) end
code[x_, eps_] := N[(0.5 * N[(N[Exp[N[(N[(x * eps), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[Power[N[Exp[-1.0], $MachinePrecision], N[(x * eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(e^{x \cdot \varepsilon - x} + {\left(e^{-1}\right)}^{\left(\mathsf{fma}\left(x, \varepsilon, x\right)\right)}\right)
\end{array}
Initial program 72.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.5%
lift-fma.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f6499.5
Applied rewrites99.5%
(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))))
5.0)
1.0
(* (* x x) (* 0.5 (* eps eps)))))
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)))) <= 5.0) {
tmp = 1.0;
} else {
tmp = (x * x) * (0.5 * (eps * eps));
}
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)))) <= 5.0d0) then
tmp = 1.0d0
else
tmp = (x * x) * (0.5d0 * (eps * eps))
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)))) <= 5.0) {
tmp = 1.0;
} else {
tmp = (x * x) * (0.5 * (eps * eps));
}
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)))) <= 5.0: tmp = 1.0 else: tmp = (x * x) * (0.5 * (eps * eps)) 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)))) <= 5.0) tmp = 1.0; else tmp = Float64(Float64(x * x) * Float64(0.5 * Float64(eps * eps))); 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)))) <= 5.0) tmp = 1.0; else tmp = (x * x) * (0.5 * (eps * eps)); 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], 5.0], 1.0, N[(N[(x * x), $MachinePrecision] * N[(0.5 * N[(eps * eps), $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 5:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(0.5 \cdot \left(\varepsilon \cdot \varepsilon\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))))) < 5Initial program 52.5%
Taylor expanded in x around 0
Applied rewrites79.1%
if 5 < (-.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 x around 0
Applied rewrites85.7%
Taylor expanded in eps around inf
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6475.2
Applied rewrites75.2%
Final simplification77.5%
(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))))
5.0)
1.0
(* 0.5 (* eps (* x (* x eps))))))
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)))) <= 5.0) {
tmp = 1.0;
} else {
tmp = 0.5 * (eps * (x * (x * eps)));
}
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)))) <= 5.0d0) then
tmp = 1.0d0
else
tmp = 0.5d0 * (eps * (x * (x * eps)))
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)))) <= 5.0) {
tmp = 1.0;
} else {
tmp = 0.5 * (eps * (x * (x * eps)));
}
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)))) <= 5.0: tmp = 1.0 else: tmp = 0.5 * (eps * (x * (x * eps))) 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)))) <= 5.0) tmp = 1.0; else tmp = Float64(0.5 * Float64(eps * Float64(x * Float64(x * eps)))); 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)))) <= 5.0) tmp = 1.0; else tmp = 0.5 * (eps * (x * (x * eps))); 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], 5.0], 1.0, N[(0.5 * N[(eps * N[(x * N[(x * eps), $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 5:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\varepsilon \cdot \left(x \cdot \left(x \cdot \varepsilon\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))))) < 5Initial program 52.5%
Taylor expanded in x around 0
Applied rewrites79.1%
if 5 < (-.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 x around 0
Applied rewrites12.8%
Taylor expanded in eps around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6450.9
Applied rewrites50.9%
Taylor expanded in x around 0
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6467.7
Applied rewrites67.7%
Final simplification74.4%
(FPCore (x eps) :precision binary64 (* 0.5 (+ (exp (- (* x eps) x)) (exp (- (fma x eps x))))))
double code(double x, double eps) {
return 0.5 * (exp(((x * eps) - x)) + exp(-fma(x, eps, x)));
}
function code(x, eps) return Float64(0.5 * Float64(exp(Float64(Float64(x * eps) - x)) + exp(Float64(-fma(x, eps, x))))) end
code[x_, eps_] := N[(0.5 * N[(N[Exp[N[(N[(x * eps), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision] + N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(e^{x \cdot \varepsilon - x} + e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)
\end{array}
Initial program 72.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.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (/ 1.0 eps) eps)))
(if (<= x -9e-233)
(fma
x
(*
0.5
(+
(+ (- -1.0 eps) (/ (+ eps 1.0) eps))
(fma
x
(* eps (* eps (fma x -0.6666666666666666 1.0)))
(+ (/ (+ eps -1.0) eps) (+ eps -1.0)))))
1.0)
(if (<= x 5.8e-265)
(fma x (* (+ eps -1.0) (fma (* x 0.25) (+ eps -1.0) 0.5)) 1.0)
(if (<= x 0.085)
(fma (* 0.5 x) (* x (* eps eps)) 1.0)
(* (fma (- -1.0 eps) t_0 (* (- 1.0 eps) t_0)) (* 0.25 (* x x))))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) - eps;
double tmp;
if (x <= -9e-233) {
tmp = fma(x, (0.5 * (((-1.0 - eps) + ((eps + 1.0) / eps)) + fma(x, (eps * (eps * fma(x, -0.6666666666666666, 1.0))), (((eps + -1.0) / eps) + (eps + -1.0))))), 1.0);
} else if (x <= 5.8e-265) {
tmp = fma(x, ((eps + -1.0) * fma((x * 0.25), (eps + -1.0), 0.5)), 1.0);
} else if (x <= 0.085) {
tmp = fma((0.5 * x), (x * (eps * eps)), 1.0);
} else {
tmp = fma((-1.0 - eps), t_0, ((1.0 - eps) * t_0)) * (0.25 * (x * x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) - eps) tmp = 0.0 if (x <= -9e-233) tmp = fma(x, Float64(0.5 * Float64(Float64(Float64(-1.0 - eps) + Float64(Float64(eps + 1.0) / eps)) + fma(x, Float64(eps * Float64(eps * fma(x, -0.6666666666666666, 1.0))), Float64(Float64(Float64(eps + -1.0) / eps) + Float64(eps + -1.0))))), 1.0); elseif (x <= 5.8e-265) tmp = fma(x, Float64(Float64(eps + -1.0) * fma(Float64(x * 0.25), Float64(eps + -1.0), 0.5)), 1.0); elseif (x <= 0.085) tmp = fma(Float64(0.5 * x), Float64(x * Float64(eps * eps)), 1.0); else tmp = Float64(fma(Float64(-1.0 - eps), t_0, Float64(Float64(1.0 - eps) * t_0)) * Float64(0.25 * Float64(x * x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] - eps), $MachinePrecision]}, If[LessEqual[x, -9e-233], N[(x * N[(0.5 * N[(N[(N[(-1.0 - eps), $MachinePrecision] + N[(N[(eps + 1.0), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + N[(x * N[(eps * N[(eps * N[(x * -0.6666666666666666 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(eps + -1.0), $MachinePrecision] / eps), $MachinePrecision] + N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 5.8e-265], N[(x * N[(N[(eps + -1.0), $MachinePrecision] * N[(N[(x * 0.25), $MachinePrecision] * N[(eps + -1.0), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 0.085], N[(N[(0.5 * x), $MachinePrecision] * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(N[(-1.0 - eps), $MachinePrecision] * t$95$0 + N[(N[(1.0 - eps), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} - \varepsilon\\
\mathbf{if}\;x \leq -9 \cdot 10^{-233}:\\
\;\;\;\;\mathsf{fma}\left(x, 0.5 \cdot \left(\left(\left(-1 - \varepsilon\right) + \frac{\varepsilon + 1}{\varepsilon}\right) + \mathsf{fma}\left(x, \varepsilon \cdot \left(\varepsilon \cdot \mathsf{fma}\left(x, -0.6666666666666666, 1\right)\right), \frac{\varepsilon + -1}{\varepsilon} + \left(\varepsilon + -1\right)\right)\right), 1\right)\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-265}:\\
\;\;\;\;\mathsf{fma}\left(x, \left(\varepsilon + -1\right) \cdot \mathsf{fma}\left(x \cdot 0.25, \varepsilon + -1, 0.5\right), 1\right)\\
\mathbf{elif}\;x \leq 0.085:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, x \cdot \left(\varepsilon \cdot \varepsilon\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1 - \varepsilon, t\_0, \left(1 - \varepsilon\right) \cdot t\_0\right) \cdot \left(0.25 \cdot \left(x \cdot x\right)\right)\\
\end{array}
\end{array}
if x < -9.0000000000000004e-233Initial program 68.0%
Taylor expanded in x around 0
Applied rewrites49.5%
Taylor expanded in eps around inf
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6492.9
Applied rewrites92.9%
if -9.0000000000000004e-233 < x < 5.7999999999999995e-265Initial program 65.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.9%
Taylor expanded in x around 0
Applied rewrites94.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites98.1%
if 5.7999999999999995e-265 < x < 0.0850000000000000061Initial program 51.6%
Taylor expanded in x around 0
Applied rewrites97.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.7
Applied rewrites97.7%
if 0.0850000000000000061 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites42.2%
Taylor expanded in x around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites68.5%
Final simplification88.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (/ 1.0 eps) eps)))
(if (<= x 5.8e-265)
(fma x (* (+ eps -1.0) (fma (* x 0.25) (+ eps -1.0) 0.5)) 1.0)
(if (<= x 0.085)
(fma (* 0.5 x) (* x (* eps eps)) 1.0)
(* (fma (- -1.0 eps) t_0 (* (- 1.0 eps) t_0)) (* 0.25 (* x x)))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) - eps;
double tmp;
if (x <= 5.8e-265) {
tmp = fma(x, ((eps + -1.0) * fma((x * 0.25), (eps + -1.0), 0.5)), 1.0);
} else if (x <= 0.085) {
tmp = fma((0.5 * x), (x * (eps * eps)), 1.0);
} else {
tmp = fma((-1.0 - eps), t_0, ((1.0 - eps) * t_0)) * (0.25 * (x * x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) - eps) tmp = 0.0 if (x <= 5.8e-265) tmp = fma(x, Float64(Float64(eps + -1.0) * fma(Float64(x * 0.25), Float64(eps + -1.0), 0.5)), 1.0); elseif (x <= 0.085) tmp = fma(Float64(0.5 * x), Float64(x * Float64(eps * eps)), 1.0); else tmp = Float64(fma(Float64(-1.0 - eps), t_0, Float64(Float64(1.0 - eps) * t_0)) * Float64(0.25 * Float64(x * x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] - eps), $MachinePrecision]}, If[LessEqual[x, 5.8e-265], N[(x * N[(N[(eps + -1.0), $MachinePrecision] * N[(N[(x * 0.25), $MachinePrecision] * N[(eps + -1.0), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 0.085], N[(N[(0.5 * x), $MachinePrecision] * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(N[(-1.0 - eps), $MachinePrecision] * t$95$0 + N[(N[(1.0 - eps), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(0.25 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} - \varepsilon\\
\mathbf{if}\;x \leq 5.8 \cdot 10^{-265}:\\
\;\;\;\;\mathsf{fma}\left(x, \left(\varepsilon + -1\right) \cdot \mathsf{fma}\left(x \cdot 0.25, \varepsilon + -1, 0.5\right), 1\right)\\
\mathbf{elif}\;x \leq 0.085:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, x \cdot \left(\varepsilon \cdot \varepsilon\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1 - \varepsilon, t\_0, \left(1 - \varepsilon\right) \cdot t\_0\right) \cdot \left(0.25 \cdot \left(x \cdot x\right)\right)\\
\end{array}
\end{array}
if x < 5.7999999999999995e-265Initial program 67.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 rewrites99.3%
Taylor expanded in x around 0
Applied rewrites76.3%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites90.5%
if 5.7999999999999995e-265 < x < 0.0850000000000000061Initial program 51.6%
Taylor expanded in x around 0
Applied rewrites97.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6497.7
Applied rewrites97.7%
if 0.0850000000000000061 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites42.2%
Taylor expanded in x around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites68.5%
Final simplification86.6%
(FPCore (x eps)
:precision binary64
(if (<= x 5.8e-265)
(fma x (* (+ eps -1.0) (fma (* x 0.25) (+ eps -1.0) 0.5)) 1.0)
(if (<= x 3.6e+42)
(fma
x
(fma
x
(*
(* (- 1.0 eps) (- 1.0 eps))
(fma (* x 0.08333333333333333) (+ eps -1.0) 0.25))
(fma 0.5 eps -0.5))
1.0)
(* (* x x) (* 0.5 (* eps eps))))))
double code(double x, double eps) {
double tmp;
if (x <= 5.8e-265) {
tmp = fma(x, ((eps + -1.0) * fma((x * 0.25), (eps + -1.0), 0.5)), 1.0);
} else if (x <= 3.6e+42) {
tmp = fma(x, fma(x, (((1.0 - eps) * (1.0 - eps)) * fma((x * 0.08333333333333333), (eps + -1.0), 0.25)), fma(0.5, eps, -0.5)), 1.0);
} else {
tmp = (x * x) * (0.5 * (eps * eps));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 5.8e-265) tmp = fma(x, Float64(Float64(eps + -1.0) * fma(Float64(x * 0.25), Float64(eps + -1.0), 0.5)), 1.0); elseif (x <= 3.6e+42) tmp = fma(x, fma(x, Float64(Float64(Float64(1.0 - eps) * Float64(1.0 - eps)) * fma(Float64(x * 0.08333333333333333), Float64(eps + -1.0), 0.25)), fma(0.5, eps, -0.5)), 1.0); else tmp = Float64(Float64(x * x) * Float64(0.5 * Float64(eps * eps))); end return tmp end
code[x_, eps_] := If[LessEqual[x, 5.8e-265], N[(x * N[(N[(eps + -1.0), $MachinePrecision] * N[(N[(x * 0.25), $MachinePrecision] * N[(eps + -1.0), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 3.6e+42], N[(x * N[(x * N[(N[(N[(1.0 - eps), $MachinePrecision] * N[(1.0 - eps), $MachinePrecision]), $MachinePrecision] * N[(N[(x * 0.08333333333333333), $MachinePrecision] * N[(eps + -1.0), $MachinePrecision] + 0.25), $MachinePrecision]), $MachinePrecision] + N[(0.5 * eps + -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.8 \cdot 10^{-265}:\\
\;\;\;\;\mathsf{fma}\left(x, \left(\varepsilon + -1\right) \cdot \mathsf{fma}\left(x \cdot 0.25, \varepsilon + -1, 0.5\right), 1\right)\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{+42}:\\
\;\;\;\;\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.08333333333333333, \varepsilon + -1, 0.25\right), \mathsf{fma}\left(0.5, \varepsilon, -0.5\right)\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
\end{array}
\end{array}
if x < 5.7999999999999995e-265Initial program 67.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 rewrites99.3%
Taylor expanded in x around 0
Applied rewrites76.3%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites90.5%
if 5.7999999999999995e-265 < x < 3.6000000000000001e42Initial program 60.2%
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 x around 0
Applied rewrites74.5%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites72.7%
if 3.6000000000000001e42 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites49.8%
Taylor expanded in eps around inf
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6464.2
Applied rewrites64.2%
Final simplification80.1%
(FPCore (x eps)
:precision binary64
(if (<= x 5.8e-265)
(fma x (* (+ eps -1.0) (fma (* x 0.25) (+ eps -1.0) 0.5)) 1.0)
(if (<= x 2.6)
(fma (* 0.5 x) (* x (* eps eps)) 1.0)
(* (* x x) (* 0.5 (* eps eps))))))
double code(double x, double eps) {
double tmp;
if (x <= 5.8e-265) {
tmp = fma(x, ((eps + -1.0) * fma((x * 0.25), (eps + -1.0), 0.5)), 1.0);
} else if (x <= 2.6) {
tmp = fma((0.5 * x), (x * (eps * eps)), 1.0);
} else {
tmp = (x * x) * (0.5 * (eps * eps));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 5.8e-265) tmp = fma(x, Float64(Float64(eps + -1.0) * fma(Float64(x * 0.25), Float64(eps + -1.0), 0.5)), 1.0); elseif (x <= 2.6) tmp = fma(Float64(0.5 * x), Float64(x * Float64(eps * eps)), 1.0); else tmp = Float64(Float64(x * x) * Float64(0.5 * Float64(eps * eps))); end return tmp end
code[x_, eps_] := If[LessEqual[x, 5.8e-265], N[(x * N[(N[(eps + -1.0), $MachinePrecision] * N[(N[(x * 0.25), $MachinePrecision] * N[(eps + -1.0), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 2.6], N[(N[(0.5 * x), $MachinePrecision] * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.8 \cdot 10^{-265}:\\
\;\;\;\;\mathsf{fma}\left(x, \left(\varepsilon + -1\right) \cdot \mathsf{fma}\left(x \cdot 0.25, \varepsilon + -1, 0.5\right), 1\right)\\
\mathbf{elif}\;x \leq 2.6:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, x \cdot \left(\varepsilon \cdot \varepsilon\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
\end{array}
\end{array}
if x < 5.7999999999999995e-265Initial program 67.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 rewrites99.3%
Taylor expanded in x around 0
Applied rewrites76.3%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites90.5%
if 5.7999999999999995e-265 < x < 2.60000000000000009Initial program 52.4%
Taylor expanded in x around 0
Applied rewrites96.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.1
Applied rewrites96.1%
if 2.60000000000000009 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites42.8%
Taylor expanded in eps around inf
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.6
Applied rewrites57.6%
Final simplification83.6%
(FPCore (x eps) :precision binary64 (if (<= x 2.6) (fma (* 0.5 x) (* x (* eps eps)) 1.0) (* (* x x) (* 0.5 (* eps eps)))))
double code(double x, double eps) {
double tmp;
if (x <= 2.6) {
tmp = fma((0.5 * x), (x * (eps * eps)), 1.0);
} else {
tmp = (x * x) * (0.5 * (eps * eps));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 2.6) tmp = fma(Float64(0.5 * x), Float64(x * Float64(eps * eps)), 1.0); else tmp = Float64(Float64(x * x) * Float64(0.5 * Float64(eps * eps))); end return tmp end
code[x_, eps_] := If[LessEqual[x, 2.6], N[(N[(0.5 * x), $MachinePrecision] * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.6:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, x \cdot \left(\varepsilon \cdot \varepsilon\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
\end{array}
\end{array}
if x < 2.60000000000000009Initial program 62.6%
Taylor expanded in x around 0
Applied rewrites90.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.0
Applied rewrites90.0%
if 2.60000000000000009 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites42.8%
Taylor expanded in eps around inf
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.6
Applied rewrites57.6%
Final simplification81.9%
(FPCore (x eps) :precision binary64 (if (<= x -0.49) (* eps (* x -0.5)) (fma x (fma 0.5 eps -0.5) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -0.49) {
tmp = eps * (x * -0.5);
} else {
tmp = fma(x, fma(0.5, eps, -0.5), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -0.49) tmp = Float64(eps * Float64(x * -0.5)); else tmp = fma(x, fma(0.5, eps, -0.5), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -0.49], N[(eps * N[(x * -0.5), $MachinePrecision]), $MachinePrecision], N[(x * N[(0.5 * eps + -0.5), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.49:\\
\;\;\;\;\varepsilon \cdot \left(x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(0.5, \varepsilon, -0.5\right), 1\right)\\
\end{array}
\end{array}
if x < -0.48999999999999999Initial program 100.0%
Taylor expanded in x around 0
neg-mul-1N/A
unsub-negN/A
lower--.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6447.2
Applied rewrites47.2%
Taylor expanded in eps around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6424.7
Applied rewrites24.7%
if -0.48999999999999999 < x Initial program 66.8%
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 rewrites68.0%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
distribute-lft-inN/A
metadata-evalN/A
lower-fma.f6458.2
Applied rewrites58.2%
(FPCore (x eps) :precision binary64 (if (<= x -0.49) (* eps (* x -0.5)) 1.0))
double code(double x, double eps) {
double tmp;
if (x <= -0.49) {
tmp = eps * (x * -0.5);
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= (-0.49d0)) then
tmp = eps * (x * (-0.5d0))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -0.49) {
tmp = eps * (x * -0.5);
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -0.49: tmp = eps * (x * -0.5) else: tmp = 1.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= -0.49) tmp = Float64(eps * Float64(x * -0.5)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -0.49) tmp = eps * (x * -0.5); else tmp = 1.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -0.49], N[(eps * N[(x * -0.5), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.49:\\
\;\;\;\;\varepsilon \cdot \left(x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -0.48999999999999999Initial program 100.0%
Taylor expanded in x around 0
neg-mul-1N/A
unsub-negN/A
lower--.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6447.2
Applied rewrites47.2%
Taylor expanded in eps around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6424.7
Applied rewrites24.7%
if -0.48999999999999999 < x Initial program 66.8%
Taylor expanded in x around 0
Applied rewrites56.3%
(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 72.0%
Taylor expanded in x around 0
Applied rewrites48.0%
herbie shell --seed 2024212
(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))