
(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 17 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 (exp (* x (- -1.0 eps)))))
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ -1.0 eps))))
(* t_0 (+ 1.0 (/ -1.0 eps))))
0.0)
(* 0.5 (* (exp (- x)) (+ x (+ x 2.0))))
(* 0.5 (+ t_0 (exp (* x eps)))))))
double code(double x, double eps) {
double t_0 = exp((x * (-1.0 - eps)));
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (-1.0 + eps)))) + (t_0 * (1.0 + (-1.0 / eps)))) <= 0.0) {
tmp = 0.5 * (exp(-x) * (x + (x + 2.0)));
} else {
tmp = 0.5 * (t_0 + exp((x * eps)));
}
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 = exp((x * ((-1.0d0) - eps)))
if ((((1.0d0 + (1.0d0 / eps)) * exp((x * ((-1.0d0) + eps)))) + (t_0 * (1.0d0 + ((-1.0d0) / eps)))) <= 0.0d0) then
tmp = 0.5d0 * (exp(-x) * (x + (x + 2.0d0)))
else
tmp = 0.5d0 * (t_0 + exp((x * eps)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.exp((x * (-1.0 - eps)));
double tmp;
if ((((1.0 + (1.0 / eps)) * Math.exp((x * (-1.0 + eps)))) + (t_0 * (1.0 + (-1.0 / eps)))) <= 0.0) {
tmp = 0.5 * (Math.exp(-x) * (x + (x + 2.0)));
} else {
tmp = 0.5 * (t_0 + Math.exp((x * eps)));
}
return tmp;
}
def code(x, eps): t_0 = math.exp((x * (-1.0 - eps))) tmp = 0 if (((1.0 + (1.0 / eps)) * math.exp((x * (-1.0 + eps)))) + (t_0 * (1.0 + (-1.0 / eps)))) <= 0.0: tmp = 0.5 * (math.exp(-x) * (x + (x + 2.0))) else: tmp = 0.5 * (t_0 + math.exp((x * eps))) return tmp
function code(x, eps) t_0 = exp(Float64(x * Float64(-1.0 - eps))) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(-1.0 + eps)))) + Float64(t_0 * Float64(1.0 + Float64(-1.0 / eps)))) <= 0.0) tmp = Float64(0.5 * Float64(exp(Float64(-x)) * Float64(x + Float64(x + 2.0)))); else tmp = Float64(0.5 * Float64(t_0 + exp(Float64(x * eps)))); end return tmp end
function tmp_2 = code(x, eps) t_0 = exp((x * (-1.0 - eps))); tmp = 0.0; if ((((1.0 + (1.0 / eps)) * exp((x * (-1.0 + eps)))) + (t_0 * (1.0 + (-1.0 / eps)))) <= 0.0) tmp = 0.5 * (exp(-x) * (x + (x + 2.0))); else tmp = 0.5 * (t_0 + exp((x * eps))); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] * N[(x + N[(x + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(t$95$0 + N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(-1 - \varepsilon\right)}\\
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(-1 + \varepsilon\right)} + t\_0 \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 0:\\
\;\;\;\;0.5 \cdot \left(e^{-x} \cdot \left(x + \left(x + 2\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(t\_0 + e^{x \cdot \varepsilon}\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 41.2%
Taylor expanded in eps around 0
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
*-commutativeN/A
distribute-rgt1-inN/A
distribute-rgt-out--N/A
distribute-lft-outN/A
lower-*.f64N/A
Simplified100.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
lower-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f64N/A
Simplified100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64100.0
Simplified100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ -1.0 eps))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))
0.0)
(* 0.5 (* (exp (- x)) (+ x (+ x 2.0))))
(* 0.5 (* 2.0 (cosh (* x eps))))))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (-1.0 + eps)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0) {
tmp = 0.5 * (exp(-x) * (x + (x + 2.0)));
} else {
tmp = 0.5 * (2.0 * cosh((x * eps)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((((1.0d0 + (1.0d0 / eps)) * exp((x * ((-1.0d0) + eps)))) + (exp((x * ((-1.0d0) - eps))) * (1.0d0 + ((-1.0d0) / eps)))) <= 0.0d0) then
tmp = 0.5d0 * (exp(-x) * (x + (x + 2.0d0)))
else
tmp = 0.5d0 * (2.0d0 * cosh((x * eps)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * Math.exp((x * (-1.0 + eps)))) + (Math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0) {
tmp = 0.5 * (Math.exp(-x) * (x + (x + 2.0)));
} else {
tmp = 0.5 * (2.0 * Math.cosh((x * eps)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (((1.0 + (1.0 / eps)) * math.exp((x * (-1.0 + eps)))) + (math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0: tmp = 0.5 * (math.exp(-x) * (x + (x + 2.0))) else: tmp = 0.5 * (2.0 * math.cosh((x * eps))) return tmp
function code(x, eps) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(-1.0 + eps)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 0.0) tmp = Float64(0.5 * Float64(exp(Float64(-x)) * Float64(x + Float64(x + 2.0)))); else tmp = Float64(0.5 * Float64(2.0 * cosh(Float64(x * eps)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((((1.0 + (1.0 / eps)) * exp((x * (-1.0 + eps)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0) tmp = 0.5 * (exp(-x) * (x + (x + 2.0))); else tmp = 0.5 * (2.0 * cosh((x * eps))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(0.5 * N[(N[Exp[(-x)], $MachinePrecision] * N[(x + N[(x + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(2.0 * N[Cosh[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(-1 + \varepsilon\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 0:\\
\;\;\;\;0.5 \cdot \left(e^{-x} \cdot \left(x + \left(x + 2\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \cosh \left(x \cdot \varepsilon\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 41.2%
Taylor expanded in eps around 0
lower-*.f64N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
*-commutativeN/A
distribute-rgt1-inN/A
distribute-rgt-out--N/A
distribute-lft-outN/A
lower-*.f64N/A
Simplified100.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
lower-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f64N/A
Simplified100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64100.0
Simplified100.0%
Taylor expanded in eps around inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f64100.0
Simplified100.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
lift-*.f64N/A
cosh-undefN/A
lower-*.f64N/A
lower-cosh.f64100.0
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ -1.0 eps))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))
0.0)
(exp (- x))
(* 0.5 (* 2.0 (cosh (* x eps))))))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (-1.0 + eps)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0) {
tmp = exp(-x);
} else {
tmp = 0.5 * (2.0 * cosh((x * eps)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((((1.0d0 + (1.0d0 / eps)) * exp((x * ((-1.0d0) + eps)))) + (exp((x * ((-1.0d0) - eps))) * (1.0d0 + ((-1.0d0) / eps)))) <= 0.0d0) then
tmp = exp(-x)
else
tmp = 0.5d0 * (2.0d0 * cosh((x * eps)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * Math.exp((x * (-1.0 + eps)))) + (Math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0) {
tmp = Math.exp(-x);
} else {
tmp = 0.5 * (2.0 * Math.cosh((x * eps)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (((1.0 + (1.0 / eps)) * math.exp((x * (-1.0 + eps)))) + (math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0: tmp = math.exp(-x) else: tmp = 0.5 * (2.0 * math.cosh((x * eps))) return tmp
function code(x, eps) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(-1.0 + eps)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 0.0) tmp = exp(Float64(-x)); else tmp = Float64(0.5 * Float64(2.0 * cosh(Float64(x * eps)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((((1.0 + (1.0 / eps)) * exp((x * (-1.0 + eps)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0) tmp = exp(-x); else tmp = 0.5 * (2.0 * cosh((x * eps))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[Exp[(-x)], $MachinePrecision], N[(0.5 * N[(2.0 * N[Cosh[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(-1 + \varepsilon\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 0:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(2 \cdot \cosh \left(x \cdot \varepsilon\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 41.2%
Taylor expanded in eps around inf
lower-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f64N/A
Simplified99.3%
Taylor expanded in eps around 0
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6499.3
Simplified99.3%
if 0.0 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Taylor expanded in eps around inf
lower-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f64N/A
Simplified100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64100.0
Simplified100.0%
Taylor expanded in eps around inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f64100.0
Simplified100.0%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
lift-+.f64N/A
*-commutativeN/A
lower-*.f64100.0
lift-+.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-rgt-neg-outN/A
lift-*.f64N/A
cosh-undefN/A
lower-*.f64N/A
lower-cosh.f64100.0
Applied egg-rr100.0%
Final simplification99.7%
(FPCore (x eps)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ -1.0 eps))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))
2.0)
(exp (- x))
(fma 0.5 (* x (/ (* eps (fma eps (fma x eps 0.0) (- x))) eps)) 1.0)))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (-1.0 + eps)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 2.0) {
tmp = exp(-x);
} else {
tmp = fma(0.5, (x * ((eps * fma(eps, fma(x, eps, 0.0), -x)) / eps)), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(-1.0 + eps)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 2.0) tmp = exp(Float64(-x)); else tmp = fma(0.5, Float64(x * Float64(Float64(eps * fma(eps, fma(x, eps, 0.0), Float64(-x))) / eps)), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], N[Exp[(-x)], $MachinePrecision], N[(0.5 * N[(x * N[(N[(eps * N[(eps * N[(x * eps + 0.0), $MachinePrecision] + (-x)), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(-1 + \varepsilon\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 2:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5, x \cdot \frac{\varepsilon \cdot \mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(x, \varepsilon, 0\right), -x\right)}{\varepsilon}, 1\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 2Initial program 55.0%
Taylor expanded in eps around inf
lower-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f64N/A
Simplified99.4%
Taylor expanded in eps around 0
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6499.4
Simplified99.4%
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 x around 0
Simplified86.0%
Applied egg-rr78.6%
Taylor expanded in eps around 0
Simplified89.3%
Final simplification94.8%
(FPCore (x eps)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ -1.0 eps))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))
4.0)
1.0
(* 0.5 (* x (* x (* eps eps))))))
double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (-1.0 + eps)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0) {
tmp = 1.0;
} else {
tmp = 0.5 * (x * (x * (eps * eps)));
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if ((((1.0d0 + (1.0d0 / eps)) * exp((x * ((-1.0d0) + eps)))) + (exp((x * ((-1.0d0) - eps))) * (1.0d0 + ((-1.0d0) / eps)))) <= 4.0d0) then
tmp = 1.0d0
else
tmp = 0.5d0 * (x * (x * (eps * eps)))
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((((1.0 + (1.0 / eps)) * Math.exp((x * (-1.0 + eps)))) + (Math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0) {
tmp = 1.0;
} else {
tmp = 0.5 * (x * (x * (eps * eps)));
}
return tmp;
}
def code(x, eps): tmp = 0 if (((1.0 + (1.0 / eps)) * math.exp((x * (-1.0 + eps)))) + (math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0: tmp = 1.0 else: tmp = 0.5 * (x * (x * (eps * eps))) return tmp
function code(x, eps) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(-1.0 + eps)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 4.0) tmp = 1.0; else tmp = Float64(0.5 * Float64(x * Float64(x * Float64(eps * eps)))); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((((1.0 + (1.0 / eps)) * exp((x * (-1.0 + eps)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0) tmp = 1.0; else tmp = 0.5 * (x * (x * (eps * eps))); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0], 1.0, N[(0.5 * N[(x * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(-1 + \varepsilon\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 4:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\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))))) < 4Initial program 55.7%
Taylor expanded in x around 0
Simplified70.7%
if 4 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Taylor expanded in x around 0
Simplified86.8%
Applied egg-rr78.4%
Taylor expanded in eps around inf
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6486.8
Simplified86.8%
Final simplification77.9%
(FPCore (x eps) :precision binary64 (* 0.5 (+ (exp (* x (+ -1.0 eps))) (exp (* x (- -1.0 eps))))))
double code(double x, double eps) {
return 0.5 * (exp((x * (-1.0 + eps))) + exp((x * (-1.0 - eps))));
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.5d0 * (exp((x * ((-1.0d0) + eps))) + exp((x * ((-1.0d0) - eps))))
end function
public static double code(double x, double eps) {
return 0.5 * (Math.exp((x * (-1.0 + eps))) + Math.exp((x * (-1.0 - eps))));
}
def code(x, eps): return 0.5 * (math.exp((x * (-1.0 + eps))) + math.exp((x * (-1.0 - eps))))
function code(x, eps) return Float64(0.5 * Float64(exp(Float64(x * Float64(-1.0 + eps))) + exp(Float64(x * Float64(-1.0 - eps))))) end
function tmp = code(x, eps) tmp = 0.5 * (exp((x * (-1.0 + eps))) + exp((x * (-1.0 - eps)))); end
code[x_, eps_] := N[(0.5 * N[(N[Exp[N[(x * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(e^{x \cdot \left(-1 + \varepsilon\right)} + e^{x \cdot \left(-1 - \varepsilon\right)}\right)
\end{array}
Initial program 75.4%
Taylor expanded in eps around inf
lower-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f64N/A
Simplified99.7%
(FPCore (x eps)
:precision binary64
(if (<= x 1600000000000.0)
(fma 0.5 (* x (/ (* eps (fma eps (fma x eps 0.0) (- x))) eps)) 1.0)
(if (<= x 8e+147)
(*
(* 0.25 (* x x))
(fma
(+ eps 1.0)
(+ eps (/ -1.0 eps))
(* (- 1.0 eps) (- (/ 1.0 eps) eps))))
(* 0.5 (* x (* x (* eps eps)))))))
double code(double x, double eps) {
double tmp;
if (x <= 1600000000000.0) {
tmp = fma(0.5, (x * ((eps * fma(eps, fma(x, eps, 0.0), -x)) / eps)), 1.0);
} else if (x <= 8e+147) {
tmp = (0.25 * (x * x)) * fma((eps + 1.0), (eps + (-1.0 / eps)), ((1.0 - eps) * ((1.0 / eps) - eps)));
} else {
tmp = 0.5 * (x * (x * (eps * eps)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 1600000000000.0) tmp = fma(0.5, Float64(x * Float64(Float64(eps * fma(eps, fma(x, eps, 0.0), Float64(-x))) / eps)), 1.0); elseif (x <= 8e+147) tmp = Float64(Float64(0.25 * Float64(x * x)) * fma(Float64(eps + 1.0), Float64(eps + Float64(-1.0 / eps)), Float64(Float64(1.0 - eps) * Float64(Float64(1.0 / eps) - eps)))); else tmp = Float64(0.5 * Float64(x * Float64(x * Float64(eps * eps)))); end return tmp end
code[x_, eps_] := If[LessEqual[x, 1600000000000.0], N[(0.5 * N[(x * N[(N[(eps * N[(eps * N[(x * eps + 0.0), $MachinePrecision] + (-x)), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 8e+147], N[(N[(0.25 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(N[(eps + 1.0), $MachinePrecision] * N[(eps + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - eps), $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1600000000000:\\
\;\;\;\;\mathsf{fma}\left(0.5, x \cdot \frac{\varepsilon \cdot \mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(x, \varepsilon, 0\right), -x\right)}{\varepsilon}, 1\right)\\
\mathbf{elif}\;x \leq 8 \cdot 10^{+147}:\\
\;\;\;\;\left(0.25 \cdot \left(x \cdot x\right)\right) \cdot \mathsf{fma}\left(\varepsilon + 1, \varepsilon + \frac{-1}{\varepsilon}, \left(1 - \varepsilon\right) \cdot \left(\frac{1}{\varepsilon} - \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\\
\end{array}
\end{array}
if x < 1.6e12Initial program 64.8%
Taylor expanded in x around 0
Simplified87.5%
Applied egg-rr87.5%
Taylor expanded in eps around 0
Simplified90.8%
if 1.6e12 < x < 7.9999999999999998e147Initial program 100.0%
Taylor expanded in x around 0
Simplified33.8%
Taylor expanded in x around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
Simplified85.3%
if 7.9999999999999998e147 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified50.5%
Applied egg-rr49.7%
Taylor expanded in eps around inf
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6480.4
Simplified80.4%
Final simplification88.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* x (* x (* eps eps)))))
(if (<= x -4.6e-223)
(fma 0.5 t_0 1.0)
(if (<= x 2.25e-27)
(fma 0.5 (* x (* eps (* x eps))) 1.0)
(if (<= x 8.2e+108)
(* (* 0.08333333333333333 (* eps (* eps eps))) (* x (* x x)))
(* 0.5 t_0))))))
double code(double x, double eps) {
double t_0 = x * (x * (eps * eps));
double tmp;
if (x <= -4.6e-223) {
tmp = fma(0.5, t_0, 1.0);
} else if (x <= 2.25e-27) {
tmp = fma(0.5, (x * (eps * (x * eps))), 1.0);
} else if (x <= 8.2e+108) {
tmp = (0.08333333333333333 * (eps * (eps * eps))) * (x * (x * x));
} else {
tmp = 0.5 * t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(x * Float64(x * Float64(eps * eps))) tmp = 0.0 if (x <= -4.6e-223) tmp = fma(0.5, t_0, 1.0); elseif (x <= 2.25e-27) tmp = fma(0.5, Float64(x * Float64(eps * Float64(x * eps))), 1.0); elseif (x <= 8.2e+108) tmp = Float64(Float64(0.08333333333333333 * Float64(eps * Float64(eps * eps))) * Float64(x * Float64(x * x))); else tmp = Float64(0.5 * t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(x * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.6e-223], N[(0.5 * t$95$0 + 1.0), $MachinePrecision], If[LessEqual[x, 2.25e-27], N[(0.5 * N[(x * N[(eps * N[(x * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 8.2e+108], N[(N[(0.08333333333333333 * N[(eps * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
\mathbf{if}\;x \leq -4.6 \cdot 10^{-223}:\\
\;\;\;\;\mathsf{fma}\left(0.5, t\_0, 1\right)\\
\mathbf{elif}\;x \leq 2.25 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(0.5, x \cdot \left(\varepsilon \cdot \left(x \cdot \varepsilon\right)\right), 1\right)\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{+108}:\\
\;\;\;\;\left(0.08333333333333333 \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right) \cdot \left(x \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot t\_0\\
\end{array}
\end{array}
if x < -4.5999999999999999e-223Initial program 76.5%
Taylor expanded in x around 0
Simplified90.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.5
Simplified90.5%
if -4.5999999999999999e-223 < x < 2.2500000000000001e-27Initial program 49.1%
Taylor expanded in x around 0
Simplified86.7%
Applied egg-rr92.8%
Taylor expanded in eps around inf
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
mul0-rgtN/A
lower-*.f64N/A
lower-+.f6492.8
Simplified92.8%
if 2.2500000000000001e-27 < x < 8.1999999999999998e108Initial program 97.2%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified27.6%
Taylor expanded in eps around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6456.6
Simplified56.6%
if 8.1999999999999998e108 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified50.6%
Applied egg-rr49.8%
Taylor expanded in eps around inf
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6480.8
Simplified80.8%
Final simplification84.8%
(FPCore (x eps)
:precision binary64
(if (<= x 3.3e-6)
(fma 0.5 (* x (/ (* eps (fma eps (fma x eps 0.0) (- x))) eps)) 1.0)
(if (<= x 8.2e+108)
(* (* 0.08333333333333333 (* eps (* eps eps))) (* x (* x x)))
(* 0.5 (* x (* x (* eps eps)))))))
double code(double x, double eps) {
double tmp;
if (x <= 3.3e-6) {
tmp = fma(0.5, (x * ((eps * fma(eps, fma(x, eps, 0.0), -x)) / eps)), 1.0);
} else if (x <= 8.2e+108) {
tmp = (0.08333333333333333 * (eps * (eps * eps))) * (x * (x * x));
} else {
tmp = 0.5 * (x * (x * (eps * eps)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 3.3e-6) tmp = fma(0.5, Float64(x * Float64(Float64(eps * fma(eps, fma(x, eps, 0.0), Float64(-x))) / eps)), 1.0); elseif (x <= 8.2e+108) tmp = Float64(Float64(0.08333333333333333 * Float64(eps * Float64(eps * eps))) * Float64(x * Float64(x * x))); else tmp = Float64(0.5 * Float64(x * Float64(x * Float64(eps * eps)))); end return tmp end
code[x_, eps_] := If[LessEqual[x, 3.3e-6], N[(0.5 * N[(x * N[(N[(eps * N[(eps * N[(x * eps + 0.0), $MachinePrecision] + (-x)), $MachinePrecision]), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 8.2e+108], N[(N[(0.08333333333333333 * N[(eps * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.3 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(0.5, x \cdot \frac{\varepsilon \cdot \mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(x, \varepsilon, 0\right), -x\right)}{\varepsilon}, 1\right)\\
\mathbf{elif}\;x \leq 8.2 \cdot 10^{+108}:\\
\;\;\;\;\left(0.08333333333333333 \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right) \cdot \left(x \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\right)\\
\end{array}
\end{array}
if x < 3.30000000000000017e-6Initial program 64.0%
Taylor expanded in x around 0
Simplified87.7%
Applied egg-rr87.8%
Taylor expanded in eps around 0
Simplified91.1%
if 3.30000000000000017e-6 < x < 8.1999999999999998e108Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified24.5%
Taylor expanded in eps around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.4
Simplified57.4%
if 8.1999999999999998e108 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified50.6%
Applied egg-rr49.8%
Taylor expanded in eps around inf
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6480.8
Simplified80.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* x (* x (* eps eps)))) (t_1 (fma 0.5 t_0 1.0)))
(if (<= x -1.45e-223)
t_1
(if (<= x 1.7e-163)
(fma (* (* x eps) (* 0.5 x)) eps 1.0)
(if (<= x 3.3e-6) t_1 (* 0.5 t_0))))))
double code(double x, double eps) {
double t_0 = x * (x * (eps * eps));
double t_1 = fma(0.5, t_0, 1.0);
double tmp;
if (x <= -1.45e-223) {
tmp = t_1;
} else if (x <= 1.7e-163) {
tmp = fma(((x * eps) * (0.5 * x)), eps, 1.0);
} else if (x <= 3.3e-6) {
tmp = t_1;
} else {
tmp = 0.5 * t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(x * Float64(x * Float64(eps * eps))) t_1 = fma(0.5, t_0, 1.0) tmp = 0.0 if (x <= -1.45e-223) tmp = t_1; elseif (x <= 1.7e-163) tmp = fma(Float64(Float64(x * eps) * Float64(0.5 * x)), eps, 1.0); elseif (x <= 3.3e-6) tmp = t_1; else tmp = Float64(0.5 * t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(x * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * t$95$0 + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.45e-223], t$95$1, If[LessEqual[x, 1.7e-163], N[(N[(N[(x * eps), $MachinePrecision] * N[(0.5 * x), $MachinePrecision]), $MachinePrecision] * eps + 1.0), $MachinePrecision], If[LessEqual[x, 3.3e-6], t$95$1, N[(0.5 * t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
t_1 := \mathsf{fma}\left(0.5, t\_0, 1\right)\\
\mathbf{if}\;x \leq -1.45 \cdot 10^{-223}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.7 \cdot 10^{-163}:\\
\;\;\;\;\mathsf{fma}\left(\left(x \cdot \varepsilon\right) \cdot \left(0.5 \cdot x\right), \varepsilon, 1\right)\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot t\_0\\
\end{array}
\end{array}
if x < -1.45e-223 or 1.70000000000000007e-163 < x < 3.30000000000000017e-6Initial program 68.9%
Taylor expanded in x around 0
Simplified90.8%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.8
Simplified90.8%
if -1.45e-223 < x < 1.70000000000000007e-163Initial program 50.5%
Taylor expanded in x around 0
Simplified79.4%
Applied egg-rr97.9%
Taylor expanded in eps around inf
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
mul0-rgtN/A
lower-*.f64N/A
lower-+.f6497.9
Simplified97.9%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
+-rgt-identityN/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied egg-rr97.9%
if 3.30000000000000017e-6 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified45.1%
Applied egg-rr44.4%
Taylor expanded in eps around inf
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6472.5
Simplified72.5%
Final simplification86.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* x (* x (* eps eps)))) (t_1 (fma 0.5 t_0 1.0)))
(if (<= x -1.45e-223)
t_1
(if (<= x 1.85e-239) 1.0 (if (<= x 3.3e-6) t_1 (* 0.5 t_0))))))
double code(double x, double eps) {
double t_0 = x * (x * (eps * eps));
double t_1 = fma(0.5, t_0, 1.0);
double tmp;
if (x <= -1.45e-223) {
tmp = t_1;
} else if (x <= 1.85e-239) {
tmp = 1.0;
} else if (x <= 3.3e-6) {
tmp = t_1;
} else {
tmp = 0.5 * t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(x * Float64(x * Float64(eps * eps))) t_1 = fma(0.5, t_0, 1.0) tmp = 0.0 if (x <= -1.45e-223) tmp = t_1; elseif (x <= 1.85e-239) tmp = 1.0; elseif (x <= 3.3e-6) tmp = t_1; else tmp = Float64(0.5 * t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(x * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * t$95$0 + 1.0), $MachinePrecision]}, If[LessEqual[x, -1.45e-223], t$95$1, If[LessEqual[x, 1.85e-239], 1.0, If[LessEqual[x, 3.3e-6], t$95$1, N[(0.5 * t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
t_1 := \mathsf{fma}\left(0.5, t\_0, 1\right)\\
\mathbf{if}\;x \leq -1.45 \cdot 10^{-223}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{-239}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot t\_0\\
\end{array}
\end{array}
if x < -1.45e-223 or 1.85000000000000008e-239 < x < 3.30000000000000017e-6Initial program 65.4%
Taylor expanded in x around 0
Simplified91.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6491.1
Simplified91.1%
if -1.45e-223 < x < 1.85000000000000008e-239Initial program 57.6%
Taylor expanded in x around 0
Simplified100.0%
if 3.30000000000000017e-6 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified45.1%
Applied egg-rr44.4%
Taylor expanded in eps around inf
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6472.5
Simplified72.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* x (* x (* eps eps)))))
(if (<= x -4.6e-223)
(fma 0.5 t_0 1.0)
(if (<= x 1600000000000.0)
(fma 0.5 (* x (* eps (* x eps))) 1.0)
(* 0.5 t_0)))))
double code(double x, double eps) {
double t_0 = x * (x * (eps * eps));
double tmp;
if (x <= -4.6e-223) {
tmp = fma(0.5, t_0, 1.0);
} else if (x <= 1600000000000.0) {
tmp = fma(0.5, (x * (eps * (x * eps))), 1.0);
} else {
tmp = 0.5 * t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(x * Float64(x * Float64(eps * eps))) tmp = 0.0 if (x <= -4.6e-223) tmp = fma(0.5, t_0, 1.0); elseif (x <= 1600000000000.0) tmp = fma(0.5, Float64(x * Float64(eps * Float64(x * eps))), 1.0); else tmp = Float64(0.5 * t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(x * N[(x * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.6e-223], N[(0.5 * t$95$0 + 1.0), $MachinePrecision], If[LessEqual[x, 1600000000000.0], N[(0.5 * N[(x * N[(eps * N[(x * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(0.5 * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
\mathbf{if}\;x \leq -4.6 \cdot 10^{-223}:\\
\;\;\;\;\mathsf{fma}\left(0.5, t\_0, 1\right)\\
\mathbf{elif}\;x \leq 1600000000000:\\
\;\;\;\;\mathsf{fma}\left(0.5, x \cdot \left(\varepsilon \cdot \left(x \cdot \varepsilon\right)\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot t\_0\\
\end{array}
\end{array}
if x < -4.5999999999999999e-223Initial program 76.5%
Taylor expanded in x around 0
Simplified90.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.5
Simplified90.5%
if -4.5999999999999999e-223 < x < 1.6e12Initial program 52.7%
Taylor expanded in x around 0
Simplified84.4%
Applied egg-rr89.9%
Taylor expanded in eps around inf
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
mul0-rgtN/A
lower-*.f64N/A
lower-+.f6489.9
Simplified89.9%
if 1.6e12 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified43.5%
Applied egg-rr42.8%
Taylor expanded in eps around inf
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6472.4
Simplified72.4%
Final simplification84.8%
(FPCore (x eps) :precision binary64 (if (<= x 1.6) (fma x (fma x (fma x -0.16666666666666666 0.5) -1.0) 1.0) 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 1.6) {
tmp = fma(x, fma(x, fma(x, -0.16666666666666666, 0.5), -1.0), 1.0);
} else {
tmp = 0.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 1.6) tmp = fma(x, fma(x, fma(x, -0.16666666666666666, 0.5), -1.0), 1.0); else tmp = 0.0; end return tmp end
code[x_, eps_] := If[LessEqual[x, 1.6], N[(x * N[(x * N[(x * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 1.0), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, -0.16666666666666666, 0.5\right), -1\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.6000000000000001Initial program 64.2%
Taylor expanded in eps around inf
lower-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f64N/A
Simplified99.5%
Taylor expanded in eps around 0
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6479.9
Simplified79.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6474.0
Simplified74.0%
if 1.6000000000000001 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified44.5%
Applied egg-rr43.7%
Taylor expanded in eps around 0
associate-*r/N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-commutativeN/A
mul0-rgtN/A
associate-*l*N/A
metadata-evalN/A
associate-*l/N/A
mul0-rgt53.2
Simplified53.2%
(FPCore (x eps) :precision binary64 (if (<= x 1600000000000.0) (fma x (fma 0.5 x -1.0) 1.0) 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 1600000000000.0) {
tmp = fma(x, fma(0.5, x, -1.0), 1.0);
} else {
tmp = 0.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 1600000000000.0) tmp = fma(x, fma(0.5, x, -1.0), 1.0); else tmp = 0.0; end return tmp end
code[x_, eps_] := If[LessEqual[x, 1600000000000.0], N[(x * N[(0.5 * x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1600000000000:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(0.5, x, -1\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.6e12Initial program 64.8%
Taylor expanded in eps around inf
lower-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f64N/A
Simplified99.5%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f64N/A
Simplified87.2%
Taylor expanded in eps around 0
sub-negN/A
metadata-evalN/A
distribute-lft-inN/A
metadata-evalN/A
lower-fma.f6469.7
Simplified69.7%
if 1.6e12 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified43.5%
Applied egg-rr42.8%
Taylor expanded in eps around 0
associate-*r/N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-commutativeN/A
mul0-rgtN/A
associate-*l*N/A
metadata-evalN/A
associate-*l/N/A
mul0-rgt55.3
Simplified55.3%
(FPCore (x eps) :precision binary64 (if (<= x 1.0) (- 1.0 x) 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 1.0) {
tmp = 1.0 - x;
} 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 <= 1.0d0) then
tmp = 1.0d0 - x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 1.0) {
tmp = 1.0 - x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 1.0: tmp = 1.0 - x else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 1.0) tmp = Float64(1.0 - x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 1.0) tmp = 1.0 - x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 1.0], N[(1.0 - x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1Initial program 64.2%
Taylor expanded in eps around inf
lower-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower-+.f64N/A
Simplified99.5%
Taylor expanded in eps around 0
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6479.9
Simplified79.9%
Taylor expanded in x around 0
neg-mul-1N/A
unsub-negN/A
lower--.f6458.0
Simplified58.0%
if 1 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified44.5%
Applied egg-rr43.7%
Taylor expanded in eps around 0
associate-*r/N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-commutativeN/A
mul0-rgtN/A
associate-*l*N/A
metadata-evalN/A
associate-*l/N/A
mul0-rgt53.2
Simplified53.2%
(FPCore (x eps) :precision binary64 (if (<= x 1600000000000.0) 1.0 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 1600000000000.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 <= 1600000000000.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 <= 1600000000000.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 1600000000000.0: tmp = 1.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 1600000000000.0) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 1600000000000.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 1600000000000.0], 1.0, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1600000000000:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.6e12Initial program 64.8%
Taylor expanded in x around 0
Simplified56.8%
if 1.6e12 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified43.5%
Applied egg-rr42.8%
Taylor expanded in eps around 0
associate-*r/N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-commutativeN/A
mul0-rgtN/A
associate-*l*N/A
metadata-evalN/A
associate-*l/N/A
mul0-rgt55.3
Simplified55.3%
(FPCore (x eps) :precision binary64 0.0)
double code(double x, double eps) {
return 0.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 0.0d0
end function
public static double code(double x, double eps) {
return 0.0;
}
def code(x, eps): return 0.0
function code(x, eps) return 0.0 end
function tmp = code(x, eps) tmp = 0.0; end
code[x_, eps_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 75.4%
Taylor expanded in x around 0
Simplified74.3%
Applied egg-rr74.1%
Taylor expanded in eps around 0
associate-*r/N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
*-commutativeN/A
mul0-rgtN/A
associate-*l*N/A
metadata-evalN/A
associate-*l/N/A
mul0-rgt18.3
Simplified18.3%
herbie shell --seed 2024207
(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))