
(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 14 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))))
(* (+ (/ 1.0 eps) -1.0) (exp (* x (- -1.0 eps)))))
0.0)
(* 0.5 (* (exp (- x)) (+ x (+ x 2.0))))
(* 0.5 (* 2.0 (cosh (* x eps))))))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))))) <= 0.0) {
tmp = 0.5 * (exp(-x) * (x + (x + 2.0)));
} else {
tmp = 0.5 * (2.0 * cosh((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))))) - (((1.0d0 / eps) + (-1.0d0)) * exp((x * ((-1.0d0) - eps))))) <= 0.0d0) then
tmp = 0.5d0 * (exp(-x) * (x + (x + 2.0d0)))
else
tmp = 0.5d0 * (2.0d0 * cosh((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)))) - (((1.0 / eps) + -1.0) * Math.exp((x * (-1.0 - eps))))) <= 0.0) {
tmp = 0.5 * (Math.exp(-x) * (x + (x + 2.0)));
} else {
tmp = 0.5 * (2.0 * Math.cosh((x * eps)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (((1.0 + (1.0 / eps)) * math.exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * math.exp((x * (-1.0 - eps))))) <= 0.0: tmp = 0.5 * (math.exp(-x) * (x + (x + 2.0))) else: tmp = 0.5 * (2.0 * math.cosh((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(Float64(Float64(1.0 / eps) + -1.0) * exp(Float64(x * 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(2.0 * cosh(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)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))))) <= 0.0) tmp = 0.5 * (exp(-x) * (x + (x + 2.0))); else tmp = 0.5 * (2.0 * cosh((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[(N[(1.0 / eps), $MachinePrecision] + -1.0), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $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[(2.0 * N[Cosh[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)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{x \cdot \left(-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(2 \cdot \cosh \left(x \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))))) < 0.0Initial program 35.7%
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
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 99.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.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
lift-*.f64N/A
cosh-undefN/A
lower-*.f64N/A
lower-cosh.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (+ (/ 1.0 eps) -1.0) (exp (* x (- -1.0 eps)))))
0.0)
(exp (- x))
(* 0.5 (* 2.0 (cosh (* x eps))))))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))))) <= 0.0) {
tmp = exp(-x);
} else {
tmp = 0.5 * (2.0 * cosh((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))))) - (((1.0d0 / eps) + (-1.0d0)) * exp((x * ((-1.0d0) - eps))))) <= 0.0d0) then
tmp = exp(-x)
else
tmp = 0.5d0 * (2.0d0 * cosh((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)))) - (((1.0 / eps) + -1.0) * Math.exp((x * (-1.0 - eps))))) <= 0.0) {
tmp = Math.exp(-x);
} else {
tmp = 0.5 * (2.0 * Math.cosh((x * eps)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (((1.0 + (1.0 / eps)) * math.exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * math.exp((x * (-1.0 - eps))))) <= 0.0: tmp = math.exp(-x) else: tmp = 0.5 * (2.0 * math.cosh((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(Float64(Float64(1.0 / eps) + -1.0) * exp(Float64(x * Float64(-1.0 - eps))))) <= 0.0) tmp = exp(Float64(-x)); else tmp = Float64(0.5 * Float64(2.0 * cosh(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)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))))) <= 0.0) tmp = exp(-x); else tmp = 0.5 * (2.0 * cosh((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[(N[(1.0 / eps), $MachinePrecision] + -1.0), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[Exp[(-x)], $MachinePrecision], N[(0.5 * N[(2.0 * N[Cosh[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)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{x \cdot \left(-1 - \varepsilon\right)} \leq 0:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \cosh \left(x \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))))) < 0.0Initial program 35.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.4%
Taylor expanded in eps around 0
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6499.4
Applied rewrites99.4%
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 99.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.7%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
lift-*.f64N/A
cosh-undefN/A
lower-*.f64N/A
lower-cosh.f64100.0
Applied rewrites100.0%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (+ (/ 1.0 eps) -1.0) (exp (* x (- -1.0 eps)))))
4.0)
(exp (- x))
(/ (fma 0.5 x (fma (* eps eps) (* x (fma 0.5 (* x eps) -0.5)) eps)) eps)))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))))) <= 4.0) {
tmp = exp(-x);
} else {
tmp = fma(0.5, x, fma((eps * eps), (x * fma(0.5, (x * eps), -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(Float64(Float64(1.0 / eps) + -1.0) * exp(Float64(x * Float64(-1.0 - eps))))) <= 4.0) tmp = exp(Float64(-x)); else tmp = Float64(fma(0.5, x, fma(Float64(eps * eps), Float64(x * fma(0.5, Float64(x * eps), -0.5)), eps)) / 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[(N[(1.0 / eps), $MachinePrecision] + -1.0), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0], N[Exp[(-x)], $MachinePrecision], N[(N[(0.5 * x + N[(N[(eps * eps), $MachinePrecision] * N[(x * N[(0.5 * N[(x * eps), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{x \cdot \left(-1 - \varepsilon\right)} \leq 4:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, x, \mathsf{fma}\left(\varepsilon \cdot \varepsilon, x \cdot \mathsf{fma}\left(0.5, x \cdot \varepsilon, -0.5\right), \varepsilon\right)\right)}{\varepsilon}\\
\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 50.1%
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 eps around 0
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6497.9
Applied rewrites97.9%
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 x around 0
Applied rewrites84.7%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6484.7
Applied rewrites84.7%
Taylor expanded in eps around 0
lower-/.f64N/A
Applied rewrites91.3%
Final simplification95.1%
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (+ (/ 1.0 eps) -1.0) (exp (* x (- -1.0 eps)))))
4.0)
1.0
(* (* x 0.25) (* x (* eps eps)))))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))))) <= 4.0) {
tmp = 1.0;
} else {
tmp = (x * 0.25) * (x * (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))))) - (((1.0d0 / eps) + (-1.0d0)) * exp((x * ((-1.0d0) - eps))))) <= 4.0d0) then
tmp = 1.0d0
else
tmp = (x * 0.25d0) * (x * (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)))) - (((1.0 / eps) + -1.0) * Math.exp((x * (-1.0 - eps))))) <= 4.0) {
tmp = 1.0;
} else {
tmp = (x * 0.25) * (x * (eps * eps));
}
return tmp;
}
def code(x, eps): tmp = 0 if (((1.0 + (1.0 / eps)) * math.exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * math.exp((x * (-1.0 - eps))))) <= 4.0: tmp = 1.0 else: tmp = (x * 0.25) * (x * (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(Float64(Float64(1.0 / eps) + -1.0) * exp(Float64(x * Float64(-1.0 - eps))))) <= 4.0) tmp = 1.0; else tmp = Float64(Float64(x * 0.25) * Float64(x * 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)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))))) <= 4.0) tmp = 1.0; else tmp = (x * 0.25) * (x * (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[(N[(1.0 / eps), $MachinePrecision] + -1.0), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0], 1.0, N[(N[(x * 0.25), $MachinePrecision] * N[(x * 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)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{x \cdot \left(-1 - \varepsilon\right)} \leq 4:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 0.25\right) \cdot \left(x \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))))) < 4Initial program 50.1%
Taylor expanded in x around 0
Applied rewrites73.3%
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 x around 0
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites90.6%
Taylor expanded in eps around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6481.0
Applied rewrites81.0%
Taylor expanded in eps around 0
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6481.0
Applied rewrites81.0%
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6484.7
Applied rewrites84.7%
Final simplification78.2%
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (+ (/ 1.0 eps) -1.0) (exp (* x (- -1.0 eps)))))
4.0)
1.0
(* (* 0.5 (* eps eps)) (* x x))))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))))) <= 4.0) {
tmp = 1.0;
} else {
tmp = (0.5 * (eps * eps)) * (x * 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))))) - (((1.0d0 / eps) + (-1.0d0)) * exp((x * ((-1.0d0) - eps))))) <= 4.0d0) then
tmp = 1.0d0
else
tmp = (0.5d0 * (eps * eps)) * (x * 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)))) - (((1.0 / eps) + -1.0) * Math.exp((x * (-1.0 - eps))))) <= 4.0) {
tmp = 1.0;
} else {
tmp = (0.5 * (eps * eps)) * (x * x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (((1.0 + (1.0 / eps)) * math.exp((x * (eps + -1.0)))) - (((1.0 / eps) + -1.0) * math.exp((x * (-1.0 - eps))))) <= 4.0: tmp = 1.0 else: tmp = (0.5 * (eps * eps)) * (x * 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(Float64(Float64(1.0 / eps) + -1.0) * exp(Float64(x * Float64(-1.0 - eps))))) <= 4.0) tmp = 1.0; else tmp = Float64(Float64(0.5 * Float64(eps * eps)) * Float64(x * 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)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))))) <= 4.0) tmp = 1.0; else tmp = (0.5 * (eps * eps)) * (x * 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[(N[(1.0 / eps), $MachinePrecision] + -1.0), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0], 1.0, N[(N[(0.5 * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{x \cdot \left(-1 - \varepsilon\right)} \leq 4:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \left(x \cdot x\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 50.1%
Taylor expanded in x around 0
Applied rewrites73.3%
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 x around 0
Applied rewrites84.7%
Taylor expanded in eps around inf
associate-*r*N/A
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6481.0
Applied rewrites81.0%
Final simplification76.6%
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (+ (/ 1.0 eps) -1.0) (exp (* x (- -1.0 eps)))))
4.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)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))))) <= 4.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))))) - (((1.0d0 / eps) + (-1.0d0)) * exp((x * ((-1.0d0) - eps))))) <= 4.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)))) - (((1.0 / eps) + -1.0) * Math.exp((x * (-1.0 - eps))))) <= 4.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)))) - (((1.0 / eps) + -1.0) * math.exp((x * (-1.0 - eps))))) <= 4.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(Float64(Float64(1.0 / eps) + -1.0) * exp(Float64(x * Float64(-1.0 - eps))))) <= 4.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)))) - (((1.0 / eps) + -1.0) * exp((x * (-1.0 - eps))))) <= 4.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[(N[(1.0 / eps), $MachinePrecision] + -1.0), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.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)} - \left(\frac{1}{\varepsilon} + -1\right) \cdot e^{x \cdot \left(-1 - \varepsilon\right)} \leq 4:\\
\;\;\;\;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))))) < 4Initial program 50.1%
Taylor expanded in x around 0
Applied rewrites73.3%
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 x around 0
Applied rewrites84.7%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6484.7
Applied rewrites84.7%
Taylor expanded in eps around inf
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
sub-negN/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6479.4
Applied rewrites79.4%
Taylor expanded in x around inf
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.4
Applied rewrites74.4%
Final simplification73.8%
(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 71.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.6%
(FPCore (x eps)
:precision binary64
(if (<= x -5e+67)
(/ (fma 0.5 x (fma (* eps eps) (* x (fma 0.5 (* x eps) -0.5)) eps)) eps)
(if (<= x 2.1e-8)
(fma
x
(*
0.5
(fma
(+ eps 1.0)
(+ (/ 1.0 eps) -1.0)
(/
(fma
eps
(+
(fma x -0.5 (* eps (+ (+ 1.0 (fma x -0.5 (* x eps))) (* 0.5 x))))
(* x -0.5))
-1.0)
eps)))
1.0)
(* (* x 0.25) (* x (* eps eps))))))
double code(double x, double eps) {
double tmp;
if (x <= -5e+67) {
tmp = fma(0.5, x, fma((eps * eps), (x * fma(0.5, (x * eps), -0.5)), eps)) / eps;
} else if (x <= 2.1e-8) {
tmp = fma(x, (0.5 * fma((eps + 1.0), ((1.0 / eps) + -1.0), (fma(eps, (fma(x, -0.5, (eps * ((1.0 + fma(x, -0.5, (x * eps))) + (0.5 * x)))) + (x * -0.5)), -1.0) / eps))), 1.0);
} else {
tmp = (x * 0.25) * (x * (eps * eps));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -5e+67) tmp = Float64(fma(0.5, x, fma(Float64(eps * eps), Float64(x * fma(0.5, Float64(x * eps), -0.5)), eps)) / eps); elseif (x <= 2.1e-8) tmp = fma(x, Float64(0.5 * fma(Float64(eps + 1.0), Float64(Float64(1.0 / eps) + -1.0), Float64(fma(eps, Float64(fma(x, -0.5, Float64(eps * Float64(Float64(1.0 + fma(x, -0.5, Float64(x * eps))) + Float64(0.5 * x)))) + Float64(x * -0.5)), -1.0) / eps))), 1.0); else tmp = Float64(Float64(x * 0.25) * Float64(x * Float64(eps * eps))); end return tmp end
code[x_, eps_] := If[LessEqual[x, -5e+67], N[(N[(0.5 * x + N[(N[(eps * eps), $MachinePrecision] * N[(x * N[(0.5 * N[(x * eps), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision], If[LessEqual[x, 2.1e-8], N[(x * N[(0.5 * N[(N[(eps + 1.0), $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + -1.0), $MachinePrecision] + N[(N[(eps * N[(N[(x * -0.5 + N[(eps * N[(N[(1.0 + N[(x * -0.5 + N[(x * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * -0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x * 0.25), $MachinePrecision] * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+67}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, x, \mathsf{fma}\left(\varepsilon \cdot \varepsilon, x \cdot \mathsf{fma}\left(0.5, x \cdot \varepsilon, -0.5\right), \varepsilon\right)\right)}{\varepsilon}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(x, 0.5 \cdot \mathsf{fma}\left(\varepsilon + 1, \frac{1}{\varepsilon} + -1, \frac{\mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(x, -0.5, \varepsilon \cdot \left(\left(1 + \mathsf{fma}\left(x, -0.5, x \cdot \varepsilon\right)\right) + 0.5 \cdot x\right)\right) + x \cdot -0.5, -1\right)}{\varepsilon}\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 0.25\right) \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
\end{array}
\end{array}
if x < -4.99999999999999976e67Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites85.8%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.8
Applied rewrites85.8%
Taylor expanded in eps around 0
lower-/.f64N/A
Applied rewrites100.0%
if -4.99999999999999976e67 < x < 2.09999999999999994e-8Initial program 50.1%
Taylor expanded in x around 0
Applied rewrites90.3%
Taylor expanded in eps around 0
Applied rewrites92.3%
if 2.09999999999999994e-8 < x Initial program 100.0%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites49.7%
Taylor expanded in eps around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6456.0
Applied rewrites56.0%
Taylor expanded in eps around 0
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6456.0
Applied rewrites56.0%
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6472.7
Applied rewrites72.7%
Final simplification87.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* x (* eps eps))))
(if (<= x -5e+67)
(/ (fma 0.5 x (fma (* eps eps) (* x (fma 0.5 (* x eps) -0.5)) eps)) eps)
(if (<= x 2.1e-8) (fma x (* 0.5 t_0) 1.0) (* (* x 0.25) t_0)))))
double code(double x, double eps) {
double t_0 = x * (eps * eps);
double tmp;
if (x <= -5e+67) {
tmp = fma(0.5, x, fma((eps * eps), (x * fma(0.5, (x * eps), -0.5)), eps)) / eps;
} else if (x <= 2.1e-8) {
tmp = fma(x, (0.5 * t_0), 1.0);
} else {
tmp = (x * 0.25) * t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(x * Float64(eps * eps)) tmp = 0.0 if (x <= -5e+67) tmp = Float64(fma(0.5, x, fma(Float64(eps * eps), Float64(x * fma(0.5, Float64(x * eps), -0.5)), eps)) / eps); elseif (x <= 2.1e-8) tmp = fma(x, Float64(0.5 * t_0), 1.0); else tmp = Float64(Float64(x * 0.25) * t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5e+67], N[(N[(0.5 * x + N[(N[(eps * eps), $MachinePrecision] * N[(x * N[(0.5 * N[(x * eps), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision], If[LessEqual[x, 2.1e-8], N[(x * N[(0.5 * t$95$0), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x * 0.25), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{if}\;x \leq -5 \cdot 10^{+67}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, x, \mathsf{fma}\left(\varepsilon \cdot \varepsilon, x \cdot \mathsf{fma}\left(0.5, x \cdot \varepsilon, -0.5\right), \varepsilon\right)\right)}{\varepsilon}\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(x, 0.5 \cdot t\_0, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 0.25\right) \cdot t\_0\\
\end{array}
\end{array}
if x < -4.99999999999999976e67Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites85.8%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.8
Applied rewrites85.8%
Taylor expanded in eps around 0
lower-/.f64N/A
Applied rewrites100.0%
if -4.99999999999999976e67 < x < 2.09999999999999994e-8Initial program 50.1%
Taylor expanded in x around 0
Applied rewrites90.3%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.3
Applied rewrites90.3%
if 2.09999999999999994e-8 < x Initial program 100.0%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites49.7%
Taylor expanded in eps around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6456.0
Applied rewrites56.0%
Taylor expanded in eps around 0
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6456.0
Applied rewrites56.0%
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6472.7
Applied rewrites72.7%
Final simplification86.2%
(FPCore (x eps) :precision binary64 (let* ((t_0 (* x (* eps eps)))) (if (<= x 2.1e-8) (fma x (* 0.5 t_0) 1.0) (* (* x 0.25) t_0))))
double code(double x, double eps) {
double t_0 = x * (eps * eps);
double tmp;
if (x <= 2.1e-8) {
tmp = fma(x, (0.5 * t_0), 1.0);
} else {
tmp = (x * 0.25) * t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(x * Float64(eps * eps)) tmp = 0.0 if (x <= 2.1e-8) tmp = fma(x, Float64(0.5 * t_0), 1.0); else tmp = Float64(Float64(x * 0.25) * t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.1e-8], N[(x * N[(0.5 * t$95$0), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x * 0.25), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{if}\;x \leq 2.1 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(x, 0.5 \cdot t\_0, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 0.25\right) \cdot t\_0\\
\end{array}
\end{array}
if x < 2.09999999999999994e-8Initial program 59.1%
Taylor expanded in x around 0
Applied rewrites89.5%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6489.5
Applied rewrites89.5%
if 2.09999999999999994e-8 < x Initial program 100.0%
Taylor expanded in x around 0
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites49.7%
Taylor expanded in eps around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6456.0
Applied rewrites56.0%
Taylor expanded in eps around 0
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6456.0
Applied rewrites56.0%
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6472.7
Applied rewrites72.7%
Final simplification84.4%
(FPCore (x eps) :precision binary64 (if (<= x -2e-7) (fma x (fma x (fma x -0.16666666666666666 0.5) -1.0) 1.0) (fma x (fma 0.5 x -1.0) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -2e-7) {
tmp = fma(x, fma(x, fma(x, -0.16666666666666666, 0.5), -1.0), 1.0);
} else {
tmp = fma(x, fma(0.5, x, -1.0), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -2e-7) tmp = fma(x, fma(x, fma(x, -0.16666666666666666, 0.5), -1.0), 1.0); else tmp = fma(x, fma(0.5, x, -1.0), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -2e-7], N[(x * N[(x * N[(x * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 1.0), $MachinePrecision], N[(x * N[(0.5 * x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-7}:\\
\;\;\;\;\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, \mathsf{fma}\left(0.5, x, -1\right), 1\right)\\
\end{array}
\end{array}
if x < -1.9999999999999999e-7Initial program 97.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 rewrites98.9%
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%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6460.2
Applied rewrites60.2%
if -1.9999999999999999e-7 < x Initial program 66.1%
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.7%
Taylor expanded in eps around 0
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6467.9
Applied rewrites67.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f6461.7
Applied rewrites61.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 71.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.6%
Taylor expanded in eps around 0
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6473.2
Applied rewrites73.2%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f6459.2
Applied rewrites59.2%
(FPCore (x eps) :precision binary64 (fma x (* eps -0.5) 1.0))
double code(double x, double eps) {
return fma(x, (eps * -0.5), 1.0);
}
function code(x, eps) return fma(x, Float64(eps * -0.5), 1.0) end
code[x_, eps_] := N[(x * N[(eps * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \varepsilon \cdot -0.5, 1\right)
\end{array}
Initial program 71.6%
Taylor expanded in x around 0
Applied rewrites76.6%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6459.2
Applied rewrites59.2%
Taylor expanded in eps around inf
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
sub-negN/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6475.4
Applied rewrites75.4%
Taylor expanded in eps around 0
Applied rewrites52.7%
(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 71.6%
Taylor expanded in x around 0
Applied rewrites43.2%
herbie shell --seed 2024214
(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))