
(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 18 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 57.4%
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
(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((eps ^ -1.0) - Float64(-1.0 / exp(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[Power[eps, -1.0], $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * eps + x), $MachinePrecision]], $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{{\varepsilon}^{-1} - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\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 57.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 x around 0
lower--.f64N/A
lower-/.f6471.0
Applied rewrites71.0%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6411.6
Applied rewrites11.6%
Taylor expanded in x around 0
Applied rewrites3.1%
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.f6431.1
Applied rewrites31.1%
Final simplification71.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (+ 1.0 (pow eps -1.0)) (exp (* (+ -1.0 eps) x)))))
(if (<= (- t_0 (* (- (pow eps -1.0) 1.0) (exp (* (- -1.0 eps) x)))) 4.0)
(* (* 2.0 (/ (+ 1.0 x) (exp x))) 0.5)
(/ (- t_0 -1.0) 2.0))))
double code(double x, double eps) {
double t_0 = (1.0 + pow(eps, -1.0)) * exp(((-1.0 + eps) * x));
double tmp;
if ((t_0 - ((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 - -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))) * exp((((-1.0d0) + eps) * x))
if ((t_0 - (((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 - (-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)) * Math.exp(((-1.0 + eps) * x));
double tmp;
if ((t_0 - ((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 - -1.0) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = (1.0 + math.pow(eps, -1.0)) * math.exp(((-1.0 + eps) * x)) tmp = 0 if (t_0 - ((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 - -1.0) / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(1.0 + (eps ^ -1.0)) * exp(Float64(Float64(-1.0 + eps) * x))) tmp = 0.0 if (Float64(t_0 - 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(t_0 - -1.0) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = (1.0 + (eps ^ -1.0)) * exp(((-1.0 + eps) * x)); tmp = 0.0; if ((t_0 - (((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 - -1.0) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - 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[(t$95$0 - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + {\varepsilon}^{-1}\right) \cdot e^{\left(-1 + \varepsilon\right) \cdot x}\\
\mathbf{if}\;t\_0 - \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 - -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 57.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 rewrites71.0%
Final simplification87.7%
(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)
(/ (+ 1.0 x) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
(/
(* (fma (* x x) 0.1111111111111111 -0.25) (* x x))
(fma 0.3333333333333333 x 0.5))))
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 = (1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
} else {
tmp = (fma((x * x), 0.1111111111111111, -0.25) * (x * x)) / fma(0.3333333333333333, x, 0.5);
}
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(1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)); else tmp = Float64(Float64(fma(Float64(x * x), 0.1111111111111111, -0.25) * Float64(x * x)) / fma(0.3333333333333333, x, 0.5)); 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[(1.0 + x), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x * x), $MachinePrecision] * 0.1111111111111111 + -0.25), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(0.3333333333333333 * x + 0.5), $MachinePrecision]), $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:\\
\;\;\;\;\frac{1 + x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x \cdot x, 0.1111111111111111, -0.25\right) \cdot \left(x \cdot x\right)}{\mathsf{fma}\left(0.3333333333333333, x, 0.5\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 57.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites89.4%
Applied rewrites89.4%
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 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.6%
Taylor expanded in x around 0
Applied rewrites27.9%
Taylor expanded in x around inf
Applied rewrites27.3%
Applied rewrites31.6%
Final simplification65.3%
(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))))
0.2)
(/ (+ 1.0 x) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
(* (+ x 1.0) (fma (fma 0.5 x -1.0) x 1.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)))) <= 0.2) {
tmp = (1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
} else {
tmp = (x + 1.0) * fma(fma(0.5, x, -1.0), x, 1.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)))) <= 0.2) tmp = Float64(Float64(1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)); else tmp = Float64(Float64(x + 1.0) * fma(fma(0.5, x, -1.0), x, 1.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], 0.2], N[(N[(1.0 + x), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] * N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $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 0.2:\\
\;\;\;\;\frac{1 + x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(x + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 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))))) < 0.20000000000000001Initial program 42.5%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites86.0%
Applied rewrites86.0%
if 0.20000000000000001 < (-.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 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites28.1%
Applied rewrites28.1%
Taylor expanded in x around 0
Applied rewrites47.2%
Final simplification63.7%
(FPCore (x eps)
:precision binary64
(if (<= eps 1.95e-13)
(* (* 2.0 (/ (+ 1.0 x) (exp x))) 0.5)
(if (or (<= eps 1.72e+103) (not (<= eps 8e+184)))
(/
(-
(* (+ 1.0 (pow eps -1.0)) (exp (* (+ -1.0 eps) x)))
(- (pow eps -1.0) 1.0))
2.0)
(/ (- (+ (pow eps -1.0) 1.0) (/ -1.0 (exp (fma x eps x)))) 2.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 1.95e-13) {
tmp = (2.0 * ((1.0 + x) / exp(x))) * 0.5;
} else if ((eps <= 1.72e+103) || !(eps <= 8e+184)) {
tmp = (((1.0 + pow(eps, -1.0)) * exp(((-1.0 + eps) * x))) - (pow(eps, -1.0) - 1.0)) / 2.0;
} else {
tmp = ((pow(eps, -1.0) + 1.0) - (-1.0 / exp(fma(x, eps, x)))) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 1.95e-13) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / exp(x))) * 0.5); elseif ((eps <= 1.72e+103) || !(eps <= 8e+184)) tmp = Float64(Float64(Float64(Float64(1.0 + (eps ^ -1.0)) * exp(Float64(Float64(-1.0 + eps) * x))) - Float64((eps ^ -1.0) - 1.0)) / 2.0); else tmp = Float64(Float64(Float64((eps ^ -1.0) + 1.0) - Float64(-1.0 / exp(fma(x, eps, x)))) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 1.95e-13], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[Or[LessEqual[eps, 1.72e+103], N[Not[LessEqual[eps, 8e+184]], $MachinePrecision]], N[(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[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[Power[eps, -1.0], $MachinePrecision] + 1.0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1.95 \cdot 10^{-13}:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{e^{x}}\right) \cdot 0.5\\
\mathbf{elif}\;\varepsilon \leq 1.72 \cdot 10^{+103} \lor \neg \left(\varepsilon \leq 8 \cdot 10^{+184}\right):\\
\;\;\;\;\frac{\left(1 + {\varepsilon}^{-1}\right) \cdot e^{\left(-1 + \varepsilon\right) \cdot x} - \left({\varepsilon}^{-1} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left({\varepsilon}^{-1} + 1\right) - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\right)}}}{2}\\
\end{array}
\end{array}
if eps < 1.95000000000000002e-13Initial program 65.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.3%
if 1.95000000000000002e-13 < eps < 1.72e103 or 8.00000000000000014e184 < eps Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6483.1
Applied rewrites83.1%
if 1.72e103 < eps < 8.00000000000000014e184Initial 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
+-commutativeN/A
lower-+.f64N/A
lower-/.f6476.8
Applied rewrites76.8%
Final simplification73.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (pow eps -1.0) 1.0)))
(if (<= x -7.2e+146)
(/
(-
(fma
(fma (/ x eps) (fma -0.16666666666666666 x 0.5) (/ -1.0 eps))
x
(pow eps -1.0))
(- (pow eps -1.0) 1.0))
2.0)
(if (<= x -1.4e-176)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 5.4e+246)
(* (* 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 <= -7.2e+146) {
tmp = (fma(fma((x / eps), fma(-0.16666666666666666, x, 0.5), (-1.0 / eps)), x, pow(eps, -1.0)) - (pow(eps, -1.0) - 1.0)) / 2.0;
} else if (x <= -1.4e-176) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 5.4e+246) {
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 <= -7.2e+146) tmp = Float64(Float64(fma(fma(Float64(x / eps), fma(-0.16666666666666666, x, 0.5), Float64(-1.0 / eps)), x, (eps ^ -1.0)) - Float64((eps ^ -1.0) - 1.0)) / 2.0); elseif (x <= -1.4e-176) 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 <= 5.4e+246) 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, -7.2e+146], N[(N[(N[(N[(N[(x / eps), $MachinePrecision] * N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] * x + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] - N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.4e-176], 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, 5.4e+246], 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 -7.2 \cdot 10^{+146}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{x}{\varepsilon}, \mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), \frac{-1}{\varepsilon}\right), x, {\varepsilon}^{-1}\right) - \left({\varepsilon}^{-1} - 1\right)}{2}\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-176}:\\
\;\;\;\;\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.4 \cdot 10^{+246}:\\
\;\;\;\;\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 < -7.1999999999999997e146Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6476.9
Applied rewrites76.9%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6423.8
Applied rewrites23.8%
Taylor expanded in x around 0
Applied rewrites23.8%
if -7.1999999999999997e146 < x < -1.4000000000000001e-176Initial program 71.3%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites45.3%
Taylor expanded in eps around 0
Applied rewrites51.8%
if -1.4000000000000001e-176 < x < 5.4e246Initial program 72.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites72.9%
if 5.4e246 < 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 rewrites55.1%
Final simplification63.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (pow eps -1.0) 1.0)))
(if (<= x -7.2e+146)
(/
(-
(fma
(fma (/ x eps) (fma -0.16666666666666666 x 0.5) (/ -1.0 eps))
x
(pow eps -1.0))
(- (pow eps -1.0) 1.0))
2.0)
(if (<= x -1.4e-176)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 5.4e+246)
(* (+ x 1.0) (exp (- x)))
(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 <= -7.2e+146) {
tmp = (fma(fma((x / eps), fma(-0.16666666666666666, x, 0.5), (-1.0 / eps)), x, pow(eps, -1.0)) - (pow(eps, -1.0) - 1.0)) / 2.0;
} else if (x <= -1.4e-176) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 5.4e+246) {
tmp = (x + 1.0) * exp(-x);
} 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 <= -7.2e+146) tmp = Float64(Float64(fma(fma(Float64(x / eps), fma(-0.16666666666666666, x, 0.5), Float64(-1.0 / eps)), x, (eps ^ -1.0)) - Float64((eps ^ -1.0) - 1.0)) / 2.0); elseif (x <= -1.4e-176) 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 <= 5.4e+246) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); 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, -7.2e+146], N[(N[(N[(N[(N[(x / eps), $MachinePrecision] * N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] * x + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] - N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.4e-176], 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, 5.4e+246], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $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 -7.2 \cdot 10^{+146}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{x}{\varepsilon}, \mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), \frac{-1}{\varepsilon}\right), x, {\varepsilon}^{-1}\right) - \left({\varepsilon}^{-1} - 1\right)}{2}\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-176}:\\
\;\;\;\;\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.4 \cdot 10^{+246}:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\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 < -7.1999999999999997e146Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6476.9
Applied rewrites76.9%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6423.8
Applied rewrites23.8%
Taylor expanded in x around 0
Applied rewrites23.8%
if -7.1999999999999997e146 < x < -1.4000000000000001e-176Initial program 71.3%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites45.3%
Taylor expanded in eps around 0
Applied rewrites51.8%
if -1.4000000000000001e-176 < x < 5.4e246Initial program 72.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites72.9%
Applied rewrites72.9%
if 5.4e246 < 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 rewrites55.1%
Final simplification63.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow eps -1.0) 1.0)) (t_1 (+ (pow eps -1.0) 1.0)))
(if (<= x -7.2e+146)
(/
(-
(fma
(fma (/ x eps) (fma -0.16666666666666666 x 0.5) (/ -1.0 eps))
x
(pow eps -1.0))
t_0)
2.0)
(if (<= x -1.4e-176)
(fma (* 0.5 x) (fma (- eps 1.0) t_1 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 370.0)
(/ (+ 1.0 x) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
(if (<= x 5.4e+246)
(/ (- t_1 t_0) 2.0)
(fma (* 0.5 x) (fma (- eps 1.0) t_1 (pow eps -1.0)) 1.0)))))))
double code(double x, double eps) {
double t_0 = pow(eps, -1.0) - 1.0;
double t_1 = pow(eps, -1.0) + 1.0;
double tmp;
if (x <= -7.2e+146) {
tmp = (fma(fma((x / eps), fma(-0.16666666666666666, x, 0.5), (-1.0 / eps)), x, pow(eps, -1.0)) - t_0) / 2.0;
} else if (x <= -1.4e-176) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_1, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 370.0) {
tmp = (1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
} else if (x <= 5.4e+246) {
tmp = (t_1 - t_0) / 2.0;
} else {
tmp = fma((0.5 * x), fma((eps - 1.0), t_1, pow(eps, -1.0)), 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64((eps ^ -1.0) - 1.0) t_1 = Float64((eps ^ -1.0) + 1.0) tmp = 0.0 if (x <= -7.2e+146) tmp = Float64(Float64(fma(fma(Float64(x / eps), fma(-0.16666666666666666, x, 0.5), Float64(-1.0 / eps)), x, (eps ^ -1.0)) - t_0) / 2.0); elseif (x <= -1.4e-176) tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), t_1, Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0); elseif (x <= 370.0) tmp = Float64(Float64(1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)); elseif (x <= 5.4e+246) tmp = Float64(Float64(t_1 - t_0) / 2.0); else tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), t_1, (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]}, Block[{t$95$1 = N[(N[Power[eps, -1.0], $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -7.2e+146], N[(N[(N[(N[(N[(x / eps), $MachinePrecision] * N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] * x + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.4e-176], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * t$95$1 + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 370.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], If[LessEqual[x, 5.4e+246], N[(N[(t$95$1 - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * t$95$1 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\varepsilon}^{-1} - 1\\
t_1 := {\varepsilon}^{-1} + 1\\
\mathbf{if}\;x \leq -7.2 \cdot 10^{+146}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{x}{\varepsilon}, \mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), \frac{-1}{\varepsilon}\right), x, {\varepsilon}^{-1}\right) - t\_0}{2}\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-176}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, t\_1, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
\mathbf{elif}\;x \leq 370:\\
\;\;\;\;\frac{1 + x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{+246}:\\
\;\;\;\;\frac{t\_1 - t\_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, t\_1, {\varepsilon}^{-1}\right), 1\right)\\
\end{array}
\end{array}
if x < -7.1999999999999997e146Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6476.9
Applied rewrites76.9%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6423.8
Applied rewrites23.8%
Taylor expanded in x around 0
Applied rewrites23.8%
if -7.1999999999999997e146 < x < -1.4000000000000001e-176Initial program 71.3%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites45.3%
Taylor expanded in eps around 0
Applied rewrites51.8%
if -1.4000000000000001e-176 < x < 370Initial program 50.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.8%
Taylor expanded in x around 0
Applied rewrites84.0%
Applied rewrites84.0%
if 370 < x < 5.4e246Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6434.1
Applied rewrites34.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6458.1
Applied rewrites58.1%
if 5.4e246 < 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 rewrites55.1%
Final simplification63.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow eps -1.0) 1.0)) (t_1 (+ (pow eps -1.0) 1.0)))
(if (<= x -1.1e+183)
(/ (- (fma (fma (/ 0.5 eps) x (/ -1.0 eps)) x (pow eps -1.0)) t_0) 2.0)
(if (<= x -1.4e-176)
(fma (* 0.5 x) (fma (- eps 1.0) t_1 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 370.0)
(/ (+ 1.0 x) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
(if (<= x 5.4e+246)
(/ (- t_1 t_0) 2.0)
(fma (* 0.5 x) (fma (- eps 1.0) t_1 (pow eps -1.0)) 1.0)))))))
double code(double x, double eps) {
double t_0 = pow(eps, -1.0) - 1.0;
double t_1 = pow(eps, -1.0) + 1.0;
double tmp;
if (x <= -1.1e+183) {
tmp = (fma(fma((0.5 / eps), x, (-1.0 / eps)), x, pow(eps, -1.0)) - t_0) / 2.0;
} else if (x <= -1.4e-176) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_1, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 370.0) {
tmp = (1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
} else if (x <= 5.4e+246) {
tmp = (t_1 - t_0) / 2.0;
} else {
tmp = fma((0.5 * x), fma((eps - 1.0), t_1, pow(eps, -1.0)), 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64((eps ^ -1.0) - 1.0) t_1 = Float64((eps ^ -1.0) + 1.0) tmp = 0.0 if (x <= -1.1e+183) tmp = Float64(Float64(fma(fma(Float64(0.5 / eps), x, Float64(-1.0 / eps)), x, (eps ^ -1.0)) - t_0) / 2.0); elseif (x <= -1.4e-176) tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), t_1, Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0); elseif (x <= 370.0) tmp = Float64(Float64(1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)); elseif (x <= 5.4e+246) tmp = Float64(Float64(t_1 - t_0) / 2.0); else tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), t_1, (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]}, Block[{t$95$1 = N[(N[Power[eps, -1.0], $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.1e+183], N[(N[(N[(N[(N[(0.5 / eps), $MachinePrecision] * x + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] * x + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.4e-176], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * t$95$1 + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 370.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], If[LessEqual[x, 5.4e+246], N[(N[(t$95$1 - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * t$95$1 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\varepsilon}^{-1} - 1\\
t_1 := {\varepsilon}^{-1} + 1\\
\mathbf{if}\;x \leq -1.1 \cdot 10^{+183}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{0.5}{\varepsilon}, x, \frac{-1}{\varepsilon}\right), x, {\varepsilon}^{-1}\right) - t\_0}{2}\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-176}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, t\_1, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
\mathbf{elif}\;x \leq 370:\\
\;\;\;\;\frac{1 + x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{+246}:\\
\;\;\;\;\frac{t\_1 - t\_0}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, t\_1, {\varepsilon}^{-1}\right), 1\right)\\
\end{array}
\end{array}
if x < -1.09999999999999995e183Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6473.1
Applied rewrites73.1%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6427.8
Applied rewrites27.8%
Taylor expanded in x around 0
Applied rewrites12.0%
if -1.09999999999999995e183 < x < -1.4000000000000001e-176Initial program 72.8%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites43.1%
Taylor expanded in eps around 0
Applied rewrites49.1%
if -1.4000000000000001e-176 < x < 370Initial program 50.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.8%
Taylor expanded in x around 0
Applied rewrites84.0%
Applied rewrites84.0%
if 370 < x < 5.4e246Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6434.1
Applied rewrites34.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6458.1
Applied rewrites58.1%
if 5.4e246 < 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 rewrites55.1%
Final simplification62.4%
(FPCore (x eps)
:precision binary64
(if (<= eps 1.65)
(* (* 2.0 (/ (+ 1.0 x) (exp x))) 0.5)
(if (or (<= eps 1.72e+103) (not (<= eps 8e+184)))
(/ (- (* (+ 1.0 (pow eps -1.0)) (exp (* (+ -1.0 eps) x))) -1.0) 2.0)
(/ (- (+ (pow eps -1.0) 1.0) (/ -1.0 (exp (fma x eps x)))) 2.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 1.65) {
tmp = (2.0 * ((1.0 + x) / exp(x))) * 0.5;
} else if ((eps <= 1.72e+103) || !(eps <= 8e+184)) {
tmp = (((1.0 + pow(eps, -1.0)) * exp(((-1.0 + eps) * x))) - -1.0) / 2.0;
} else {
tmp = ((pow(eps, -1.0) + 1.0) - (-1.0 / exp(fma(x, eps, x)))) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 1.65) tmp = Float64(Float64(2.0 * Float64(Float64(1.0 + x) / exp(x))) * 0.5); elseif ((eps <= 1.72e+103) || !(eps <= 8e+184)) tmp = Float64(Float64(Float64(Float64(1.0 + (eps ^ -1.0)) * exp(Float64(Float64(-1.0 + eps) * x))) - -1.0) / 2.0); else tmp = Float64(Float64(Float64((eps ^ -1.0) + 1.0) - Float64(-1.0 / exp(fma(x, eps, x)))) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 1.65], N[(N[(2.0 * N[(N[(1.0 + x), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[Or[LessEqual[eps, 1.72e+103], N[Not[LessEqual[eps, 8e+184]], $MachinePrecision]], N[(N[(N[(N[(1.0 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[Power[eps, -1.0], $MachinePrecision] + 1.0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1.65:\\
\;\;\;\;\left(2 \cdot \frac{1 + x}{e^{x}}\right) \cdot 0.5\\
\mathbf{elif}\;\varepsilon \leq 1.72 \cdot 10^{+103} \lor \neg \left(\varepsilon \leq 8 \cdot 10^{+184}\right):\\
\;\;\;\;\frac{\left(1 + {\varepsilon}^{-1}\right) \cdot e^{\left(-1 + \varepsilon\right) \cdot x} - -1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left({\varepsilon}^{-1} + 1\right) - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\right)}}}{2}\\
\end{array}
\end{array}
if eps < 1.6499999999999999Initial program 65.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.4%
if 1.6499999999999999 < eps < 1.72e103 or 8.00000000000000014e184 < eps 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.f6497.9
Applied rewrites97.9%
Taylor expanded in x around 0
Applied rewrites80.6%
if 1.72e103 < eps < 8.00000000000000014e184Initial 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
+-commutativeN/A
lower-+.f64N/A
lower-/.f6476.8
Applied rewrites76.8%
Final simplification73.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (pow eps -1.0) 1.0)) (t_1 (- (pow eps -1.0) 1.0)))
(if (<= x -9.8e+42)
(/ (- (pow eps -1.0) (* (fma (- -1.0 eps) x 1.0) t_1)) 2.0)
(if (<= x -1.4e-176)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 370.0)
(/ (+ 1.0 x) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
(if (<= x 5.4e+246)
(/ (- t_0 t_1) 2.0)
(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 t_1 = pow(eps, -1.0) - 1.0;
double tmp;
if (x <= -9.8e+42) {
tmp = (pow(eps, -1.0) - (fma((-1.0 - eps), x, 1.0) * t_1)) / 2.0;
} else if (x <= -1.4e-176) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 370.0) {
tmp = (1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
} else if (x <= 5.4e+246) {
tmp = (t_0 - t_1) / 2.0;
} 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) t_1 = Float64((eps ^ -1.0) - 1.0) tmp = 0.0 if (x <= -9.8e+42) tmp = Float64(Float64((eps ^ -1.0) - Float64(fma(Float64(-1.0 - eps), x, 1.0) * t_1)) / 2.0); elseif (x <= -1.4e-176) 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 <= 370.0) tmp = Float64(Float64(1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)); elseif (x <= 5.4e+246) tmp = Float64(Float64(t_0 - t_1) / 2.0); 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]}, Block[{t$95$1 = N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[x, -9.8e+42], N[(N[(N[Power[eps, -1.0], $MachinePrecision] - N[(N[(N[(-1.0 - eps), $MachinePrecision] * x + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.4e-176], 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, 370.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], If[LessEqual[x, 5.4e+246], N[(N[(t$95$0 - t$95$1), $MachinePrecision] / 2.0), $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\\
t_1 := {\varepsilon}^{-1} - 1\\
\mathbf{if}\;x \leq -9.8 \cdot 10^{+42}:\\
\;\;\;\;\frac{{\varepsilon}^{-1} - \mathsf{fma}\left(-1 - \varepsilon, x, 1\right) \cdot t\_1}{2}\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-176}:\\
\;\;\;\;\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 370:\\
\;\;\;\;\frac{1 + x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{+246}:\\
\;\;\;\;\frac{t\_0 - t\_1}{2}\\
\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 < -9.8000000000000004e42Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6469.9
Applied rewrites69.9%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6431.0
Applied rewrites31.0%
Taylor expanded in x around 0
Applied rewrites3.1%
Taylor expanded in x around 0
associate--l+N/A
mul-1-negN/A
associate-*r*N/A
distribute-lft-neg-inN/A
distribute-lft1-inN/A
lower-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
neg-sub0N/A
associate--r+N/A
metadata-evalN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6421.3
Applied rewrites21.3%
if -9.8000000000000004e42 < x < -1.4000000000000001e-176Initial program 66.3%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites52.7%
Taylor expanded in eps around 0
Applied rewrites58.2%
if -1.4000000000000001e-176 < x < 370Initial program 50.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.8%
Taylor expanded in x around 0
Applied rewrites84.0%
Applied rewrites84.0%
if 370 < x < 5.4e246Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6434.1
Applied rewrites34.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6458.1
Applied rewrites58.1%
if 5.4e246 < 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 rewrites55.1%
Final simplification63.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (pow eps -1.0) 1.0)))
(if (<= x -1.5e+42)
(/ (- (/ (exp (- x)) eps) (- (pow eps -1.0) 1.0)) 2.0)
(if (<= x -1.4e-176)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 5.4e+246)
(* (* 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 <= -1.5e+42) {
tmp = ((exp(-x) / eps) - (pow(eps, -1.0) - 1.0)) / 2.0;
} else if (x <= -1.4e-176) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 5.4e+246) {
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 <= -1.5e+42) tmp = Float64(Float64(Float64(exp(Float64(-x)) / eps) - Float64((eps ^ -1.0) - 1.0)) / 2.0); elseif (x <= -1.4e-176) 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 <= 5.4e+246) 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, -1.5e+42], N[(N[(N[(N[Exp[(-x)], $MachinePrecision] / eps), $MachinePrecision] - N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.4e-176], 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, 5.4e+246], 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 -1.5 \cdot 10^{+42}:\\
\;\;\;\;\frac{\frac{e^{-x}}{\varepsilon} - \left({\varepsilon}^{-1} - 1\right)}{2}\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-176}:\\
\;\;\;\;\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.4 \cdot 10^{+246}:\\
\;\;\;\;\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 < -1.50000000000000014e42Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6469.9
Applied rewrites69.9%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6431.0
Applied rewrites31.0%
if -1.50000000000000014e42 < x < -1.4000000000000001e-176Initial program 66.3%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites52.7%
Taylor expanded in eps around 0
Applied rewrites58.2%
if -1.4000000000000001e-176 < x < 5.4e246Initial program 72.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites72.9%
if 5.4e246 < 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 rewrites55.1%
Final simplification64.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (pow eps -1.0) 1.0)))
(if (<= x -1.4e-176)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 370.0)
(/ (+ 1.0 x) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
(if (<= x 5.4e+246)
(/ (- t_0 (- (pow eps -1.0) 1.0)) 2.0)
(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 <= -1.4e-176) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 370.0) {
tmp = (1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
} else if (x <= 5.4e+246) {
tmp = (t_0 - (pow(eps, -1.0) - 1.0)) / 2.0;
} 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 <= -1.4e-176) 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 <= 370.0) tmp = Float64(Float64(1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)); elseif (x <= 5.4e+246) tmp = Float64(Float64(t_0 - Float64((eps ^ -1.0) - 1.0)) / 2.0); 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, -1.4e-176], 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, 370.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], If[LessEqual[x, 5.4e+246], N[(N[(t$95$0 - N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $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 -1.4 \cdot 10^{-176}:\\
\;\;\;\;\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 370:\\
\;\;\;\;\frac{1 + x}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{+246}:\\
\;\;\;\;\frac{t\_0 - \left({\varepsilon}^{-1} - 1\right)}{2}\\
\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 < -1.4000000000000001e-176Initial program 79.3%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites33.5%
Taylor expanded in eps around 0
Applied rewrites44.5%
if -1.4000000000000001e-176 < x < 370Initial program 50.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.8%
Taylor expanded in x around 0
Applied rewrites84.0%
Applied rewrites84.0%
if 370 < x < 5.4e246Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6434.1
Applied rewrites34.1%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6458.1
Applied rewrites58.1%
if 5.4e246 < 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 rewrites55.1%
Final simplification63.7%
(FPCore (x eps) :precision binary64 (if (<= x 2.9e+32) 1.0 (* (* (fma 0.3333333333333333 x -0.5) x) x)))
double code(double x, double eps) {
double tmp;
if (x <= 2.9e+32) {
tmp = 1.0;
} else {
tmp = (fma(0.3333333333333333, x, -0.5) * x) * x;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 2.9e+32) tmp = 1.0; else tmp = Float64(Float64(fma(0.3333333333333333, x, -0.5) * x) * x); end return tmp end
code[x_, eps_] := If[LessEqual[x, 2.9e+32], 1.0, N[(N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.9 \cdot 10^{+32}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right) \cdot x\right) \cdot x\\
\end{array}
\end{array}
if x < 2.90000000000000003e32Initial program 65.6%
Taylor expanded in x around 0
Applied rewrites58.3%
if 2.90000000000000003e32 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites48.1%
Taylor expanded in x around 0
Applied rewrites39.6%
Taylor expanded in x around inf
Applied rewrites39.6%
(FPCore (x eps) :precision binary64 (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))
double code(double x, double eps) {
return fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
function code(x, eps) return fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0) end
code[x_, eps_] := N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)
\end{array}
Initial program 75.5%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites58.7%
Taylor expanded in x around 0
Applied rewrites52.5%
(FPCore (x eps) :precision binary64 (fma (* 0.3333333333333333 x) (* x x) 1.0))
double code(double x, double eps) {
return fma((0.3333333333333333 * x), (x * x), 1.0);
}
function code(x, eps) return fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0) end
code[x_, eps_] := N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)
\end{array}
Initial program 75.5%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites58.7%
Taylor expanded in x around 0
Applied rewrites52.5%
Taylor expanded in x around inf
Applied rewrites52.5%
(FPCore (x eps) :precision binary64 1.0)
double code(double x, double eps) {
return 1.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0
end function
public static double code(double x, double eps) {
return 1.0;
}
def code(x, eps): return 1.0
function code(x, eps) return 1.0 end
function tmp = code(x, eps) tmp = 1.0; end
code[x_, eps_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 75.5%
Taylor expanded in x around 0
Applied rewrites42.3%
herbie shell --seed 2024309
(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))