
(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
(let* ((t_0 (+ 1.0 (pow eps -1.0))))
(if (<=
(-
(* t_0 (exp (* (+ -1.0 eps) x)))
(* (- (pow eps -1.0) 1.0) (exp (* (- -1.0 eps) x))))
2.0)
(* (* 2.0 (/ (+ 1.0 x) (exp x))) 0.5)
(/ (- (* t_0 (exp (* eps x))) (- (exp (- (fma x eps x))))) 2.0))))
double code(double x, double eps) {
double t_0 = 1.0 + pow(eps, -1.0);
double tmp;
if (((t_0 * exp(((-1.0 + eps) * x))) - ((pow(eps, -1.0) - 1.0) * exp(((-1.0 - eps) * x)))) <= 2.0) {
tmp = (2.0 * ((1.0 + x) / exp(x))) * 0.5;
} else {
tmp = ((t_0 * exp((eps * x))) - -exp(-fma(x, eps, x))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 + (eps ^ -1.0)) tmp = 0.0 if (Float64(Float64(t_0 * exp(Float64(Float64(-1.0 + eps) * x))) - Float64(Float64((eps ^ -1.0) - 1.0) * exp(Float64(Float64(-1.0 - eps) * x)))) <= 2.0) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / exp(x))) * 0.5); else tmp = Float64(Float64(Float64(t_0 * exp(Float64(eps * x))) - Float64(-exp(Float64(-fma(x, eps, x))))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(t$95$0 * N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + {\varepsilon}^{-1}\\
\mathbf{if}\;t\_0 \cdot e^{\left(-1 + \varepsilon\right) \cdot x} - \left({\varepsilon}^{-1} - 1\right) \cdot e^{\left(-1 - \varepsilon\right) \cdot x} \leq 2:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{e^{x}}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot e^{\varepsilon \cdot x} - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)}{2}\\
\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))))) < 2Initial program 68.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
if 2 < (-.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
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in eps around inf
lower-*.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (pow eps -1.0))))
(if (<=
(-
(* t_0 (exp (* (+ -1.0 eps) x)))
(* (- (pow eps -1.0) 1.0) (exp (* (- -1.0 eps) x))))
4.0)
(* (* 2.0 (/ (+ 1.0 x) (exp x))) 0.5)
(/ (- (* t_0 (exp (* eps x))) -1.0) 2.0))))
double code(double x, double eps) {
double t_0 = 1.0 + pow(eps, -1.0);
double tmp;
if (((t_0 * exp(((-1.0 + eps) * x))) - ((pow(eps, -1.0) - 1.0) * exp(((-1.0 - eps) * x)))) <= 4.0) {
tmp = (2.0 * ((1.0 + x) / exp(x))) * 0.5;
} else {
tmp = ((t_0 * exp((eps * x))) - -1.0) / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (eps ** (-1.0d0))
if (((t_0 * exp((((-1.0d0) + eps) * x))) - (((eps ** (-1.0d0)) - 1.0d0) * exp((((-1.0d0) - eps) * x)))) <= 4.0d0) then
tmp = (2.0d0 * ((1.0d0 + x) / exp(x))) * 0.5d0
else
tmp = ((t_0 * exp((eps * x))) - (-1.0d0)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = 1.0 + Math.pow(eps, -1.0);
double tmp;
if (((t_0 * Math.exp(((-1.0 + eps) * x))) - ((Math.pow(eps, -1.0) - 1.0) * Math.exp(((-1.0 - eps) * x)))) <= 4.0) {
tmp = (2.0 * ((1.0 + x) / Math.exp(x))) * 0.5;
} else {
tmp = ((t_0 * Math.exp((eps * x))) - -1.0) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = 1.0 + math.pow(eps, -1.0) tmp = 0 if ((t_0 * math.exp(((-1.0 + eps) * x))) - ((math.pow(eps, -1.0) - 1.0) * math.exp(((-1.0 - eps) * x)))) <= 4.0: tmp = (2.0 * ((1.0 + x) / math.exp(x))) * 0.5 else: tmp = ((t_0 * math.exp((eps * x))) - -1.0) / 2.0 return tmp
function code(x, eps) t_0 = Float64(1.0 + (eps ^ -1.0)) tmp = 0.0 if (Float64(Float64(t_0 * exp(Float64(Float64(-1.0 + eps) * x))) - Float64(Float64((eps ^ -1.0) - 1.0) * exp(Float64(Float64(-1.0 - eps) * x)))) <= 4.0) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / exp(x))) * 0.5); else tmp = Float64(Float64(Float64(t_0 * exp(Float64(eps * x))) - -1.0) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 + (eps ^ -1.0); tmp = 0.0; if (((t_0 * exp(((-1.0 + eps) * x))) - (((eps ^ -1.0) - 1.0) * exp(((-1.0 - eps) * x)))) <= 4.0) tmp = (2.0 * ((1.0 + x) / exp(x))) * 0.5; else tmp = ((t_0 * exp((eps * x))) - -1.0) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(t$95$0 * N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + {\varepsilon}^{-1}\\
\mathbf{if}\;t\_0 \cdot e^{\left(-1 + \varepsilon\right) \cdot x} - \left({\varepsilon}^{-1} - 1\right) \cdot e^{\left(-1 - \varepsilon\right) \cdot x} \leq 4:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{e^{x}}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot e^{\varepsilon \cdot x} - -1}{2}\\
\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 68.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
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
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites56.0%
Taylor expanded in eps around inf
lower-*.f6456.0
Applied rewrites56.0%
Final simplification79.4%
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (+ 1.0 (pow eps -1.0)) (exp (* (+ -1.0 eps) x)))
(* (- (pow eps -1.0) 1.0) (exp (* (- -1.0 eps) x))))
4.0)
(* (* 2.0 (/ (+ 1.0 x) (exp x))) 0.5)
(/ (- (+ (pow eps -1.0) 1.0) (- (exp (- (fma x eps x))))) 2.0)))
double code(double x, double eps) {
double tmp;
if ((((1.0 + pow(eps, -1.0)) * exp(((-1.0 + eps) * x))) - ((pow(eps, -1.0) - 1.0) * exp(((-1.0 - eps) * x)))) <= 4.0) {
tmp = (2.0 * ((1.0 + x) / exp(x))) * 0.5;
} else {
tmp = ((pow(eps, -1.0) + 1.0) - -exp(-fma(x, eps, x))) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (Float64(Float64(Float64(1.0 + (eps ^ -1.0)) * exp(Float64(Float64(-1.0 + eps) * x))) - Float64(Float64((eps ^ -1.0) - 1.0) * exp(Float64(Float64(-1.0 - eps) * x)))) <= 4.0) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / exp(x))) * 0.5); else tmp = Float64(Float64(Float64((eps ^ -1.0) + 1.0) - Float64(-exp(Float64(-fma(x, eps, x))))) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[N[(N[(N[(1.0 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[Power[eps, -1.0], $MachinePrecision] + 1.0), $MachinePrecision] - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + {\varepsilon}^{-1}\right) \cdot e^{\left(-1 + \varepsilon\right) \cdot x} - \left({\varepsilon}^{-1} - 1\right) \cdot e^{\left(-1 - \varepsilon\right) \cdot x} \leq 4:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{e^{x}}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left({\varepsilon}^{-1} + 1\right) - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)}{2}\\
\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 68.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
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
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6447.1
Applied rewrites47.1%
Final simplification75.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (pow eps -1.0))))
(if (<= eps 1.0)
(* (* 2.0 (/ (+ 1.0 x) (exp x))) 0.5)
(if (or (<= eps 1.6e+61) (not (<= eps 2.3e+279)))
(/
(-
(* t_0 (fma (- eps 1.0) x 1.0))
(* (- (pow eps -1.0) 1.0) (exp (* (- -1.0 eps) x))))
2.0)
(/
(+
(* t_0 (exp (* (+ -1.0 eps) x)))
(* (- (/ -1.0 eps) -1.0) (fma (- -1.0 eps) x 1.0)))
2.0)))))
double code(double x, double eps) {
double t_0 = 1.0 + pow(eps, -1.0);
double tmp;
if (eps <= 1.0) {
tmp = (2.0 * ((1.0 + x) / exp(x))) * 0.5;
} else if ((eps <= 1.6e+61) || !(eps <= 2.3e+279)) {
tmp = ((t_0 * fma((eps - 1.0), x, 1.0)) - ((pow(eps, -1.0) - 1.0) * exp(((-1.0 - eps) * x)))) / 2.0;
} else {
tmp = ((t_0 * exp(((-1.0 + eps) * x))) + (((-1.0 / eps) - -1.0) * fma((-1.0 - eps), x, 1.0))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 + (eps ^ -1.0)) tmp = 0.0 if (eps <= 1.0) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / exp(x))) * 0.5); elseif ((eps <= 1.6e+61) || !(eps <= 2.3e+279)) tmp = Float64(Float64(Float64(t_0 * fma(Float64(eps - 1.0), x, 1.0)) - Float64(Float64((eps ^ -1.0) - 1.0) * exp(Float64(Float64(-1.0 - eps) * x)))) / 2.0); else tmp = Float64(Float64(Float64(t_0 * exp(Float64(Float64(-1.0 + eps) * x))) + Float64(Float64(Float64(-1.0 / eps) - -1.0) * fma(Float64(-1.0 - eps), x, 1.0))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, 1.0], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[Or[LessEqual[eps, 1.6e+61], N[Not[LessEqual[eps, 2.3e+279]], $MachinePrecision]], N[(N[(N[(t$95$0 * N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(t$95$0 * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-1.0 / eps), $MachinePrecision] - -1.0), $MachinePrecision] * N[(N[(-1.0 - eps), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + {\varepsilon}^{-1}\\
\mathbf{if}\;\varepsilon \leq 1:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{e^{x}}\right) \cdot 0.5\\
\mathbf{elif}\;\varepsilon \leq 1.6 \cdot 10^{+61} \lor \neg \left(\varepsilon \leq 2.3 \cdot 10^{+279}\right):\\
\;\;\;\;\frac{t\_0 \cdot \mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left({\varepsilon}^{-1} - 1\right) \cdot e^{\left(-1 - \varepsilon\right) \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot e^{\left(-1 + \varepsilon\right) \cdot x} + \left(\frac{-1}{\varepsilon} - -1\right) \cdot \mathsf{fma}\left(-1 - \varepsilon, x, 1\right)}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 74.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.9%
if 1 < eps < 1.5999999999999999e61 or 2.3e279 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6492.6
Applied rewrites92.6%
if 1.5999999999999999e61 < eps < 2.3e279Initial program 100.0%
Taylor expanded in x around 0
neg-mul-1N/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f6470.2
Applied rewrites70.2%
Final simplification70.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (pow eps -1.0))))
(if (<= eps 1.0)
(* (* 2.0 (/ (+ 1.0 x) (exp x))) 0.5)
(if (or (<= eps 1.6e+61) (not (<= eps 2.3e+279)))
(/
(-
(* t_0 (fma (- eps 1.0) x 1.0))
(* (- (pow eps -1.0) 1.0) (exp (* (- -1.0 eps) x))))
2.0)
(/ (- (* t_0 (exp (* eps x))) (fma (+ 1.0 eps) x -1.0)) 2.0)))))
double code(double x, double eps) {
double t_0 = 1.0 + pow(eps, -1.0);
double tmp;
if (eps <= 1.0) {
tmp = (2.0 * ((1.0 + x) / exp(x))) * 0.5;
} else if ((eps <= 1.6e+61) || !(eps <= 2.3e+279)) {
tmp = ((t_0 * fma((eps - 1.0), x, 1.0)) - ((pow(eps, -1.0) - 1.0) * exp(((-1.0 - eps) * x)))) / 2.0;
} else {
tmp = ((t_0 * exp((eps * x))) - fma((1.0 + eps), x, -1.0)) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 + (eps ^ -1.0)) tmp = 0.0 if (eps <= 1.0) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / exp(x))) * 0.5); elseif ((eps <= 1.6e+61) || !(eps <= 2.3e+279)) tmp = Float64(Float64(Float64(t_0 * fma(Float64(eps - 1.0), x, 1.0)) - Float64(Float64((eps ^ -1.0) - 1.0) * exp(Float64(Float64(-1.0 - eps) * x)))) / 2.0); else tmp = Float64(Float64(Float64(t_0 * exp(Float64(eps * x))) - fma(Float64(1.0 + eps), x, -1.0)) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eps, 1.0], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[Or[LessEqual[eps, 1.6e+61], N[Not[LessEqual[eps, 2.3e+279]], $MachinePrecision]], N[(N[(N[(t$95$0 * N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(t$95$0 * N[Exp[N[(eps * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 + eps), $MachinePrecision] * x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + {\varepsilon}^{-1}\\
\mathbf{if}\;\varepsilon \leq 1:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{e^{x}}\right) \cdot 0.5\\
\mathbf{elif}\;\varepsilon \leq 1.6 \cdot 10^{+61} \lor \neg \left(\varepsilon \leq 2.3 \cdot 10^{+279}\right):\\
\;\;\;\;\frac{t\_0 \cdot \mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \left({\varepsilon}^{-1} - 1\right) \cdot e^{\left(-1 - \varepsilon\right) \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot e^{\varepsilon \cdot x} - \mathsf{fma}\left(1 + \varepsilon, x, -1\right)}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 74.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.9%
if 1 < eps < 1.5999999999999999e61 or 2.3e279 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6492.6
Applied rewrites92.6%
if 1.5999999999999999e61 < eps < 2.3e279Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in eps around inf
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites70.2%
Final simplification70.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (pow eps -1.0) 1.0)))
(if (<= x -23000000000000.0)
(/ (- (/ (exp (- x)) eps) -1.0) 2.0)
(if (<= x -2.3e-246)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 5e+274)
(* (* 2.0 (/ (+ 1.0 x) (exp x))) 0.5)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (pow eps -1.0)) 1.0))))))
double code(double x, double eps) {
double t_0 = pow(eps, -1.0) + 1.0;
double tmp;
if (x <= -23000000000000.0) {
tmp = ((exp(-x) / eps) - -1.0) / 2.0;
} else if (x <= -2.3e-246) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 5e+274) {
tmp = (2.0 * ((1.0 + x) / exp(x))) * 0.5;
} else {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, pow(eps, -1.0)), 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64((eps ^ -1.0) + 1.0) tmp = 0.0 if (x <= -23000000000000.0) tmp = Float64(Float64(Float64(exp(Float64(-x)) / eps) - -1.0) / 2.0); elseif (x <= -2.3e-246) tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), t_0, Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0); elseif (x <= 5e+274) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / exp(x))) * 0.5); else tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), t_0, (eps ^ -1.0)), 1.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[eps, -1.0], $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -23000000000000.0], N[(N[(N[(N[Exp[(-x)], $MachinePrecision] / eps), $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -2.3e-246], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * t$95$0 + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 5e+274], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * t$95$0 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\varepsilon}^{-1} + 1\\
\mathbf{if}\;x \leq -23000000000000:\\
\;\;\;\;\frac{\frac{e^{-x}}{\varepsilon} - -1}{2}\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-246}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, t\_0, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+274}:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{e^{x}}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, t\_0, {\varepsilon}^{-1}\right), 1\right)\\
\end{array}
\end{array}
if x < -2.3e13Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites65.0%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6436.1
Applied rewrites36.1%
if -2.3e13 < x < -2.2999999999999998e-246Initial program 68.8%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites71.2%
Taylor expanded in eps around 0
Applied rewrites84.2%
if -2.2999999999999998e-246 < x < 4.9999999999999998e274Initial program 84.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites61.6%
if 4.9999999999999998e274 < x Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites3.1%
Taylor expanded in eps around 0
Applied rewrites71.9%
Final simplification63.5%
(FPCore (x eps)
:precision binary64
(if (<= eps 8200.0)
(* (* 2.0 (/ (+ 1.0 x) (exp x))) 0.5)
(if (<= eps 6e+210)
(/ (- (* (+ 1.0 (pow eps -1.0)) (exp (- x))) -1.0) 2.0)
(fma
(* 0.5 x)
(+ (/ (/ (fma eps eps -1.0) (- eps -1.0)) eps) (+ (- eps 1.0) (- eps)))
1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 8200.0) {
tmp = (2.0 * ((1.0 + x) / exp(x))) * 0.5;
} else if (eps <= 6e+210) {
tmp = (((1.0 + pow(eps, -1.0)) * exp(-x)) - -1.0) / 2.0;
} else {
tmp = fma((0.5 * x), (((fma(eps, eps, -1.0) / (eps - -1.0)) / eps) + ((eps - 1.0) + -eps)), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 8200.0) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / exp(x))) * 0.5); elseif (eps <= 6e+210) tmp = Float64(Float64(Float64(Float64(1.0 + (eps ^ -1.0)) * exp(Float64(-x))) - -1.0) / 2.0); else tmp = fma(Float64(0.5 * x), Float64(Float64(Float64(fma(eps, eps, -1.0) / Float64(eps - -1.0)) / eps) + Float64(Float64(eps - 1.0) + Float64(-eps))), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 8200.0], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[eps, 6e+210], N[(N[(N[(N[(1.0 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(N[(N[(eps * eps + -1.0), $MachinePrecision] / N[(eps - -1.0), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] + N[(N[(eps - 1.0), $MachinePrecision] + (-eps)), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 8200:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{e^{x}}\right) \cdot 0.5\\
\mathbf{elif}\;\varepsilon \leq 6 \cdot 10^{+210}:\\
\;\;\;\;\frac{\left(1 + {\varepsilon}^{-1}\right) \cdot e^{-x} - -1}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \frac{\frac{\mathsf{fma}\left(\varepsilon, \varepsilon, -1\right)}{\varepsilon - -1}}{\varepsilon} + \left(\left(\varepsilon - 1\right) + \left(-\varepsilon\right)\right), 1\right)\\
\end{array}
\end{array}
if eps < 8200Initial program 75.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.1%
if 8200 < eps < 6.00000000000000044e210Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6498.7
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites72.3%
Taylor expanded in eps around 0
neg-mul-1N/A
lower-neg.f6453.6
Applied rewrites53.6%
if 6.00000000000000044e210 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites7.2%
Taylor expanded in eps around inf
Applied rewrites7.2%
Applied rewrites7.5%
Applied rewrites58.5%
Final simplification63.0%
(FPCore (x eps)
:precision binary64
(if (<= eps 1.0)
(* (* 2.0 (/ (+ 1.0 x) (exp x))) 0.5)
(if (<= eps 9.5e+179)
(fma (* 0.3333333333333333 x) (* x x) 1.0)
(fma
(* 0.5 x)
(+ (/ (/ (fma eps eps -1.0) (- eps -1.0)) eps) (+ (- eps 1.0) (- eps)))
1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 1.0) {
tmp = (2.0 * ((1.0 + x) / exp(x))) * 0.5;
} else if (eps <= 9.5e+179) {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
} else {
tmp = fma((0.5 * x), (((fma(eps, eps, -1.0) / (eps - -1.0)) / eps) + ((eps - 1.0) + -eps)), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 1.0) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / exp(x))) * 0.5); elseif (eps <= 9.5e+179) tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); else tmp = fma(Float64(0.5 * x), Float64(Float64(Float64(fma(eps, eps, -1.0) / Float64(eps - -1.0)) / eps) + Float64(Float64(eps - 1.0) + Float64(-eps))), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 1.0], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[eps, 9.5e+179], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(N[(N[(eps * eps + -1.0), $MachinePrecision] / N[(eps - -1.0), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] + N[(N[(eps - 1.0), $MachinePrecision] + (-eps)), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{e^{x}}\right) \cdot 0.5\\
\mathbf{elif}\;\varepsilon \leq 9.5 \cdot 10^{+179}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \frac{\frac{\mathsf{fma}\left(\varepsilon, \varepsilon, -1\right)}{\varepsilon - -1}}{\varepsilon} + \left(\left(\varepsilon - 1\right) + \left(-\varepsilon\right)\right), 1\right)\\
\end{array}
\end{array}
if eps < 1Initial program 74.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.9%
if 1 < eps < 9.5e179Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites40.7%
Taylor expanded in x around 0
Applied rewrites56.0%
Taylor expanded in x around inf
Applied rewrites56.0%
if 9.5e179 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites11.7%
Taylor expanded in eps around inf
Applied rewrites11.7%
Applied rewrites11.7%
Applied rewrites47.2%
(FPCore (x eps)
:precision binary64
(if (<= eps 1.0)
(* (+ x 1.0) (exp (- x)))
(if (<= eps 9.5e+179)
(fma (* 0.3333333333333333 x) (* x x) 1.0)
(fma
(* 0.5 x)
(+ (/ (/ (fma eps eps -1.0) (- eps -1.0)) eps) (+ (- eps 1.0) (- eps)))
1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 1.0) {
tmp = (x + 1.0) * exp(-x);
} else if (eps <= 9.5e+179) {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
} else {
tmp = fma((0.5 * x), (((fma(eps, eps, -1.0) / (eps - -1.0)) / eps) + ((eps - 1.0) + -eps)), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 1.0) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); elseif (eps <= 9.5e+179) tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); else tmp = fma(Float64(0.5 * x), Float64(Float64(Float64(fma(eps, eps, -1.0) / Float64(eps - -1.0)) / eps) + Float64(Float64(eps - 1.0) + Float64(-eps))), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 1.0], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 9.5e+179], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(N[(N[(eps * eps + -1.0), $MachinePrecision] / N[(eps - -1.0), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] + N[(N[(eps - 1.0), $MachinePrecision] + (-eps)), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{elif}\;\varepsilon \leq 9.5 \cdot 10^{+179}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \frac{\frac{\mathsf{fma}\left(\varepsilon, \varepsilon, -1\right)}{\varepsilon - -1}}{\varepsilon} + \left(\left(\varepsilon - 1\right) + \left(-\varepsilon\right)\right), 1\right)\\
\end{array}
\end{array}
if eps < 1Initial program 74.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.9%
Applied rewrites66.9%
if 1 < eps < 9.5e179Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites40.7%
Taylor expanded in x around 0
Applied rewrites56.0%
Taylor expanded in x around inf
Applied rewrites56.0%
if 9.5e179 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites11.7%
Taylor expanded in eps around inf
Applied rewrites11.7%
Applied rewrites11.7%
Applied rewrites47.2%
(FPCore (x eps)
:precision binary64
(if (<= eps 1020000000.0)
(*
(*
2.0
(/ (+ 1.0 x) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0)))
0.5)
(if (<= eps 9.5e+179)
(fma (* 0.3333333333333333 x) (* x x) 1.0)
(fma
(* 0.5 x)
(+ (/ (/ (fma eps eps -1.0) (- eps -1.0)) eps) (+ (- eps 1.0) (- eps)))
1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 1020000000.0) {
tmp = (2.0 * ((1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0))) * 0.5;
} else if (eps <= 9.5e+179) {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
} else {
tmp = fma((0.5 * x), (((fma(eps, eps, -1.0) / (eps - -1.0)) / eps) + ((eps - 1.0) + -eps)), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 1020000000.0) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0))) * 0.5); elseif (eps <= 9.5e+179) tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); else tmp = fma(Float64(0.5 * x), Float64(Float64(Float64(fma(eps, eps, -1.0) / Float64(eps - -1.0)) / eps) + Float64(Float64(eps - 1.0) + Float64(-eps))), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 1020000000.0], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[eps, 9.5e+179], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(N[(N[(eps * eps + -1.0), $MachinePrecision] / N[(eps - -1.0), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] + N[(N[(eps - 1.0), $MachinePrecision] + (-eps)), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1020000000:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\right) \cdot 0.5\\
\mathbf{elif}\;\varepsilon \leq 9.5 \cdot 10^{+179}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \frac{\frac{\mathsf{fma}\left(\varepsilon, \varepsilon, -1\right)}{\varepsilon - -1}}{\varepsilon} + \left(\left(\varepsilon - 1\right) + \left(-\varepsilon\right)\right), 1\right)\\
\end{array}
\end{array}
if eps < 1.02e9Initial program 75.4%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.9%
Taylor expanded in x around 0
Applied rewrites61.9%
if 1.02e9 < eps < 9.5e179Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites39.1%
Taylor expanded in x around 0
Applied rewrites55.4%
Taylor expanded in x around inf
Applied rewrites55.4%
if 9.5e179 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites11.7%
Taylor expanded in eps around inf
Applied rewrites11.7%
Applied rewrites11.7%
Applied rewrites47.2%
(FPCore (x eps)
:precision binary64
(if (<= eps 1020000000.0)
(*
(*
2.0
(/ (+ 1.0 x) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0)))
0.5)
(if (<= eps 1.3e+235)
(fma (* 0.3333333333333333 x) (* x x) 1.0)
(fma (- eps 1.0) (* (+ (/ x eps) x) 0.5) (fma (* 0.5 x) (- eps) 1.0)))))
double code(double x, double eps) {
double tmp;
if (eps <= 1020000000.0) {
tmp = (2.0 * ((1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0))) * 0.5;
} else if (eps <= 1.3e+235) {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
} else {
tmp = fma((eps - 1.0), (((x / eps) + x) * 0.5), fma((0.5 * x), -eps, 1.0));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 1020000000.0) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0))) * 0.5); elseif (eps <= 1.3e+235) tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); else tmp = fma(Float64(eps - 1.0), Float64(Float64(Float64(x / eps) + x) * 0.5), fma(Float64(0.5 * x), Float64(-eps), 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 1020000000.0], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[eps, 1.3e+235], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(eps - 1.0), $MachinePrecision] * N[(N[(N[(x / eps), $MachinePrecision] + x), $MachinePrecision] * 0.5), $MachinePrecision] + N[(N[(0.5 * x), $MachinePrecision] * (-eps) + 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1020000000:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\right) \cdot 0.5\\
\mathbf{elif}\;\varepsilon \leq 1.3 \cdot 10^{+235}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon - 1, \left(\frac{x}{\varepsilon} + x\right) \cdot 0.5, \mathsf{fma}\left(0.5 \cdot x, -\varepsilon, 1\right)\right)\\
\end{array}
\end{array}
if eps < 1.02e9Initial program 75.4%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.9%
Taylor expanded in x around 0
Applied rewrites61.9%
if 1.02e9 < eps < 1.2999999999999999e235Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites34.4%
Taylor expanded in x around 0
Applied rewrites50.5%
Taylor expanded in x around inf
Applied rewrites50.5%
if 1.2999999999999999e235 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites7.7%
Taylor expanded in eps around inf
Applied rewrites7.7%
Applied rewrites20.4%
Taylor expanded in x around 0
Applied rewrites20.4%
(FPCore (x eps)
:precision binary64
(if (<= x -215.0)
(fma (- eps 1.0) (* (/ x eps) 0.5) (fma (* 0.5 x) (- eps) 1.0))
(if (<= x 1.8)
(fma (fma (fma -0.125 x 0.3333333333333333) x -0.5) (* x x) 1.0)
(if (<= x 5e+274) 0.0 (fma (* 0.3333333333333333 x) (* x x) 1.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -215.0) {
tmp = fma((eps - 1.0), ((x / eps) * 0.5), fma((0.5 * x), -eps, 1.0));
} else if (x <= 1.8) {
tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), (x * x), 1.0);
} else if (x <= 5e+274) {
tmp = 0.0;
} else {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -215.0) tmp = fma(Float64(eps - 1.0), Float64(Float64(x / eps) * 0.5), fma(Float64(0.5 * x), Float64(-eps), 1.0)); elseif (x <= 1.8) tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), Float64(x * x), 1.0); elseif (x <= 5e+274) tmp = 0.0; else tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -215.0], N[(N[(eps - 1.0), $MachinePrecision] * N[(N[(x / eps), $MachinePrecision] * 0.5), $MachinePrecision] + N[(N[(0.5 * x), $MachinePrecision] * (-eps) + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.8], N[(N[(N[(-0.125 * x + 0.3333333333333333), $MachinePrecision] * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 5e+274], 0.0, N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -215:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon - 1, \frac{x}{\varepsilon} \cdot 0.5, \mathsf{fma}\left(0.5 \cdot x, -\varepsilon, 1\right)\right)\\
\mathbf{elif}\;x \leq 1.8:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.125, x, 0.3333333333333333\right), x, -0.5\right), x \cdot x, 1\right)\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+274}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -215Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites3.2%
Taylor expanded in eps around inf
Applied rewrites3.1%
Applied rewrites21.9%
Taylor expanded in eps around 0
Applied rewrites21.4%
if -215 < x < 1.80000000000000004Initial program 68.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites72.8%
Taylor expanded in x around 0
Applied rewrites72.7%
if 1.80000000000000004 < x < 4.9999999999999998e274Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites3.1%
Taylor expanded in eps around inf
Applied rewrites2.4%
Applied rewrites13.9%
Taylor expanded in eps around 0
Applied rewrites51.5%
if 4.9999999999999998e274 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites15.6%
Taylor expanded in x around 0
Applied rewrites85.9%
Taylor expanded in x around inf
Applied rewrites85.9%
(FPCore (x eps) :precision binary64 (if (<= eps 1020000000.0) (* (* 2.0 (/ (+ 1.0 x) (fma (fma 0.5 x 1.0) x 1.0))) 0.5) (fma (* 0.3333333333333333 x) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (eps <= 1020000000.0) {
tmp = (2.0 * ((1.0 + x) / fma(fma(0.5, x, 1.0), x, 1.0))) * 0.5;
} else {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 1020000000.0) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / fma(fma(0.5, x, 1.0), x, 1.0))) * 0.5); else tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 1020000000.0], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[(N[(0.5 * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1020000000:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right)}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\end{array}
\end{array}
if eps < 1.02e9Initial program 75.4%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.9%
Taylor expanded in x around 0
Applied rewrites57.8%
if 1.02e9 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites27.4%
Taylor expanded in x around 0
Applied rewrites44.3%
Taylor expanded in x around inf
Applied rewrites44.3%
(FPCore (x eps) :precision binary64 (if (<= x 550.0) 1.0 (if (<= x 5e+274) 0.0 (fma (* 0.3333333333333333 x) (* x x) 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= 550.0) {
tmp = 1.0;
} else if (x <= 5e+274) {
tmp = 0.0;
} else {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 550.0) tmp = 1.0; elseif (x <= 5e+274) tmp = 0.0; else tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 550.0], 1.0, If[LessEqual[x, 5e+274], 0.0, N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 550:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 5 \cdot 10^{+274}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < 550Initial program 75.8%
Taylor expanded in x around 0
Applied rewrites56.8%
if 550 < x < 4.9999999999999998e274Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites3.1%
Taylor expanded in eps around inf
Applied rewrites2.4%
Applied rewrites13.9%
Taylor expanded in eps around 0
Applied rewrites51.5%
if 4.9999999999999998e274 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites15.6%
Taylor expanded in x around 0
Applied rewrites85.9%
Taylor expanded in x around inf
Applied rewrites85.9%
(FPCore (x eps) :precision binary64 (if (<= x 550.0) 1.0 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 550.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 550.0d0) then
tmp = 1.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 550.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 550.0: tmp = 1.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 550.0) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 550.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 550.0], 1.0, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 550:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 550Initial program 75.8%
Taylor expanded in x around 0
Applied rewrites56.8%
if 550 < x Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites3.1%
Taylor expanded in eps around inf
Applied rewrites2.4%
Applied rewrites14.0%
Taylor expanded in eps around 0
Applied rewrites48.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 83.3%
Taylor expanded in x around 0
Applied rewrites40.0%
herbie shell --seed 2024314
(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))