
(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)) (exp (* (+ -1.0 eps) x)))
(* (- (pow eps -1.0) 1.0) (exp (* (- -1.0 eps) x))))))
(if (<= t_0 0.0) (* (+ x 1.0) (exp (- x))) (/ t_0 2.0))))
double code(double x, double eps) {
double t_0 = ((1.0 + pow(eps, -1.0)) * exp(((-1.0 + eps) * x))) - ((pow(eps, -1.0) - 1.0) * exp(((-1.0 - eps) * x)));
double tmp;
if (t_0 <= 0.0) {
tmp = (x + 1.0) * exp(-x);
} else {
tmp = t_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))) - (((eps ** (-1.0d0)) - 1.0d0) * exp((((-1.0d0) - eps) * x)))
if (t_0 <= 0.0d0) then
tmp = (x + 1.0d0) * exp(-x)
else
tmp = t_0 / 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))) - ((Math.pow(eps, -1.0) - 1.0) * Math.exp(((-1.0 - eps) * x)));
double tmp;
if (t_0 <= 0.0) {
tmp = (x + 1.0) * Math.exp(-x);
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = ((1.0 + math.pow(eps, -1.0)) * math.exp(((-1.0 + eps) * x))) - ((math.pow(eps, -1.0) - 1.0) * math.exp(((-1.0 - eps) * x))) tmp = 0 if t_0 <= 0.0: tmp = (x + 1.0) * math.exp(-x) else: tmp = t_0 / 2.0 return tmp
function code(x, eps) t_0 = 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)))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); else tmp = Float64(t_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))) - (((eps ^ -1.0) - 1.0) * exp(((-1.0 - eps) * x))); tmp = 0.0; if (t_0 <= 0.0) tmp = (x + 1.0) * exp(-x); else tmp = t_0 / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, 0.0], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{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))))) < 0.0Initial program 33.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Applied rewrites100.0%
if 0.0 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
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)
(* (+ x 1.0) (exp (- x)))
(/ (- (+ (pow eps -1.0) 1.0) (/ -1.0 (exp (fma eps x 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 = (x + 1.0) * exp(-x);
} else {
tmp = ((pow(eps, -1.0) + 1.0) - (-1.0 / exp(fma(eps, x, 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(x + 1.0) * exp(Float64(-x))); else tmp = Float64(Float64(Float64((eps ^ -1.0) + 1.0) - Float64(-1.0 / exp(fma(eps, x, 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[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Power[eps, -1.0], $MachinePrecision] + 1.0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(eps * x + 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(x + 1\right) \cdot e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left({\varepsilon}^{-1} + 1\right) - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, 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 50.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Applied rewrites100.0%
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
+-commutativeN/A
lower-+.f64N/A
lower-/.f6456.8
Applied rewrites56.8%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6456.8
Applied rewrites56.8%
Final simplification81.1%
(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.0)
(*
(*
2.0
(/ (+ 1.0 x) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0)))
0.5)
(/ (* (fma x x -1.0) (fma (fma 0.5 x -1.0) 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.0) {
tmp = (2.0 * ((1.0 + x) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0))) * 0.5;
} else {
tmp = (fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), 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.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); else tmp = Float64(Float64(fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), x, 1.0)) / Float64(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.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], N[(N[(N[(x * x + -1.0), $MachinePrecision] * N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] / N[(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:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, -1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right)}{x - 1}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 0.0Initial program 33.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites89.0%
if 0.0 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites26.0%
Applied rewrites26.0%
Taylor expanded in x around 0
Applied rewrites43.0%
Applied rewrites46.6%
Final simplification64.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.0)
(/ -1.0 (* (fma (fma 0.5 x 1.0) x 1.0) (- x 1.0)))
(/ (* (fma x x -1.0) (fma (fma 0.5 x -1.0) 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.0) {
tmp = -1.0 / (fma(fma(0.5, x, 1.0), x, 1.0) * (x - 1.0));
} else {
tmp = (fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), 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.0) tmp = Float64(-1.0 / Float64(fma(fma(0.5, x, 1.0), x, 1.0) * Float64(x - 1.0))); else tmp = Float64(Float64(fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), x, 1.0)) / Float64(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.0], N[(-1.0 / N[(N[(N[(0.5 * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x + -1.0), $MachinePrecision] * N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] / N[(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:\\
\;\;\;\;\frac{-1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right) \cdot \left(x - 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, -1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right)}{x - 1}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 0.0Initial program 33.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites84.3%
Applied rewrites72.9%
Taylor expanded in x around 0
Applied rewrites88.3%
if 0.0 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites26.0%
Applied rewrites26.0%
Taylor expanded in x around 0
Applied rewrites43.0%
Applied rewrites46.6%
Final simplification64.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))))
0.0)
(/ -1.0 (* (fma (fma 0.5 x 1.0) 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.0) {
tmp = -1.0 / (fma(fma(0.5, x, 1.0), 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.0) tmp = Float64(-1.0 / Float64(fma(fma(0.5, x, 1.0), x, 1.0) * Float64(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.0], N[(-1.0 / N[(N[(N[(0.5 * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x - 1.0), $MachinePrecision]), $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:\\
\;\;\;\;\frac{-1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right) \cdot \left(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.0Initial program 33.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites84.3%
Applied rewrites72.9%
Taylor expanded in x around 0
Applied rewrites88.3%
if 0.0 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites26.0%
Applied rewrites26.0%
Taylor expanded in x around 0
Applied rewrites43.0%
Final simplification61.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow eps -1.0) 1.0)))
(if (<= eps 1.0)
(* (+ x 1.0) (exp (- x)))
(if (<= eps 1.25e+264)
(/ (- (+ (pow eps -1.0) 1.0) (* t_0 (exp (* (- -1.0 eps) x)))) 2.0)
(/ (- (* (+ 1.0 (pow eps -1.0)) (exp (* (- eps 1.0) x))) t_0) 2.0)))))
double code(double x, double eps) {
double t_0 = pow(eps, -1.0) - 1.0;
double tmp;
if (eps <= 1.0) {
tmp = (x + 1.0) * exp(-x);
} else if (eps <= 1.25e+264) {
tmp = ((pow(eps, -1.0) + 1.0) - (t_0 * exp(((-1.0 - eps) * x)))) / 2.0;
} else {
tmp = (((1.0 + pow(eps, -1.0)) * exp(((eps - 1.0) * x))) - t_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 = (eps ** (-1.0d0)) - 1.0d0
if (eps <= 1.0d0) then
tmp = (x + 1.0d0) * exp(-x)
else if (eps <= 1.25d+264) then
tmp = (((eps ** (-1.0d0)) + 1.0d0) - (t_0 * exp((((-1.0d0) - eps) * x)))) / 2.0d0
else
tmp = (((1.0d0 + (eps ** (-1.0d0))) * exp(((eps - 1.0d0) * x))) - t_0) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.pow(eps, -1.0) - 1.0;
double tmp;
if (eps <= 1.0) {
tmp = (x + 1.0) * Math.exp(-x);
} else if (eps <= 1.25e+264) {
tmp = ((Math.pow(eps, -1.0) + 1.0) - (t_0 * Math.exp(((-1.0 - eps) * x)))) / 2.0;
} else {
tmp = (((1.0 + Math.pow(eps, -1.0)) * Math.exp(((eps - 1.0) * x))) - t_0) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = math.pow(eps, -1.0) - 1.0 tmp = 0 if eps <= 1.0: tmp = (x + 1.0) * math.exp(-x) elif eps <= 1.25e+264: tmp = ((math.pow(eps, -1.0) + 1.0) - (t_0 * math.exp(((-1.0 - eps) * x)))) / 2.0 else: tmp = (((1.0 + math.pow(eps, -1.0)) * math.exp(((eps - 1.0) * x))) - t_0) / 2.0 return tmp
function code(x, eps) t_0 = Float64((eps ^ -1.0) - 1.0) tmp = 0.0 if (eps <= 1.0) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); elseif (eps <= 1.25e+264) tmp = Float64(Float64(Float64((eps ^ -1.0) + 1.0) - Float64(t_0 * exp(Float64(Float64(-1.0 - eps) * x)))) / 2.0); else tmp = Float64(Float64(Float64(Float64(1.0 + (eps ^ -1.0)) * exp(Float64(Float64(eps - 1.0) * x))) - t_0) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = (eps ^ -1.0) - 1.0; tmp = 0.0; if (eps <= 1.0) tmp = (x + 1.0) * exp(-x); elseif (eps <= 1.25e+264) tmp = (((eps ^ -1.0) + 1.0) - (t_0 * exp(((-1.0 - eps) * x)))) / 2.0; else tmp = (((1.0 + (eps ^ -1.0)) * exp(((eps - 1.0) * x))) - t_0) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[eps, 1.0], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.25e+264], N[(N[(N[(N[Power[eps, -1.0], $MachinePrecision] + 1.0), $MachinePrecision] - N[(t$95$0 * N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(1.0 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\varepsilon}^{-1} - 1\\
\mathbf{if}\;\varepsilon \leq 1:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{elif}\;\varepsilon \leq 1.25 \cdot 10^{+264}:\\
\;\;\;\;\frac{\left({\varepsilon}^{-1} + 1\right) - t\_0 \cdot e^{\left(-1 - \varepsilon\right) \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + {\varepsilon}^{-1}\right) \cdot e^{\left(\varepsilon - 1\right) \cdot x} - t\_0}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 61.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.1%
Applied rewrites71.1%
if 1 < eps < 1.25000000000000008e264Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
if 1.25000000000000008e264 < eps Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6478.5
Applied rewrites78.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f6478.5
Applied rewrites78.5%
Final simplification72.0%
(FPCore (x eps)
:precision binary64
(if (<= eps 12.0)
(* (+ x 1.0) (exp (- x)))
(if (<= eps 1.25e+264)
(/ (- (+ (pow eps -1.0) 1.0) (/ -1.0 (exp (fma eps x x)))) 2.0)
(/
(-
(* (+ 1.0 (pow eps -1.0)) (exp (* (- eps 1.0) x)))
(- (pow eps -1.0) 1.0))
2.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 12.0) {
tmp = (x + 1.0) * exp(-x);
} else if (eps <= 1.25e+264) {
tmp = ((pow(eps, -1.0) + 1.0) - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
} else {
tmp = (((1.0 + pow(eps, -1.0)) * exp(((eps - 1.0) * x))) - (pow(eps, -1.0) - 1.0)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 12.0) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); elseif (eps <= 1.25e+264) tmp = Float64(Float64(Float64((eps ^ -1.0) + 1.0) - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); else tmp = Float64(Float64(Float64(Float64(1.0 + (eps ^ -1.0)) * exp(Float64(Float64(eps - 1.0) * x))) - Float64((eps ^ -1.0) - 1.0)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 12.0], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.25e+264], N[(N[(N[(N[Power[eps, -1.0], $MachinePrecision] + 1.0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[(1.0 + N[Power[eps, -1.0], $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 12:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{elif}\;\varepsilon \leq 1.25 \cdot 10^{+264}:\\
\;\;\;\;\frac{\left({\varepsilon}^{-1} + 1\right) - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + {\varepsilon}^{-1}\right) \cdot e^{\left(\varepsilon - 1\right) \cdot x} - \left({\varepsilon}^{-1} - 1\right)}{2}\\
\end{array}
\end{array}
if eps < 12Initial program 61.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.1%
Applied rewrites71.1%
if 12 < eps < 1.25000000000000008e264Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6473.8
Applied rewrites73.8%
if 1.25000000000000008e264 < eps Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6478.5
Applied rewrites78.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f6478.5
Applied rewrites78.5%
Final simplification72.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (pow eps -1.0) 1.0)))
(if (<= x -0.00022)
(/ (- t_0 (/ (fma (fma (- eps 1.0) x (- x 1.0)) eps (- 1.0 x)) eps)) 2.0)
(if (<= x -1.85e-195)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 6400000000000.0)
(/
(fma x x -1.0)
(fma (fma (fma 0.125 x 0.3333333333333333) x 0.5) (* x x) -1.0))
(if (or (<= x 8.5e+71) (not (<= x 1.6e+256)))
(/ (- t_0 (- (pow eps -1.0) 1.0)) 2.0)
(/ (* (fma x x -1.0) (fma (fma 0.5 x -1.0) x 1.0)) (- x 1.0))))))))
double code(double x, double eps) {
double t_0 = pow(eps, -1.0) + 1.0;
double tmp;
if (x <= -0.00022) {
tmp = (t_0 - (fma(fma((eps - 1.0), x, (x - 1.0)), eps, (1.0 - x)) / eps)) / 2.0;
} else if (x <= -1.85e-195) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 6400000000000.0) {
tmp = fma(x, x, -1.0) / fma(fma(fma(0.125, x, 0.3333333333333333), x, 0.5), (x * x), -1.0);
} else if ((x <= 8.5e+71) || !(x <= 1.6e+256)) {
tmp = (t_0 - (pow(eps, -1.0) - 1.0)) / 2.0;
} else {
tmp = (fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), x, 1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64((eps ^ -1.0) + 1.0) tmp = 0.0 if (x <= -0.00022) tmp = Float64(Float64(t_0 - Float64(fma(fma(Float64(eps - 1.0), x, Float64(x - 1.0)), eps, Float64(1.0 - x)) / eps)) / 2.0); elseif (x <= -1.85e-195) 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 <= 6400000000000.0) tmp = Float64(fma(x, x, -1.0) / fma(fma(fma(0.125, x, 0.3333333333333333), x, 0.5), Float64(x * x), -1.0)); elseif ((x <= 8.5e+71) || !(x <= 1.6e+256)) tmp = Float64(Float64(t_0 - Float64((eps ^ -1.0) - 1.0)) / 2.0); else tmp = Float64(Float64(fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), x, 1.0)) / Float64(x - 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, -0.00022], N[(N[(t$95$0 - N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.85e-195], 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, 6400000000000.0], N[(N[(x * x + -1.0), $MachinePrecision] / N[(N[(N[(0.125 * x + 0.3333333333333333), $MachinePrecision] * x + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 8.5e+71], N[Not[LessEqual[x, 1.6e+256]], $MachinePrecision]], N[(N[(t$95$0 - N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * x + -1.0), $MachinePrecision] * N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\varepsilon}^{-1} + 1\\
\mathbf{if}\;x \leq -0.00022:\\
\;\;\;\;\frac{t\_0 - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon - 1, x, x - 1\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-195}:\\
\;\;\;\;\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 6400000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, -1\right)}{\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 8.5 \cdot 10^{+71} \lor \neg \left(x \leq 1.6 \cdot 10^{+256}\right):\\
\;\;\;\;\frac{t\_0 - \left({\varepsilon}^{-1} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, -1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right)}{x - 1}\\
\end{array}
\end{array}
if x < -2.20000000000000008e-4Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6455.1
Applied rewrites55.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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6422.1
Applied rewrites22.1%
Taylor expanded in eps around 0
Applied rewrites42.1%
if -2.20000000000000008e-4 < x < -1.84999999999999981e-195Initial program 59.4%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites56.4%
Taylor expanded in eps around 0
Applied rewrites74.1%
if -1.84999999999999981e-195 < x < 6.4e12Initial program 48.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.3%
Taylor expanded in x around 0
Applied rewrites82.2%
Applied rewrites82.2%
Taylor expanded in x around 0
Applied rewrites82.4%
if 6.4e12 < x < 8.4999999999999996e71 or 1.59999999999999998e256 < x Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6426.7
Applied rewrites26.7%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6468.9
Applied rewrites68.9%
if 8.4999999999999996e71 < x < 1.59999999999999998e256Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites31.9%
Applied rewrites31.9%
Taylor expanded in x around 0
Applied rewrites53.6%
Applied rewrites67.3%
Final simplification70.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (pow eps -1.0) 1.0)))
(if (<= x -7.5e+122)
(/ (- t_0 (* x eps)) 2.0)
(if (<= x -1.85e-195)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 6400000000000.0)
(/
(fma x x -1.0)
(fma (fma (fma 0.125 x 0.3333333333333333) x 0.5) (* x x) -1.0))
(if (or (<= x 8.5e+71) (not (<= x 1.6e+256)))
(/ (- t_0 (- (pow eps -1.0) 1.0)) 2.0)
(/ (* (fma x x -1.0) (fma (fma 0.5 x -1.0) x 1.0)) (- x 1.0))))))))
double code(double x, double eps) {
double t_0 = pow(eps, -1.0) + 1.0;
double tmp;
if (x <= -7.5e+122) {
tmp = (t_0 - (x * eps)) / 2.0;
} else if (x <= -1.85e-195) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 6400000000000.0) {
tmp = fma(x, x, -1.0) / fma(fma(fma(0.125, x, 0.3333333333333333), x, 0.5), (x * x), -1.0);
} else if ((x <= 8.5e+71) || !(x <= 1.6e+256)) {
tmp = (t_0 - (pow(eps, -1.0) - 1.0)) / 2.0;
} else {
tmp = (fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), x, 1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64((eps ^ -1.0) + 1.0) tmp = 0.0 if (x <= -7.5e+122) tmp = Float64(Float64(t_0 - Float64(x * eps)) / 2.0); elseif (x <= -1.85e-195) 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 <= 6400000000000.0) tmp = Float64(fma(x, x, -1.0) / fma(fma(fma(0.125, x, 0.3333333333333333), x, 0.5), Float64(x * x), -1.0)); elseif ((x <= 8.5e+71) || !(x <= 1.6e+256)) tmp = Float64(Float64(t_0 - Float64((eps ^ -1.0) - 1.0)) / 2.0); else tmp = Float64(Float64(fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), x, 1.0)) / Float64(x - 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.5e+122], N[(N[(t$95$0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.85e-195], 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, 6400000000000.0], N[(N[(x * x + -1.0), $MachinePrecision] / N[(N[(N[(0.125 * x + 0.3333333333333333), $MachinePrecision] * x + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 8.5e+71], N[Not[LessEqual[x, 1.6e+256]], $MachinePrecision]], N[(N[(t$95$0 - N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(x * x + -1.0), $MachinePrecision] * N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\varepsilon}^{-1} + 1\\
\mathbf{if}\;x \leq -7.5 \cdot 10^{+122}:\\
\;\;\;\;\frac{t\_0 - x \cdot \varepsilon}{2}\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-195}:\\
\;\;\;\;\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 6400000000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, -1\right)}{\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 8.5 \cdot 10^{+71} \lor \neg \left(x \leq 1.6 \cdot 10^{+256}\right):\\
\;\;\;\;\frac{t\_0 - \left({\varepsilon}^{-1} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, -1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right)}{x - 1}\\
\end{array}
\end{array}
if x < -7.5000000000000002e122Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6451.6
Applied rewrites51.6%
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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6433.5
Applied rewrites33.5%
Taylor expanded in eps around inf
Applied rewrites33.5%
if -7.5000000000000002e122 < x < -1.84999999999999981e-195Initial program 71.9%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites40.1%
Taylor expanded in eps around 0
Applied rewrites63.1%
if -1.84999999999999981e-195 < x < 6.4e12Initial program 48.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.3%
Taylor expanded in x around 0
Applied rewrites82.2%
Applied rewrites82.2%
Taylor expanded in x around 0
Applied rewrites82.4%
if 6.4e12 < x < 8.4999999999999996e71 or 1.59999999999999998e256 < x Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6426.7
Applied rewrites26.7%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6468.9
Applied rewrites68.9%
if 8.4999999999999996e71 < x < 1.59999999999999998e256Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites31.9%
Applied rewrites31.9%
Taylor expanded in x around 0
Applied rewrites53.6%
Applied rewrites67.3%
Final simplification69.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow eps -1.0) 1.0)) (t_1 (+ (pow eps -1.0) 1.0)))
(if (<= x -0.00022)
(/ (- t_1 (/ (fma (fma (- eps 1.0) x (- x 1.0)) eps (- 1.0 x)) eps)) 2.0)
(if (<= x -1.85e-195)
(fma (* 0.5 x) (fma (- eps 1.0) t_1 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 0.053)
(fma (fma (fma -0.125 x 0.3333333333333333) x -0.5) (* x x) 1.0)
(if (<= x 1.6e+70)
(/
(-
(/ (fma (fma x eps 1.0) eps (- 1.0 x)) eps)
(* (fma (- -1.0 eps) x 1.0) t_0))
2.0)
(if (<= x 1.6e+256)
(/ (* (fma x x -1.0) (fma (fma 0.5 x -1.0) x 1.0)) (- x 1.0))
(/ (- t_1 t_0) 2.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 <= -0.00022) {
tmp = (t_1 - (fma(fma((eps - 1.0), x, (x - 1.0)), eps, (1.0 - x)) / eps)) / 2.0;
} else if (x <= -1.85e-195) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_1, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 0.053) {
tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), (x * x), 1.0);
} else if (x <= 1.6e+70) {
tmp = ((fma(fma(x, eps, 1.0), eps, (1.0 - x)) / eps) - (fma((-1.0 - eps), x, 1.0) * t_0)) / 2.0;
} else if (x <= 1.6e+256) {
tmp = (fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), x, 1.0)) / (x - 1.0);
} else {
tmp = (t_1 - t_0) / 2.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 <= -0.00022) tmp = Float64(Float64(t_1 - Float64(fma(fma(Float64(eps - 1.0), x, Float64(x - 1.0)), eps, Float64(1.0 - x)) / eps)) / 2.0); elseif (x <= -1.85e-195) 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 <= 0.053) tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), Float64(x * x), 1.0); elseif (x <= 1.6e+70) tmp = Float64(Float64(Float64(fma(fma(x, eps, 1.0), eps, Float64(1.0 - x)) / eps) - Float64(fma(Float64(-1.0 - eps), x, 1.0) * t_0)) / 2.0); elseif (x <= 1.6e+256) tmp = Float64(Float64(fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), x, 1.0)) / Float64(x - 1.0)); else tmp = Float64(Float64(t_1 - t_0) / 2.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, -0.00022], N[(N[(t$95$1 - N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.85e-195], 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, 0.053], N[(N[(N[(-0.125 * x + 0.3333333333333333), $MachinePrecision] * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 1.6e+70], N[(N[(N[(N[(N[(x * eps + 1.0), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision] - N[(N[(N[(-1.0 - eps), $MachinePrecision] * x + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.6e+256], N[(N[(N[(x * x + -1.0), $MachinePrecision] * N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\varepsilon}^{-1} - 1\\
t_1 := {\varepsilon}^{-1} + 1\\
\mathbf{if}\;x \leq -0.00022:\\
\;\;\;\;\frac{t\_1 - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon - 1, x, x - 1\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-195}:\\
\;\;\;\;\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 0.053:\\
\;\;\;\;\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 1.6 \cdot 10^{+70}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x, \varepsilon, 1\right), \varepsilon, 1 - x\right)}{\varepsilon} - \mathsf{fma}\left(-1 - \varepsilon, x, 1\right) \cdot t\_0}{2}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+256}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, -1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right)}{x - 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 - t\_0}{2}\\
\end{array}
\end{array}
if x < -2.20000000000000008e-4Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6455.1
Applied rewrites55.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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6422.1
Applied rewrites22.1%
Taylor expanded in eps around 0
Applied rewrites42.1%
if -2.20000000000000008e-4 < x < -1.84999999999999981e-195Initial program 59.4%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites56.4%
Taylor expanded in eps around 0
Applied rewrites74.1%
if -1.84999999999999981e-195 < x < 0.0529999999999999985Initial program 47.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites85.6%
Taylor expanded in x around 0
Applied rewrites85.4%
if 0.0529999999999999985 < x < 1.6000000000000001e70Initial program 93.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6426.9
Applied rewrites26.9%
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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f643.3
Applied rewrites3.3%
Taylor expanded in x around 0
+-commutativeN/A
associate-+r+N/A
*-commutativeN/A
associate-*r*N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
distribute-rgt1-inN/A
lower-*.f64N/A
Applied rewrites50.9%
Taylor expanded in eps around 0
Applied rewrites50.6%
if 1.6000000000000001e70 < x < 1.59999999999999998e256Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites33.6%
Applied rewrites33.6%
Taylor expanded in x around 0
Applied rewrites52.3%
Applied rewrites65.7%
if 1.59999999999999998e256 < x Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6428.4
Applied rewrites28.4%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6467.7
Applied rewrites67.7%
Final simplification70.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow eps -1.0) 1.0))
(t_1 (exp (- x)))
(t_2 (+ (pow eps -1.0) 1.0)))
(if (<= x -720.0)
(/ (- (/ t_1 eps) t_0) 2.0)
(if (<= x -1.85e-195)
(fma (* 0.5 x) (fma (- eps 1.0) t_2 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 8.5e+71)
(* (+ x 1.0) t_1)
(if (<= x 1.6e+256)
(/ (* (fma x x -1.0) (fma (fma 0.5 x -1.0) x 1.0)) (- x 1.0))
(/ (- t_2 t_0) 2.0)))))))
double code(double x, double eps) {
double t_0 = pow(eps, -1.0) - 1.0;
double t_1 = exp(-x);
double t_2 = pow(eps, -1.0) + 1.0;
double tmp;
if (x <= -720.0) {
tmp = ((t_1 / eps) - t_0) / 2.0;
} else if (x <= -1.85e-195) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_2, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 8.5e+71) {
tmp = (x + 1.0) * t_1;
} else if (x <= 1.6e+256) {
tmp = (fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), x, 1.0)) / (x - 1.0);
} else {
tmp = (t_2 - t_0) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64((eps ^ -1.0) - 1.0) t_1 = exp(Float64(-x)) t_2 = Float64((eps ^ -1.0) + 1.0) tmp = 0.0 if (x <= -720.0) tmp = Float64(Float64(Float64(t_1 / eps) - t_0) / 2.0); elseif (x <= -1.85e-195) tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), t_2, Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0); elseif (x <= 8.5e+71) tmp = Float64(Float64(x + 1.0) * t_1); elseif (x <= 1.6e+256) tmp = Float64(Float64(fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), x, 1.0)) / Float64(x - 1.0)); else tmp = Float64(Float64(t_2 - t_0) / 2.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[Exp[(-x)], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[eps, -1.0], $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -720.0], N[(N[(N[(t$95$1 / eps), $MachinePrecision] - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.85e-195], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * t$95$2 + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 8.5e+71], N[(N[(x + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[x, 1.6e+256], N[(N[(N[(x * x + -1.0), $MachinePrecision] * N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\varepsilon}^{-1} - 1\\
t_1 := e^{-x}\\
t_2 := {\varepsilon}^{-1} + 1\\
\mathbf{if}\;x \leq -720:\\
\;\;\;\;\frac{\frac{t\_1}{\varepsilon} - t\_0}{2}\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-195}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, t\_2, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
\mathbf{elif}\;x \leq 8.5 \cdot 10^{+71}:\\
\;\;\;\;\left(x + 1\right) \cdot t\_1\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+256}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, -1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right)}{x - 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_2 - t\_0}{2}\\
\end{array}
\end{array}
if x < -720Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6456.4
Applied rewrites56.4%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f643.1
Applied rewrites3.1%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6455.0
Applied rewrites55.0%
if -720 < x < -1.84999999999999981e-195Initial program 60.4%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites55.2%
Taylor expanded in eps around 0
Applied rewrites72.5%
if -1.84999999999999981e-195 < x < 8.4999999999999996e71Initial program 54.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.5%
Applied rewrites83.5%
if 8.4999999999999996e71 < x < 1.59999999999999998e256Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites31.9%
Applied rewrites31.9%
Taylor expanded in x around 0
Applied rewrites53.6%
Applied rewrites67.3%
if 1.59999999999999998e256 < x Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6428.4
Applied rewrites28.4%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6467.7
Applied rewrites67.7%
Final simplification73.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (pow eps -1.0) 1.0)))
(if (<= x -0.00022)
(/ (- t_0 (/ (fma (fma (- eps 1.0) x (- x 1.0)) eps (- 1.0 x)) eps)) 2.0)
(if (<= x -1.85e-195)
(fma (* 0.5 x) (fma (- eps 1.0) t_0 (/ (- 1.0 (* eps eps)) eps)) 1.0)
(if (<= x 8.5e+71)
(* (+ x 1.0) (exp (- x)))
(if (<= x 1.6e+256)
(/ (* (fma x x -1.0) (fma (fma 0.5 x -1.0) x 1.0)) (- x 1.0))
(/ (- t_0 (- (pow eps -1.0) 1.0)) 2.0)))))))
double code(double x, double eps) {
double t_0 = pow(eps, -1.0) + 1.0;
double tmp;
if (x <= -0.00022) {
tmp = (t_0 - (fma(fma((eps - 1.0), x, (x - 1.0)), eps, (1.0 - x)) / eps)) / 2.0;
} else if (x <= -1.85e-195) {
tmp = fma((0.5 * x), fma((eps - 1.0), t_0, ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 8.5e+71) {
tmp = (x + 1.0) * exp(-x);
} else if (x <= 1.6e+256) {
tmp = (fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), x, 1.0)) / (x - 1.0);
} else {
tmp = (t_0 - (pow(eps, -1.0) - 1.0)) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64((eps ^ -1.0) + 1.0) tmp = 0.0 if (x <= -0.00022) tmp = Float64(Float64(t_0 - Float64(fma(fma(Float64(eps - 1.0), x, Float64(x - 1.0)), eps, Float64(1.0 - x)) / eps)) / 2.0); elseif (x <= -1.85e-195) 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 <= 8.5e+71) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); elseif (x <= 1.6e+256) tmp = Float64(Float64(fma(x, x, -1.0) * fma(fma(0.5, x, -1.0), x, 1.0)) / Float64(x - 1.0)); else tmp = Float64(Float64(t_0 - Float64((eps ^ -1.0) - 1.0)) / 2.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, -0.00022], N[(N[(t$95$0 - N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + N[(x - 1.0), $MachinePrecision]), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.85e-195], 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, 8.5e+71], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e+256], N[(N[(N[(x * x + -1.0), $MachinePrecision] * N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - N[(N[Power[eps, -1.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\varepsilon}^{-1} + 1\\
\mathbf{if}\;x \leq -0.00022:\\
\;\;\;\;\frac{t\_0 - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon - 1, x, x - 1\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-195}:\\
\;\;\;\;\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 8.5 \cdot 10^{+71}:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+256}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, -1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right)}{x - 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - \left({\varepsilon}^{-1} - 1\right)}{2}\\
\end{array}
\end{array}
if x < -2.20000000000000008e-4Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6455.1
Applied rewrites55.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
distribute-rgt-neg-inN/A
*-commutativeN/A
lower-fma.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6422.1
Applied rewrites22.1%
Taylor expanded in eps around 0
Applied rewrites42.1%
if -2.20000000000000008e-4 < x < -1.84999999999999981e-195Initial program 59.4%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites56.4%
Taylor expanded in eps around 0
Applied rewrites74.1%
if -1.84999999999999981e-195 < x < 8.4999999999999996e71Initial program 54.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.5%
Applied rewrites83.5%
if 8.4999999999999996e71 < x < 1.59999999999999998e256Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites31.9%
Applied rewrites31.9%
Taylor expanded in x around 0
Applied rewrites53.6%
Applied rewrites67.3%
if 1.59999999999999998e256 < x Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6428.4
Applied rewrites28.4%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6467.7
Applied rewrites67.7%
Final simplification71.9%
(FPCore (x eps) :precision binary64 (if (<= eps 1.0) (/ (+ x 1.0) (fma (fma 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 (eps <= 1.0) {
tmp = (x + 1.0) / fma(fma(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 (eps <= 1.0) tmp = Float64(Float64(x + 1.0) / fma(fma(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[eps, 1.0], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.5 * 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}\;\varepsilon \leq 1:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, 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 eps < 1Initial program 61.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.1%
Taylor expanded in x around 0
Applied rewrites62.1%
Applied rewrites62.1%
if 1 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites20.7%
Applied rewrites20.7%
Taylor expanded in x around 0
Applied rewrites36.1%
(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(Float64(fma(0.3333333333333333, x, -0.5) * x), x, 1.0) end
code[x_, eps_] := N[(N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right) \cdot x, x, 1\right)
\end{array}
Initial program 72.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites56.9%
Taylor expanded in x around 0
Applied rewrites53.7%
Applied rewrites53.7%
(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 72.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites56.9%
Taylor expanded in x around 0
Applied rewrites53.7%
Taylor expanded in x around inf
Applied rewrites53.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 72.0%
Taylor expanded in x around 0
Applied rewrites44.4%
herbie shell --seed 2024317
(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))