
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (/ 1.0 eps) 1.0))
(t_1 (* (exp (* (- eps 1.0) x)) (+ (/ 1.0 eps) 1.0))))
(if (<= (- t_1 (* (exp (* (- -1.0 eps) x)) t_0)) 0.0)
(* (exp (- x)) (+ x 1.0))
(/ (- t_1 (* (pow (exp -1.0) (fma x eps x)) t_0)) 2.0))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) - 1.0;
double t_1 = exp(((eps - 1.0) * x)) * ((1.0 / eps) + 1.0);
double tmp;
if ((t_1 - (exp(((-1.0 - eps) * x)) * t_0)) <= 0.0) {
tmp = exp(-x) * (x + 1.0);
} else {
tmp = (t_1 - (pow(exp(-1.0), fma(x, eps, x)) * t_0)) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) - 1.0) t_1 = Float64(exp(Float64(Float64(eps - 1.0) * x)) * Float64(Float64(1.0 / eps) + 1.0)) tmp = 0.0 if (Float64(t_1 - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * t_0)) <= 0.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); else tmp = Float64(Float64(t_1 - Float64((exp(-1.0) ^ fma(x, eps, x)) * t_0)) / 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[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 - N[(N[Power[N[Exp[-1.0], $MachinePrecision], N[(x * eps + x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} - 1\\
t_1 := e^{\left(\varepsilon - 1\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} + 1\right)\\
\mathbf{if}\;t\_1 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot t\_0 \leq 0:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 - {\left(e^{-1}\right)}^{\left(\mathsf{fma}\left(x, \varepsilon, x\right)\right)} \cdot 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 43.8%
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%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0))
(t_1 (* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0))))
(if (<= (- (* (exp (* (- eps 1.0) x)) t_0) t_1) 2.0)
(* (exp (- x)) (+ x 1.0))
(/
(- (* (exp (/ (* (+ (* eps eps) -1.0) x) (- eps -1.0))) t_0) t_1)
2.0))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double t_1 = exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0);
double tmp;
if (((exp(((eps - 1.0) * x)) * t_0) - t_1) <= 2.0) {
tmp = exp(-x) * (x + 1.0);
} else {
tmp = ((exp(((((eps * eps) + -1.0) * x) / (eps - -1.0))) * t_0) - t_1) / 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) :: tmp
t_0 = (1.0d0 / eps) + 1.0d0
t_1 = exp((((-1.0d0) - eps) * x)) * ((1.0d0 / eps) - 1.0d0)
if (((exp(((eps - 1.0d0) * x)) * t_0) - t_1) <= 2.0d0) then
tmp = exp(-x) * (x + 1.0d0)
else
tmp = ((exp(((((eps * eps) + (-1.0d0)) * x) / (eps - (-1.0d0)))) * t_0) - t_1) / 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 = Math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0);
double tmp;
if (((Math.exp(((eps - 1.0) * x)) * t_0) - t_1) <= 2.0) {
tmp = Math.exp(-x) * (x + 1.0);
} else {
tmp = ((Math.exp(((((eps * eps) + -1.0) * x) / (eps - -1.0))) * t_0) - t_1) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = (1.0 / eps) + 1.0 t_1 = math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0) tmp = 0 if ((math.exp(((eps - 1.0) * x)) * t_0) - t_1) <= 2.0: tmp = math.exp(-x) * (x + 1.0) else: tmp = ((math.exp(((((eps * eps) + -1.0) * x) / (eps - -1.0))) * t_0) - t_1) / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) t_1 = Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0)) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * t_0) - t_1) <= 2.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); else tmp = Float64(Float64(Float64(exp(Float64(Float64(Float64(Float64(eps * eps) + -1.0) * x) / Float64(eps - -1.0))) * t_0) - t_1) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = (1.0 / eps) + 1.0; t_1 = exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0); tmp = 0.0; if (((exp(((eps - 1.0) * x)) * t_0) - t_1) <= 2.0) tmp = exp(-x) * (x + 1.0); else tmp = ((exp(((((eps * eps) + -1.0) * x) / (eps - -1.0))) * t_0) - t_1) / 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[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - t$95$1), $MachinePrecision], 2.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Exp[N[(N[(N[(N[(eps * eps), $MachinePrecision] + -1.0), $MachinePrecision] * x), $MachinePrecision] / N[(eps - -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - t$95$1), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
t_1 := e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)\\
\mathbf{if}\;e^{\left(\varepsilon - 1\right) \cdot x} \cdot t\_0 - t\_1 \leq 2:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\frac{\left(\varepsilon \cdot \varepsilon + -1\right) \cdot x}{\varepsilon - -1}} \cdot t\_0 - t\_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))))) < 2Initial program 59.4%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Applied rewrites100.0%
if 2 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
lift-neg.f64N/A
lift-*.f64N/A
lift--.f64N/A
flip--N/A
lift-+.f64N/A
associate-*l/N/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-*.f64N/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
lift-+.f64N/A
distribute-neg-inN/A
metadata-evalN/A
unsub-negN/A
lower--.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<=
(-
(* (exp (* (- eps 1.0) x)) t_0)
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
2.0)
(* (exp (- x)) (+ x 1.0))
(/ (- (* (exp (* x eps)) t_0) (- (exp (- (fma x eps x))))) 2.0))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (((exp(((eps - 1.0) * x)) * t_0) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 2.0) {
tmp = exp(-x) * (x + 1.0);
} else {
tmp = ((exp((x * eps)) * t_0) - -exp(-fma(x, eps, x))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * t_0) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 2.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); else tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * t_0) - Float64(-exp(Float64(-fma(x, eps, 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[N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $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], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;e^{\left(\varepsilon - 1\right) \cdot x} \cdot t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 2:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot t\_0 - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)}{2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 2Initial program 59.4%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Applied rewrites100.0%
if 2 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<=
(-
(* (exp (* (- eps 1.0) x)) t_0)
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
4.0)
(* (exp (- x)) (+ x 1.0))
(/ (- t_0 (/ -1.0 (exp (fma x eps x)))) 2.0))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (((exp(((eps - 1.0) * x)) * 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 / exp(fma(x, eps, x)))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * 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 - Float64(-1.0 / exp(fma(x, eps, 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[N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - 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 - N[(-1.0 / N[Exp[N[(x * eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;e^{\left(\varepsilon - 1\right) \cdot x} \cdot 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 - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\right)}}}{2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 4Initial program 59.6%
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 eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6449.2
Applied rewrites49.2%
Final simplification80.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<=
(-
(* (exp (* (- eps 1.0) x)) t_0)
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
4.0)
(* (exp (- x)) (+ x 1.0))
(/ (- t_0 (- (exp (- (fma x eps x))))) 2.0))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (((exp(((eps - 1.0) * x)) * t_0) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) {
tmp = exp(-x) * (x + 1.0);
} else {
tmp = (t_0 - -exp(-fma(x, eps, x))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * 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 - Float64(-exp(Float64(-fma(x, eps, 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[N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - 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 - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;e^{\left(\varepsilon - 1\right) \cdot x} \cdot 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 - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)}{2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 4Initial program 59.6%
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 eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6449.2
Applied rewrites49.2%
Final simplification80.1%
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (exp (* (- eps 1.0) x)) (+ (/ 1.0 eps) 1.0))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
50000000.0)
(* (exp (- x)) (+ x 1.0))
(/ (- (/ (fma (fma 0.5 x -1.0) x 1.0) eps) -1.0) 2.0)))
double code(double x, double eps) {
double tmp;
if (((exp(((eps - 1.0) * x)) * ((1.0 / eps) + 1.0)) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 50000000.0) {
tmp = exp(-x) * (x + 1.0);
} else {
tmp = ((fma(fma(0.5, x, -1.0), x, 1.0) / eps) - -1.0) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * Float64(Float64(1.0 / eps) + 1.0)) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 50000000.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); else tmp = Float64(Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) / eps) - -1.0) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 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], 50000000.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] / eps), $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{\left(\varepsilon - 1\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} + 1\right) - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 50000000:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right)}{\varepsilon} - -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))))) < 5e7Initial program 59.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.4%
Applied rewrites99.4%
if 5e7 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites54.0%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6419.1
Applied rewrites19.1%
Taylor expanded in x around 0
Applied rewrites18.0%
Final simplification67.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0))
(t_1
(/ (- (* (exp (* (- eps 1.0) x)) t_0) (fma (- eps -1.0) x -1.0)) 2.0))
(t_2 (* (fma (- eps 1.0) x 1.0) t_0)))
(if (<= eps 0.058)
(* (exp (- x)) (+ x 1.0))
(if (<= eps 7.2e+226)
(/ (- t_2 (* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0))) 2.0)
(if (<= eps 1.5e+257)
t_1
(if (<= eps 2.55e+296)
(/ (- t_2 (/ -1.0 (exp (fma x eps x)))) 2.0)
t_1))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double t_1 = ((exp(((eps - 1.0) * x)) * t_0) - fma((eps - -1.0), x, -1.0)) / 2.0;
double t_2 = fma((eps - 1.0), x, 1.0) * t_0;
double tmp;
if (eps <= 0.058) {
tmp = exp(-x) * (x + 1.0);
} else if (eps <= 7.2e+226) {
tmp = (t_2 - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) / 2.0;
} else if (eps <= 1.5e+257) {
tmp = t_1;
} else if (eps <= 2.55e+296) {
tmp = (t_2 - (-1.0 / exp(fma(x, eps, x)))) / 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(exp(Float64(Float64(eps - 1.0) * x)) * t_0) - fma(Float64(eps - -1.0), x, -1.0)) / 2.0) t_2 = Float64(fma(Float64(eps - 1.0), x, 1.0) * t_0) tmp = 0.0 if (eps <= 0.058) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); elseif (eps <= 7.2e+226) tmp = Float64(Float64(t_2 - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) / 2.0); elseif (eps <= 1.5e+257) tmp = t_1; elseif (eps <= 2.55e+296) tmp = Float64(Float64(t_2 - Float64(-1.0 / exp(fma(x, eps, x)))) / 2.0); else tmp = t_1; 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[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(N[(eps - -1.0), $MachinePrecision] * x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[eps, 0.058], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 7.2e+226], N[(N[(t$95$2 - 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], If[LessEqual[eps, 1.5e+257], t$95$1, If[LessEqual[eps, 2.55e+296], N[(N[(t$95$2 - N[(-1.0 / N[Exp[N[(x * eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
t_1 := \frac{e^{\left(\varepsilon - 1\right) \cdot x} \cdot t\_0 - \mathsf{fma}\left(\varepsilon - -1, x, -1\right)}{2}\\
t_2 := \mathsf{fma}\left(\varepsilon - 1, x, 1\right) \cdot t\_0\\
\mathbf{if}\;\varepsilon \leq 0.058:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{elif}\;\varepsilon \leq 7.2 \cdot 10^{+226}:\\
\;\;\;\;\frac{t\_2 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{elif}\;\varepsilon \leq 1.5 \cdot 10^{+257}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\varepsilon \leq 2.55 \cdot 10^{+296}:\\
\;\;\;\;\frac{t\_2 - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\right)}}}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eps < 0.0580000000000000029Initial program 66.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.3%
Applied rewrites71.3%
if 0.0580000000000000029 < eps < 7.19999999999999962e226Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6479.6
Applied rewrites79.6%
if 7.19999999999999962e226 < eps < 1.5e257 or 2.5500000000000001e296 < eps Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites86.2%
if 1.5e257 < eps < 2.5500000000000001e296Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Final simplification74.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0))
(t_1
(/ (- (* (exp (* (- eps 1.0) x)) t_0) (fma (- eps -1.0) x -1.0)) 2.0))
(t_2
(/
(- (* (fma (- eps 1.0) x 1.0) t_0) (/ -1.0 (exp (fma x eps x))))
2.0)))
(if (<= eps 270000.0)
(* (exp (- x)) (+ x 1.0))
(if (<= eps 7.2e+226)
t_2
(if (<= eps 1.5e+257) t_1 (if (<= eps 2.55e+296) t_2 t_1))))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double t_1 = ((exp(((eps - 1.0) * x)) * t_0) - fma((eps - -1.0), x, -1.0)) / 2.0;
double t_2 = ((fma((eps - 1.0), x, 1.0) * t_0) - (-1.0 / exp(fma(x, eps, x)))) / 2.0;
double tmp;
if (eps <= 270000.0) {
tmp = exp(-x) * (x + 1.0);
} else if (eps <= 7.2e+226) {
tmp = t_2;
} else if (eps <= 1.5e+257) {
tmp = t_1;
} else if (eps <= 2.55e+296) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) t_1 = Float64(Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * t_0) - fma(Float64(eps - -1.0), x, -1.0)) / 2.0) t_2 = Float64(Float64(Float64(fma(Float64(eps - 1.0), x, 1.0) * t_0) - Float64(-1.0 / exp(fma(x, eps, x)))) / 2.0) tmp = 0.0 if (eps <= 270000.0) tmp = Float64(exp(Float64(-x)) * Float64(x + 1.0)); elseif (eps <= 7.2e+226) tmp = t_2; elseif (eps <= 1.5e+257) tmp = t_1; elseif (eps <= 2.55e+296) tmp = t_2; else tmp = t_1; 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[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(N[(eps - -1.0), $MachinePrecision] * x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(N[(eps - 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[eps, 270000.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 7.2e+226], t$95$2, If[LessEqual[eps, 1.5e+257], t$95$1, If[LessEqual[eps, 2.55e+296], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
t_1 := \frac{e^{\left(\varepsilon - 1\right) \cdot x} \cdot t\_0 - \mathsf{fma}\left(\varepsilon - -1, x, -1\right)}{2}\\
t_2 := \frac{\mathsf{fma}\left(\varepsilon - 1, x, 1\right) \cdot t\_0 - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\right)}}}{2}\\
\mathbf{if}\;\varepsilon \leq 270000:\\
\;\;\;\;e^{-x} \cdot \left(x + 1\right)\\
\mathbf{elif}\;\varepsilon \leq 7.2 \cdot 10^{+226}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\varepsilon \leq 1.5 \cdot 10^{+257}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\varepsilon \leq 2.55 \cdot 10^{+296}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eps < 2.7e5Initial program 66.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.5%
Applied rewrites71.5%
if 2.7e5 < eps < 7.19999999999999962e226 or 1.5e257 < eps < 2.5500000000000001e296Initial program 99.9%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6499.1
Applied rewrites99.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6480.6
Applied rewrites80.6%
if 7.19999999999999962e226 < eps < 1.5e257 or 2.5500000000000001e296 < eps Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites86.2%
Final simplification74.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -720.0)
(* 0.5 (- (/ t_0 eps) -1.0))
(if (<= x -2e-182)
(fma
(* 0.5 x)
(fma (- eps 1.0) (+ (/ 1.0 eps) 1.0) (/ (- 1.0 (* eps eps)) eps))
1.0)
(* t_0 (+ x 1.0))))))
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if (x <= -720.0) {
tmp = 0.5 * ((t_0 / eps) - -1.0);
} else if (x <= -2e-182) {
tmp = fma((0.5 * x), fma((eps - 1.0), ((1.0 / eps) + 1.0), ((1.0 - (eps * eps)) / eps)), 1.0);
} else {
tmp = t_0 * (x + 1.0);
}
return tmp;
}
function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -720.0) tmp = Float64(0.5 * Float64(Float64(t_0 / eps) - -1.0)); elseif (x <= -2e-182) tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), Float64(Float64(1.0 / eps) + 1.0), Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0); else tmp = Float64(t_0 * Float64(x + 1.0)); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -720.0], N[(0.5 * N[(N[(t$95$0 / eps), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2e-182], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(t$95$0 * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -720:\\
\;\;\;\;0.5 \cdot \left(\frac{t\_0}{\varepsilon} - -1\right)\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-182}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, \frac{1}{\varepsilon} + 1, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(x + 1\right)\\
\end{array}
\end{array}
if x < -720Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites57.8%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6443.6
Applied rewrites43.6%
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6443.6
Applied rewrites43.6%
if -720 < x < -2.0000000000000001e-182Initial program 63.3%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f6463.3
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6463.3
Applied rewrites63.3%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites64.9%
Taylor expanded in eps around 0
Applied rewrites77.6%
if -2.0000000000000001e-182 < x Initial program 72.5%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.9%
Applied rewrites73.9%
Final simplification69.8%
(FPCore (x eps)
:precision binary64
(if (<= x -2.6e+83)
(/
(- (/ (fma (fma (fma -0.16666666666666666 x 0.5) x -1.0) x 1.0) eps) -1.0)
2.0)
(if (<= x -2e-182)
(fma
(* 0.5 x)
(fma (- eps 1.0) (+ (/ 1.0 eps) 1.0) (/ (- 1.0 (* eps eps)) eps))
1.0)
(if (<= x 1.8)
(fma (fma (fma -0.125 x 0.3333333333333333) x -0.5) (* x x) 1.0)
0.0))))
double code(double x, double eps) {
double tmp;
if (x <= -2.6e+83) {
tmp = ((fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) / eps) - -1.0) / 2.0;
} else if (x <= -2e-182) {
tmp = fma((0.5 * x), fma((eps - 1.0), ((1.0 / eps) + 1.0), ((1.0 - (eps * eps)) / eps)), 1.0);
} else if (x <= 1.8) {
tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), (x * x), 1.0);
} else {
tmp = 0.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -2.6e+83) tmp = Float64(Float64(Float64(fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) / eps) - -1.0) / 2.0); elseif (x <= -2e-182) tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), Float64(Float64(1.0 / eps) + 1.0), Float64(Float64(1.0 - Float64(eps * eps)) / eps)), 1.0); elseif (x <= 1.8) tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), Float64(x * x), 1.0); else tmp = 0.0; end return tmp end
code[x_, eps_] := If[LessEqual[x, -2.6e+83], N[(N[(N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] / eps), $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -2e-182], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] + N[(N[(1.0 - N[(eps * eps), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.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], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \cdot 10^{+83}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right)}{\varepsilon} - -1}{2}\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-182}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, \frac{1}{\varepsilon} + 1, \frac{1 - \varepsilon \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
\mathbf{elif}\;x \leq 1.8:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.125, x, 0.3333333333333333\right), x, -0.5\right), x \cdot x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -2.6000000000000001e83Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites56.6%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6444.8
Applied rewrites44.8%
Taylor expanded in x around 0
Applied rewrites38.3%
if -2.6000000000000001e83 < x < -2.0000000000000001e-182Initial program 71.1%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f6471.1
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f6471.1
Applied rewrites71.1%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites51.7%
Taylor expanded in eps around 0
Applied rewrites67.8%
if -2.0000000000000001e-182 < x < 1.80000000000000004Initial program 51.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.7%
Taylor expanded in x around 0
Applied rewrites83.9%
if 1.80000000000000004 < x Initial program 100.0%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
div-subN/A
neg-mul-1N/A
+-inversesN/A
metadata-eval60.1
Applied rewrites60.1%
(FPCore (x eps)
:precision binary64
(if (<= x -1.2)
(/
(- (/ (fma (fma (fma -0.16666666666666666 x 0.5) x -1.0) x 1.0) eps) -1.0)
2.0)
(if (<= x 1.8)
(fma (fma (fma -0.125 x 0.3333333333333333) x -0.5) (* x x) 1.0)
0.0)))
double code(double x, double eps) {
double tmp;
if (x <= -1.2) {
tmp = ((fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) / eps) - -1.0) / 2.0;
} else if (x <= 1.8) {
tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), (x * x), 1.0);
} else {
tmp = 0.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1.2) tmp = Float64(Float64(Float64(fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) / eps) - -1.0) / 2.0); elseif (x <= 1.8) tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), Float64(x * x), 1.0); else tmp = 0.0; end return tmp end
code[x_, eps_] := If[LessEqual[x, -1.2], N[(N[(N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] / eps), $MachinePrecision] - -1.0), $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], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right)}{\varepsilon} - -1}{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{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1.19999999999999996Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites57.5%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6441.6
Applied rewrites41.6%
Taylor expanded in x around 0
Applied rewrites27.7%
if -1.19999999999999996 < x < 1.80000000000000004Initial program 53.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.8%
Taylor expanded in x around 0
Applied rewrites80.2%
if 1.80000000000000004 < x Initial program 100.0%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
div-subN/A
neg-mul-1N/A
+-inversesN/A
metadata-eval60.1
Applied rewrites60.1%
(FPCore (x eps)
:precision binary64
(if (<= x -1.2)
(/ (- (/ (fma (fma 0.5 x -1.0) x 1.0) eps) -1.0) 2.0)
(if (<= x 1.8)
(fma (fma (fma -0.125 x 0.3333333333333333) x -0.5) (* x x) 1.0)
0.0)))
double code(double x, double eps) {
double tmp;
if (x <= -1.2) {
tmp = ((fma(fma(0.5, x, -1.0), x, 1.0) / eps) - -1.0) / 2.0;
} else if (x <= 1.8) {
tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), (x * x), 1.0);
} else {
tmp = 0.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1.2) tmp = Float64(Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) / eps) - -1.0) / 2.0); elseif (x <= 1.8) tmp = fma(fma(fma(-0.125, x, 0.3333333333333333), x, -0.5), Float64(x * x), 1.0); else tmp = 0.0; end return tmp end
code[x_, eps_] := If[LessEqual[x, -1.2], N[(N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] / eps), $MachinePrecision] - -1.0), $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], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right)}{\varepsilon} - -1}{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{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1.19999999999999996Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites57.5%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6441.6
Applied rewrites41.6%
Taylor expanded in x around 0
Applied rewrites16.2%
if -1.19999999999999996 < x < 1.80000000000000004Initial program 53.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites80.8%
Taylor expanded in x around 0
Applied rewrites80.2%
if 1.80000000000000004 < x Initial program 100.0%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
div-subN/A
neg-mul-1N/A
+-inversesN/A
metadata-eval60.1
Applied rewrites60.1%
(FPCore (x eps) :precision binary64 (if (<= x 7500000000000.0) 1.0 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 7500000000000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 7500000000000.0d0) then
tmp = 1.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 7500000000000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 7500000000000.0: tmp = 1.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 7500000000000.0) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 7500000000000.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 7500000000000.0], 1.0, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7500000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 7.5e12Initial program 65.0%
Taylor expanded in x around 0
Applied rewrites60.7%
if 7.5e12 < x Initial program 100.0%
lift-exp.f64N/A
lift-neg.f64N/A
neg-mul-1N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64100.0
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in eps around 0
div-subN/A
neg-mul-1N/A
+-inversesN/A
metadata-eval62.4
Applied rewrites62.4%
(FPCore (x eps) :precision binary64 1.0)
double code(double x, double eps) {
return 1.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0
end function
public static double code(double x, double eps) {
return 1.0;
}
def code(x, eps): return 1.0
function code(x, eps) return 1.0 end
function tmp = code(x, eps) tmp = 1.0; end
code[x_, eps_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 75.4%
Taylor expanded in x around 0
Applied rewrites43.6%
herbie shell --seed 2024296
(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))