
(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 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (+ (/ 1.0 eps) 1.0) (exp (* (- eps 1.0) x)))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
0.0)
(* (exp (- x)) (+ x 1.0))
(* 0.5 (- (* (exp (* x eps)) 1.0) (/ -1.0 (exp (fma x eps x)))))))
double code(double x, double eps) {
double tmp;
if (((((1.0 / eps) + 1.0) * exp(((eps - 1.0) * x))) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 0.0) {
tmp = exp(-x) * (x + 1.0);
} else {
tmp = 0.5 * ((exp((x * eps)) * 1.0) - (-1.0 / exp(fma(x, eps, x))));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) * exp(Float64(Float64(eps - 1.0) * x))) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 0.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); else tmp = Float64(0.5 * Float64(Float64(exp(Float64(x * eps)) * 1.0) - Float64(-1.0 / exp(fma(x, eps, x))))); end return tmp end
code[x_, eps_] := If[LessEqual[N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\frac{1}{\varepsilon} + 1\right) \cdot e^{\left(\varepsilon - 1\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 0:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{x \cdot \varepsilon} \cdot 1 - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\right)}}\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 0.0Initial program 25.9%
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%
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.f6496.0
Applied rewrites96.0%
Taylor expanded in eps around inf
lower-*.f6496.0
Applied rewrites96.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (+ (/ 1.0 eps) 1.0) (exp (* (- eps 1.0) x)))))
(if (<= (- t_0 (* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0))) 4.0)
(* (exp (- x)) (+ x 1.0))
(/ (- t_0 -1.0) 2.0))))
double code(double x, double eps) {
double t_0 = ((1.0 / eps) + 1.0) * exp(((eps - 1.0) * x));
double tmp;
if ((t_0 - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) {
tmp = exp(-x) * (x + 1.0);
} 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(((eps - 1.0d0) * x))
if ((t_0 - (exp((((-1.0d0) - eps) * x)) * ((1.0d0 / eps) - 1.0d0))) <= 4.0d0) then
tmp = exp(-x) * (x + 1.0d0)
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 / eps) + 1.0) * Math.exp(((eps - 1.0) * x));
double tmp;
if ((t_0 - (Math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) {
tmp = Math.exp(-x) * (x + 1.0);
} else {
tmp = (t_0 - -1.0) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = ((1.0 / eps) + 1.0) * math.exp(((eps - 1.0) * x)) tmp = 0 if (t_0 - (math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0: tmp = math.exp(-x) * (x + 1.0) else: tmp = (t_0 - -1.0) / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(Float64(1.0 / eps) + 1.0) * exp(Float64(Float64(eps - 1.0) * x))) tmp = 0.0 if (Float64(t_0 - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 4.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); 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(((eps - 1.0) * x)); tmp = 0.0; if ((t_0 - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) tmp = exp(-x) * (x + 1.0); else tmp = (t_0 - -1.0) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{1}{\varepsilon} + 1\right) \cdot e^{\left(\varepsilon - 1\right) \cdot x}\\
\mathbf{if}\;t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 4:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\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 46.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.6%
Applied rewrites99.6%
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
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites49.6%
Final simplification76.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (/ 1.0 eps) 1.0)))
(if (<=
(-
(* (+ (/ 1.0 eps) 1.0) (exp (* (- eps 1.0) x)))
(* (exp (* (- -1.0 eps) x)) t_0))
4.0)
(* (exp (- x)) (+ x 1.0))
(/ (- (* (exp (* x eps)) 1.0) t_0) 2.0))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) - 1.0;
double tmp;
if (((((1.0 / eps) + 1.0) * exp(((eps - 1.0) * x))) - (exp(((-1.0 - eps) * x)) * t_0)) <= 4.0) {
tmp = exp(-x) * (x + 1.0);
} else {
tmp = ((exp((x * eps)) * 1.0) - 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
if (((((1.0d0 / eps) + 1.0d0) * exp(((eps - 1.0d0) * x))) - (exp((((-1.0d0) - eps) * x)) * t_0)) <= 4.0d0) then
tmp = exp(-x) * (x + 1.0d0)
else
tmp = ((exp((x * eps)) * 1.0d0) - t_0) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (1.0 / eps) - 1.0;
double tmp;
if (((((1.0 / eps) + 1.0) * Math.exp(((eps - 1.0) * x))) - (Math.exp(((-1.0 - eps) * x)) * t_0)) <= 4.0) {
tmp = Math.exp(-x) * (x + 1.0);
} else {
tmp = ((Math.exp((x * eps)) * 1.0) - t_0) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = (1.0 / eps) - 1.0 tmp = 0 if ((((1.0 / eps) + 1.0) * math.exp(((eps - 1.0) * x))) - (math.exp(((-1.0 - eps) * x)) * t_0)) <= 4.0: tmp = math.exp(-x) * (x + 1.0) else: tmp = ((math.exp((x * eps)) * 1.0) - t_0) / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) - 1.0) tmp = 0.0 if (Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) * exp(Float64(Float64(eps - 1.0) * x))) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * t_0)) <= 4.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); else tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * 1.0) - t_0) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = (1.0 / eps) - 1.0; tmp = 0.0; if (((((1.0 / eps) + 1.0) * exp(((eps - 1.0) * x))) - (exp(((-1.0 - eps) * x)) * t_0)) <= 4.0) tmp = exp(-x) * (x + 1.0); else tmp = ((exp((x * eps)) * 1.0) - t_0) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 4.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} - 1\\
\mathbf{if}\;\left(\frac{1}{\varepsilon} + 1\right) \cdot e^{\left(\varepsilon - 1\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot t\_0 \leq 4:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot 1 - 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))))) < 4Initial program 46.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.6%
Applied rewrites99.6%
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
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6449.6
Applied rewrites49.6%
Final simplification76.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)) (t_1 (- (/ 1.0 eps) 1.0)))
(if (<= eps 1.55e-16)
(* (exp (- x)) (+ x 1.0))
(if (<= eps 1.9e+99)
(/
(- (* t_0 (exp (* (- eps 1.0) x))) (* (fma (- -1.0 eps) x 1.0) t_1))
2.0)
(/
(- (* t_0 (fma (- eps 1.0) x 1.0)) (* (exp (* (- -1.0 eps) x)) t_1))
2.0)))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double t_1 = (1.0 / eps) - 1.0;
double tmp;
if (eps <= 1.55e-16) {
tmp = exp(-x) * (x + 1.0);
} else if (eps <= 1.9e+99) {
tmp = ((t_0 * exp(((eps - 1.0) * x))) - (fma((-1.0 - eps), x, 1.0) * t_1)) / 2.0;
} else {
tmp = ((t_0 * fma((eps - 1.0), x, 1.0)) - (exp(((-1.0 - eps) * x)) * t_1)) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) t_1 = Float64(Float64(1.0 / eps) - 1.0) tmp = 0.0 if (eps <= 1.55e-16) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); elseif (eps <= 1.9e+99) tmp = Float64(Float64(Float64(t_0 * exp(Float64(Float64(eps - 1.0) * x))) - Float64(fma(Float64(-1.0 - eps), x, 1.0) * t_1)) / 2.0); else tmp = Float64(Float64(Float64(t_0 * fma(Float64(eps - 1.0), x, 1.0)) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * t_1)) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[eps, 1.55e-16], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.9e+99], N[(N[(N[(t$95$0 * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(-1.0 - eps), $MachinePrecision] * x + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(t$95$0 * N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
t_1 := \frac{1}{\varepsilon} - 1\\
\mathbf{if}\;\varepsilon \leq 1.55 \cdot 10^{-16}:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{elif}\;\varepsilon \leq 1.9 \cdot 10^{+99}:\\
\;\;\;\;\frac{t\_0 \cdot e^{\left(\varepsilon - 1\right) \cdot x} - \mathsf{fma}\left(-1 - \varepsilon, x, 1\right) \cdot t\_1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot \mathsf{fma}\left(\varepsilon - 1, x, 1\right) - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot t\_1}{2}\\
\end{array}
\end{array}
if eps < 1.55e-16Initial program 59.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites65.5%
Applied rewrites65.5%
if 1.55e-16 < eps < 1.9e99Initial program 100.0%
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
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6477.1
Applied rewrites77.1%
if 1.9e99 < eps Initial program 100.0%
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
mul-1-negN/A
sub-negN/A
distribute-rgt-neg-inN/A
distribute-rgt1-inN/A
lower-*.f64N/A
Applied rewrites67.2%
Final simplification66.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= eps 100000.0)
(* (exp (- x)) (+ x 1.0))
(if (<= eps 1.9e+99)
(/ (- (* t_0 (exp (* (- eps 1.0) x))) (fma eps x (- x 1.0))) 2.0)
(/
(-
(* t_0 (fma (- eps 1.0) x 1.0))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
2.0)))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (eps <= 100000.0) {
tmp = exp(-x) * (x + 1.0);
} else if (eps <= 1.9e+99) {
tmp = ((t_0 * exp(((eps - 1.0) * x))) - fma(eps, x, (x - 1.0))) / 2.0;
} else {
tmp = ((t_0 * fma((eps - 1.0), x, 1.0)) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (eps <= 100000.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); elseif (eps <= 1.9e+99) tmp = Float64(Float64(Float64(t_0 * exp(Float64(Float64(eps - 1.0) * x))) - fma(eps, x, Float64(x - 1.0))) / 2.0); else tmp = Float64(Float64(Float64(t_0 * fma(Float64(eps - 1.0), x, 1.0)) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[eps, 100000.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.9e+99], N[(N[(N[(t$95$0 * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(eps * x + N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(t$95$0 * N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;\varepsilon \leq 100000:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{elif}\;\varepsilon \leq 1.9 \cdot 10^{+99}:\\
\;\;\;\;\frac{t\_0 \cdot e^{\left(\varepsilon - 1\right) \cdot x} - \mathsf{fma}\left(\varepsilon, x, x - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot \mathsf{fma}\left(\varepsilon - 1, x, 1\right) - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\end{array}
\end{array}
if eps < 1e5Initial program 60.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.1%
Applied rewrites66.1%
if 1e5 < eps < 1.9e99Initial 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
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6497.1
Applied rewrites97.1%
Taylor expanded in x around 0
Applied rewrites70.4%
if 1.9e99 < eps Initial program 100.0%
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
mul-1-negN/A
sub-negN/A
distribute-rgt-neg-inN/A
distribute-rgt1-inN/A
lower-*.f64N/A
Applied rewrites67.2%
Final simplification66.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0))
(t_1 (* t_0 (exp (* (- eps 1.0) x))))
(t_2 (- (/ 1.0 eps) 1.0)))
(if (<= eps 1.55e-16)
(* (exp (- x)) (+ x 1.0))
(if (<= eps 8.6e+52)
(/ (- t_1 t_2) 2.0)
(if (<= eps 1.5e+273)
(/ (- t_0 (* (exp (* (- -1.0 eps) x)) t_2)) 2.0)
(/ (- t_1 -1.0) 2.0))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double t_1 = t_0 * exp(((eps - 1.0) * x));
double t_2 = (1.0 / eps) - 1.0;
double tmp;
if (eps <= 1.55e-16) {
tmp = exp(-x) * (x + 1.0);
} else if (eps <= 8.6e+52) {
tmp = (t_1 - t_2) / 2.0;
} else if (eps <= 1.5e+273) {
tmp = (t_0 - (exp(((-1.0 - eps) * x)) * t_2)) / 2.0;
} else {
tmp = (t_1 - -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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (1.0d0 / eps) + 1.0d0
t_1 = t_0 * exp(((eps - 1.0d0) * x))
t_2 = (1.0d0 / eps) - 1.0d0
if (eps <= 1.55d-16) then
tmp = exp(-x) * (x + 1.0d0)
else if (eps <= 8.6d+52) then
tmp = (t_1 - t_2) / 2.0d0
else if (eps <= 1.5d+273) then
tmp = (t_0 - (exp((((-1.0d0) - eps) * x)) * t_2)) / 2.0d0
else
tmp = (t_1 - (-1.0d0)) / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double t_1 = t_0 * Math.exp(((eps - 1.0) * x));
double t_2 = (1.0 / eps) - 1.0;
double tmp;
if (eps <= 1.55e-16) {
tmp = Math.exp(-x) * (x + 1.0);
} else if (eps <= 8.6e+52) {
tmp = (t_1 - t_2) / 2.0;
} else if (eps <= 1.5e+273) {
tmp = (t_0 - (Math.exp(((-1.0 - eps) * x)) * t_2)) / 2.0;
} else {
tmp = (t_1 - -1.0) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = (1.0 / eps) + 1.0 t_1 = t_0 * math.exp(((eps - 1.0) * x)) t_2 = (1.0 / eps) - 1.0 tmp = 0 if eps <= 1.55e-16: tmp = math.exp(-x) * (x + 1.0) elif eps <= 8.6e+52: tmp = (t_1 - t_2) / 2.0 elif eps <= 1.5e+273: tmp = (t_0 - (math.exp(((-1.0 - eps) * x)) * t_2)) / 2.0 else: tmp = (t_1 - -1.0) / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) t_1 = Float64(t_0 * exp(Float64(Float64(eps - 1.0) * x))) t_2 = Float64(Float64(1.0 / eps) - 1.0) tmp = 0.0 if (eps <= 1.55e-16) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); elseif (eps <= 8.6e+52) tmp = Float64(Float64(t_1 - t_2) / 2.0); elseif (eps <= 1.5e+273) tmp = Float64(Float64(t_0 - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * t_2)) / 2.0); else tmp = Float64(Float64(t_1 - -1.0) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = (1.0 / eps) + 1.0; t_1 = t_0 * exp(((eps - 1.0) * x)); t_2 = (1.0 / eps) - 1.0; tmp = 0.0; if (eps <= 1.55e-16) tmp = exp(-x) * (x + 1.0); elseif (eps <= 8.6e+52) tmp = (t_1 - t_2) / 2.0; elseif (eps <= 1.5e+273) tmp = (t_0 - (exp(((-1.0 - eps) * x)) * t_2)) / 2.0; else tmp = (t_1 - -1.0) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[eps, 1.55e-16], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 8.6e+52], N[(N[(t$95$1 - t$95$2), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps, 1.5e+273], N[(N[(t$95$0 - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$1 - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
t_1 := t\_0 \cdot e^{\left(\varepsilon - 1\right) \cdot x}\\
t_2 := \frac{1}{\varepsilon} - 1\\
\mathbf{if}\;\varepsilon \leq 1.55 \cdot 10^{-16}:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{elif}\;\varepsilon \leq 8.6 \cdot 10^{+52}:\\
\;\;\;\;\frac{t\_1 - t\_2}{2}\\
\mathbf{elif}\;\varepsilon \leq 1.5 \cdot 10^{+273}:\\
\;\;\;\;\frac{t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot t\_2}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 - -1}{2}\\
\end{array}
\end{array}
if eps < 1.55e-16Initial program 59.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites65.5%
Applied rewrites65.5%
if 1.55e-16 < eps < 8.5999999999999999e52Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6490.3
Applied rewrites90.3%
if 8.5999999999999999e52 < eps < 1.5e273Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6468.3
Applied rewrites68.3%
if 1.5e273 < 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
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites59.6%
Final simplification66.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0))
(t_1 (/ (- (* t_0 (exp (* (- eps 1.0) x))) -1.0) 2.0)))
(if (<= eps 100000.0)
(* (exp (- x)) (+ x 1.0))
(if (<= eps 8.6e+52)
t_1
(if (<= eps 1.5e+273)
(/ (- t_0 (* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0))) 2.0)
t_1)))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double t_1 = ((t_0 * exp(((eps - 1.0) * x))) - -1.0) / 2.0;
double tmp;
if (eps <= 100000.0) {
tmp = exp(-x) * (x + 1.0);
} else if (eps <= 8.6e+52) {
tmp = t_1;
} else if (eps <= 1.5e+273) {
tmp = (t_0 - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) / 2.0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (1.0d0 / eps) + 1.0d0
t_1 = ((t_0 * exp(((eps - 1.0d0) * x))) - (-1.0d0)) / 2.0d0
if (eps <= 100000.0d0) then
tmp = exp(-x) * (x + 1.0d0)
else if (eps <= 8.6d+52) then
tmp = t_1
else if (eps <= 1.5d+273) then
tmp = (t_0 - (exp((((-1.0d0) - eps) * x)) * ((1.0d0 / eps) - 1.0d0))) / 2.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double t_1 = ((t_0 * Math.exp(((eps - 1.0) * x))) - -1.0) / 2.0;
double tmp;
if (eps <= 100000.0) {
tmp = Math.exp(-x) * (x + 1.0);
} else if (eps <= 8.6e+52) {
tmp = t_1;
} else if (eps <= 1.5e+273) {
tmp = (t_0 - (Math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) / 2.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, eps): t_0 = (1.0 / eps) + 1.0 t_1 = ((t_0 * math.exp(((eps - 1.0) * x))) - -1.0) / 2.0 tmp = 0 if eps <= 100000.0: tmp = math.exp(-x) * (x + 1.0) elif eps <= 8.6e+52: tmp = t_1 elif eps <= 1.5e+273: tmp = (t_0 - (math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) / 2.0 else: tmp = t_1 return tmp
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) t_1 = Float64(Float64(Float64(t_0 * exp(Float64(Float64(eps - 1.0) * x))) - -1.0) / 2.0) tmp = 0.0 if (eps <= 100000.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); elseif (eps <= 8.6e+52) tmp = t_1; elseif (eps <= 1.5e+273) tmp = Float64(Float64(t_0 - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) / 2.0); else tmp = t_1; end return tmp end
function tmp_2 = code(x, eps) t_0 = (1.0 / eps) + 1.0; t_1 = ((t_0 * exp(((eps - 1.0) * x))) - -1.0) / 2.0; tmp = 0.0; if (eps <= 100000.0) tmp = exp(-x) * (x + 1.0); elseif (eps <= 8.6e+52) tmp = t_1; elseif (eps <= 1.5e+273) tmp = (t_0 - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) / 2.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(t$95$0 * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[eps, 100000.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 8.6e+52], t$95$1, If[LessEqual[eps, 1.5e+273], N[(N[(t$95$0 - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
t_1 := \frac{t\_0 \cdot e^{\left(\varepsilon - 1\right) \cdot x} - -1}{2}\\
\mathbf{if}\;\varepsilon \leq 100000:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{elif}\;\varepsilon \leq 8.6 \cdot 10^{+52}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\varepsilon \leq 1.5 \cdot 10^{+273}:\\
\;\;\;\;\frac{t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eps < 1e5Initial program 60.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.1%
Applied rewrites66.1%
if 1e5 < eps < 8.5999999999999999e52 or 1.5e273 < 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
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6497.2
Applied rewrites97.2%
Taylor expanded in x around 0
Applied rewrites66.6%
if 8.5999999999999999e52 < eps < 1.5e273Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6468.3
Applied rewrites68.3%
Final simplification66.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= eps 100000.0)
(* (exp (- x)) (+ x 1.0))
(if (<= eps 1.9e+99)
(/ (- (* t_0 (exp (* (- eps 1.0) x))) (fma eps x (- x 1.0))) 2.0)
(/
(- (* t_0 (fma (- eps 1.0) x 1.0)) (/ -1.0 (exp (fma eps x x))))
2.0)))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (eps <= 100000.0) {
tmp = exp(-x) * (x + 1.0);
} else if (eps <= 1.9e+99) {
tmp = ((t_0 * exp(((eps - 1.0) * x))) - fma(eps, x, (x - 1.0))) / 2.0;
} else {
tmp = ((t_0 * fma((eps - 1.0), x, 1.0)) - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (eps <= 100000.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); elseif (eps <= 1.9e+99) tmp = Float64(Float64(Float64(t_0 * exp(Float64(Float64(eps - 1.0) * x))) - fma(eps, x, Float64(x - 1.0))) / 2.0); else tmp = Float64(Float64(Float64(t_0 * fma(Float64(eps - 1.0), x, 1.0)) - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[eps, 100000.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.9e+99], N[(N[(N[(t$95$0 * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(eps * x + N[(x - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(t$95$0 * N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;\varepsilon \leq 100000:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{elif}\;\varepsilon \leq 1.9 \cdot 10^{+99}:\\
\;\;\;\;\frac{t\_0 \cdot e^{\left(\varepsilon - 1\right) \cdot x} - \mathsf{fma}\left(\varepsilon, x, x - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot \mathsf{fma}\left(\varepsilon - 1, x, 1\right) - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\end{array}
\end{array}
if eps < 1e5Initial program 60.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.1%
Applied rewrites66.1%
if 1e5 < eps < 1.9e99Initial 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
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6497.1
Applied rewrites97.1%
Taylor expanded in x around 0
Applied rewrites70.4%
if 1.9e99 < 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
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
lower-*.f64100.0
Applied rewrites100.0%
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
mul-1-negN/A
sub-negN/A
distribute-rgt-neg-inN/A
distribute-rgt1-inN/A
lower-*.f64N/A
Applied rewrites67.2%
Final simplification66.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= eps 100000.0)
(* (exp (- x)) (+ x 1.0))
(if (<= eps 8.6e+52)
(/ (- (* t_0 (exp (* (- eps 1.0) x))) -1.0) 2.0)
(if (<= eps 8e+270)
(/ (- t_0 (/ -1.0 (exp (fma eps x x)))) 2.0)
(/ (- (* (exp (* x eps)) 1.0) (- (/ 1.0 eps) 1.0)) 2.0))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (eps <= 100000.0) {
tmp = exp(-x) * (x + 1.0);
} else if (eps <= 8.6e+52) {
tmp = ((t_0 * exp(((eps - 1.0) * x))) - -1.0) / 2.0;
} else if (eps <= 8e+270) {
tmp = (t_0 - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
} else {
tmp = ((exp((x * eps)) * 1.0) - ((1.0 / eps) - 1.0)) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (eps <= 100000.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); elseif (eps <= 8.6e+52) tmp = Float64(Float64(Float64(t_0 * exp(Float64(Float64(eps - 1.0) * x))) - -1.0) / 2.0); elseif (eps <= 8e+270) tmp = Float64(Float64(t_0 - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); else tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * 1.0) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[eps, 100000.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 8.6e+52], N[(N[(N[(t$95$0 * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps, 8e+270], N[(N[(t$95$0 - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;\varepsilon \leq 100000:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{elif}\;\varepsilon \leq 8.6 \cdot 10^{+52}:\\
\;\;\;\;\frac{t\_0 \cdot e^{\left(\varepsilon - 1\right) \cdot x} - -1}{2}\\
\mathbf{elif}\;\varepsilon \leq 8 \cdot 10^{+270}:\\
\;\;\;\;\frac{t\_0 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot 1 - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\end{array}
\end{array}
if eps < 1e5Initial program 60.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.1%
Applied rewrites66.1%
if 1e5 < eps < 8.5999999999999999e52Initial 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
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6492.5
Applied rewrites92.5%
Taylor expanded in x around 0
Applied rewrites78.7%
if 8.5999999999999999e52 < eps < 8.0000000000000004e270Initial 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
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6467.7
Applied rewrites67.7%
if 8.0000000000000004e270 < 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
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6455.3
Applied rewrites55.3%
Final simplification66.2%
(FPCore (x eps)
:precision binary64
(if (<= eps 4e-32)
(* (exp (- x)) (+ x 1.0))
(if (<= eps 4.1e+172)
(/ (+ (pow x 3.0) 1.0) 1.0)
(/
(- (+ (/ 1.0 eps) 1.0) (/ (fma (fma eps x -1.0) eps (- 1.0 x)) eps))
2.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 4e-32) {
tmp = exp(-x) * (x + 1.0);
} else if (eps <= 4.1e+172) {
tmp = (pow(x, 3.0) + 1.0) / 1.0;
} else {
tmp = (((1.0 / eps) + 1.0) - (fma(fma(eps, x, -1.0), eps, (1.0 - x)) / eps)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 4e-32) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); elseif (eps <= 4.1e+172) tmp = Float64(Float64((x ^ 3.0) + 1.0) / 1.0); else tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(fma(fma(eps, x, -1.0), eps, Float64(1.0 - x)) / eps)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 4e-32], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.1e+172], N[(N[(N[Power[x, 3.0], $MachinePrecision] + 1.0), $MachinePrecision] / 1.0), $MachinePrecision], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(N[(eps * x + -1.0), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 4 \cdot 10^{-32}:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{elif}\;\varepsilon \leq 4.1 \cdot 10^{+172}:\\
\;\;\;\;\frac{{x}^{3} + 1}{1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon, x, -1\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if eps < 4.00000000000000022e-32Initial program 60.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites64.7%
Applied rewrites64.8%
if 4.00000000000000022e-32 < eps < 4.1e172Initial program 91.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.7%
Taylor expanded in x around 0
Applied rewrites42.7%
Applied rewrites46.0%
Taylor expanded in x around 0
Applied rewrites61.9%
if 4.1e172 < eps Initial program 100.0%
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
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6452.5
Applied rewrites52.5%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6435.4
Applied rewrites35.4%
Taylor expanded in eps around 0
Applied rewrites51.2%
Taylor expanded in x around 0
Applied rewrites51.2%
Final simplification62.4%
(FPCore (x eps)
:precision binary64
(if (<= eps 26500000.0)
(* (exp (- x)) (+ x 1.0))
(if (<= eps 3e+172)
(fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)
(/
(- (+ (/ 1.0 eps) 1.0) (/ (fma (fma eps x -1.0) eps (- 1.0 x)) eps))
2.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 26500000.0) {
tmp = exp(-x) * (x + 1.0);
} else if (eps <= 3e+172) {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
} else {
tmp = (((1.0 / eps) + 1.0) - (fma(fma(eps, x, -1.0), eps, (1.0 - x)) / eps)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 26500000.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); elseif (eps <= 3e+172) tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); else tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(fma(fma(eps, x, -1.0), eps, Float64(1.0 - x)) / eps)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 26500000.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3e+172], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(N[(eps * x + -1.0), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 26500000:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{elif}\;\varepsilon \leq 3 \cdot 10^{+172}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon, x, -1\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\end{array}
\end{array}
if eps < 2.65e7Initial program 60.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.1%
Applied rewrites66.1%
if 2.65e7 < eps < 2.9999999999999999e172Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites30.6%
Taylor expanded in x around 0
Applied rewrites52.5%
if 2.9999999999999999e172 < eps Initial program 100.0%
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
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6452.5
Applied rewrites52.5%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6435.4
Applied rewrites35.4%
Taylor expanded in eps around 0
Applied rewrites51.2%
Taylor expanded in x around 0
Applied rewrites51.2%
Final simplification62.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= x -0.0295)
(/ (- t_0 (/ (fma (fma eps x -1.0) eps (- 1.0 x)) eps)) 2.0)
(if (<= x 1.8)
(fma (fma (fma -0.125 x 0.3333333333333333) x -0.5) (* x x) 1.0)
(if (<= x 1.8e+138)
(/ (- t_0 (- (/ 1.0 eps) 1.0)) 2.0)
(fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (x <= -0.0295) {
tmp = (t_0 - (fma(fma(eps, x, -1.0), eps, (1.0 - x)) / eps)) / 2.0;
} else if (x <= 1.8) {
tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), (x * x), 1.0);
} else if (x <= 1.8e+138) {
tmp = (t_0 - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (x <= -0.0295) tmp = Float64(Float64(t_0 - Float64(fma(fma(eps, x, -1.0), eps, Float64(1.0 - x)) / eps)) / 2.0); elseif (x <= 1.8) tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), Float64(x * x), 1.0); elseif (x <= 1.8e+138) tmp = Float64(Float64(t_0 - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -0.0295], N[(N[(t$95$0 - N[(N[(N[(eps * x + -1.0), $MachinePrecision] * eps + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.8], N[(N[(N[(-0.125 * x + 0.3333333333333333), $MachinePrecision] * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 1.8e+138], N[(N[(t$95$0 - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;x \leq -0.0295:\\
\;\;\;\;\frac{t\_0 - \frac{\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon, x, -1\right), \varepsilon, 1 - x\right)}{\varepsilon}}{2}\\
\mathbf{elif}\;x \leq 1.8:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.125, x, 0.3333333333333333\right), x, -0.5\right), x \cdot x, 1\right)\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+138}:\\
\;\;\;\;\frac{t\_0 - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -0.029499999999999998Initial program 100.0%
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
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6468.4
Applied rewrites68.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6433.5
Applied rewrites33.5%
Taylor expanded in eps around 0
Applied rewrites38.1%
Taylor expanded in x around 0
Applied rewrites38.1%
if -0.029499999999999998 < x < 1.80000000000000004Initial program 51.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.6%
Taylor expanded in x around 0
Applied rewrites74.2%
if 1.80000000000000004 < x < 1.8000000000000001e138Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6424.7
Applied rewrites24.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6443.7
Applied rewrites43.7%
if 1.8000000000000001e138 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites30.5%
Taylor expanded in x around 0
Applied rewrites71.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= x -170.0)
(/ (- t_0 (* x eps)) 2.0)
(if (<= x 1.8)
(fma (fma (fma -0.125 x 0.3333333333333333) x -0.5) (* x x) 1.0)
(if (<= x 1.8e+138)
(/ (- t_0 (- (/ 1.0 eps) 1.0)) 2.0)
(fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (x <= -170.0) {
tmp = (t_0 - (x * eps)) / 2.0;
} else if (x <= 1.8) {
tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), (x * x), 1.0);
} else if (x <= 1.8e+138) {
tmp = (t_0 - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (x <= -170.0) tmp = Float64(Float64(t_0 - Float64(x * eps)) / 2.0); elseif (x <= 1.8) tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), Float64(x * x), 1.0); elseif (x <= 1.8e+138) tmp = Float64(Float64(t_0 - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, -170.0], N[(N[(t$95$0 - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.8], N[(N[(N[(-0.125 * x + 0.3333333333333333), $MachinePrecision] * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 1.8e+138], N[(N[(t$95$0 - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;x \leq -170:\\
\;\;\;\;\frac{t\_0 - x \cdot \varepsilon}{2}\\
\mathbf{elif}\;x \leq 1.8:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.125, x, 0.3333333333333333\right), x, -0.5\right), x \cdot x, 1\right)\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+138}:\\
\;\;\;\;\frac{t\_0 - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -170Initial program 100.0%
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
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6468.4
Applied rewrites68.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6433.5
Applied rewrites33.5%
Taylor expanded in eps around inf
Applied rewrites33.5%
if -170 < x < 1.80000000000000004Initial program 51.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.6%
Taylor expanded in x around 0
Applied rewrites74.2%
if 1.80000000000000004 < x < 1.8000000000000001e138Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6424.7
Applied rewrites24.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6443.7
Applied rewrites43.7%
if 1.8000000000000001e138 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites30.5%
Taylor expanded in x around 0
Applied rewrites71.0%
Final simplification63.7%
(FPCore (x eps)
:precision binary64
(if (<= x -170.0)
(/ (- (+ (/ 1.0 eps) 1.0) (* x eps)) 2.0)
(if (<= x 1.8)
(fma (fma (fma -0.125 x 0.3333333333333333) x -0.5) (* x x) 1.0)
(if (<= x 1.8e+138)
(/ (- (/ 1.0 eps) (- (/ 1.0 eps) 1.0)) 2.0)
(fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -170.0) {
tmp = (((1.0 / eps) + 1.0) - (x * eps)) / 2.0;
} else if (x <= 1.8) {
tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), (x * x), 1.0);
} else if (x <= 1.8e+138) {
tmp = ((1.0 / eps) - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -170.0) tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(x * eps)) / 2.0); elseif (x <= 1.8) tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), Float64(x * x), 1.0); elseif (x <= 1.8e+138) tmp = Float64(Float64(Float64(1.0 / eps) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -170.0], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1.8], N[(N[(N[(-0.125 * x + 0.3333333333333333), $MachinePrecision] * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 1.8e+138], N[(N[(N[(1.0 / eps), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -170:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - x \cdot \varepsilon}{2}\\
\mathbf{elif}\;x \leq 1.8:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.125, x, 0.3333333333333333\right), x, -0.5\right), x \cdot x, 1\right)\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{+138}:\\
\;\;\;\;\frac{\frac{1}{\varepsilon} - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -170Initial program 100.0%
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
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6468.4
Applied rewrites68.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6433.5
Applied rewrites33.5%
Taylor expanded in eps around inf
Applied rewrites33.5%
if -170 < x < 1.80000000000000004Initial program 51.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.6%
Taylor expanded in x around 0
Applied rewrites74.2%
if 1.80000000000000004 < x < 1.8000000000000001e138Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6424.7
Applied rewrites24.7%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f642.8
Applied rewrites2.8%
Taylor expanded in x around 0
Applied rewrites43.7%
if 1.8000000000000001e138 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites30.5%
Taylor expanded in x around 0
Applied rewrites71.0%
Final simplification63.7%
(FPCore (x eps) :precision binary64 (if (<= x -170.0) (/ (- (+ (/ 1.0 eps) 1.0) (* x eps)) 2.0) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -170.0) {
tmp = (((1.0 / eps) + 1.0) - (x * eps)) / 2.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -170.0) tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(x * eps)) / 2.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -170.0], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(x * eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -170:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - x \cdot \varepsilon}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -170Initial program 100.0%
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
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64N/A
lower--.f64N/A
lower-/.f6468.4
Applied rewrites68.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6433.5
Applied rewrites33.5%
Taylor expanded in eps around inf
Applied rewrites33.5%
if -170 < x Initial program 66.4%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites63.1%
Taylor expanded in x around 0
Applied rewrites65.4%
Final simplification60.4%
(FPCore (x eps) :precision binary64 (if (<= eps 41000000.0) (/ (+ x 1.0) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0)) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (eps <= 41000000.0) {
tmp = (x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 41000000.0) tmp = Float64(Float64(x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 41000000.0], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 41000000:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if eps < 4.1e7Initial program 60.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.1%
Taylor expanded in x around 0
Applied rewrites53.0%
Applied rewrites53.0%
Taylor expanded in x around 0
Applied rewrites61.7%
if 4.1e7 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites21.1%
Taylor expanded in x around 0
Applied rewrites40.4%
(FPCore (x eps) :precision binary64 (if (<= eps 1.55e-51) (/ 1.0 (* (fma x (- x 1.0) 1.0) 1.0)) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (eps <= 1.55e-51) {
tmp = 1.0 / (fma(x, (x - 1.0), 1.0) * 1.0);
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 1.55e-51) tmp = Float64(1.0 / Float64(fma(x, Float64(x - 1.0), 1.0) * 1.0)); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 1.55e-51], N[(1.0 / N[(N[(x * N[(x - 1.0), $MachinePrecision] + 1.0), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1.55 \cdot 10^{-51}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(x, x - 1, 1\right) \cdot 1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if eps < 1.5499999999999999e-51Initial program 61.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites63.9%
Taylor expanded in x around 0
Applied rewrites51.2%
Applied rewrites52.9%
Taylor expanded in x around 0
Applied rewrites56.9%
if 1.5499999999999999e-51 < eps Initial program 91.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites31.4%
Taylor expanded in x around 0
Applied rewrites46.8%
Final simplification53.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 71.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites53.3%
Taylor expanded in x around 0
Applied rewrites55.2%
(FPCore (x eps) :precision binary64 1.0)
double code(double x, double eps) {
return 1.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0
end function
public static double code(double x, double eps) {
return 1.0;
}
def code(x, eps): return 1.0
function code(x, eps) return 1.0 end
function tmp = code(x, eps) tmp = 1.0; end
code[x_, eps_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 71.6%
Taylor expanded in x around 0
Applied rewrites44.7%
herbie shell --seed 2024271
(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))