
(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 12 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))))
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))
0.0)
(* 0.5 (fma (+ x 2.0) t_0 (* x t_0)))
(* 0.5 (* 2.0 (cosh (* x eps)))))))
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 0.0) {
tmp = 0.5 * fma((x + 2.0), t_0, (x * t_0));
} else {
tmp = 0.5 * (2.0 * cosh((x * eps)));
}
return tmp;
}
function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 0.0) tmp = Float64(0.5 * fma(Float64(x + 2.0), t_0, Float64(x * t_0))); else tmp = Float64(0.5 * Float64(2.0 * cosh(Float64(x * eps)))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps + -1.0), $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[(x + 2.0), $MachinePrecision] * t$95$0 + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(2.0 * N[Cosh[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 0:\\
\;\;\;\;0.5 \cdot \mathsf{fma}\left(x + 2, t\_0, x \cdot t\_0\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 31.5%
Taylor expanded in eps around 0
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
distribute-rgt1-inN/A
distribute-rgt-out--N/A
*-commutativeN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f64N/A
+-lowering-+.f64N/A
Simplified99.9%
distribute-rgt-inN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f64N/A
*-lowering-*.f64N/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f64100.0
Applied egg-rr100.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
*-lowering-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f64N/A
Simplified100.0%
Taylor expanded in eps around inf
*-commutativeN/A
*-lowering-*.f64100.0
Simplified100.0%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64100.0
Simplified100.0%
*-commutativeN/A
*-lowering-*.f64N/A
distribute-rgt-neg-outN/A
cosh-undefN/A
*-lowering-*.f64N/A
cosh-lowering-cosh.f64N/A
*-lowering-*.f64100.0
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (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 * (eps + -1.0)))) + (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 * (eps + (-1.0d0))))) + (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 * (eps + -1.0)))) + (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 * (eps + -1.0)))) + (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(eps + -1.0)))) + 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 * (eps + -1.0)))) + (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[(eps + -1.0), $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(\varepsilon + -1\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 31.5%
Taylor expanded in eps around 0
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
distribute-rgt1-inN/A
distribute-rgt-out--N/A
*-commutativeN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f64N/A
+-lowering-+.f64N/A
Simplified99.9%
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
*-lowering-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f64N/A
Simplified100.0%
Taylor expanded in eps around inf
*-commutativeN/A
*-lowering-*.f64100.0
Simplified100.0%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64100.0
Simplified100.0%
*-commutativeN/A
*-lowering-*.f64N/A
distribute-rgt-neg-outN/A
cosh-undefN/A
*-lowering-*.f64N/A
cosh-lowering-cosh.f64N/A
*-lowering-*.f64100.0
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (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 * (eps + -1.0)))) + (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 * (eps + (-1.0d0))))) + (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 * (eps + -1.0)))) + (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 * (eps + -1.0)))) + (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(eps + -1.0)))) + 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 * (eps + -1.0)))) + (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[(eps + -1.0), $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(\varepsilon + -1\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 31.5%
Taylor expanded in eps around inf
*-lowering-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f64N/A
Simplified98.2%
Taylor expanded in eps around 0
distribute-rgt-inN/A
neg-mul-1N/A
distribute-lft-outN/A
metadata-evalN/A
*-lowering-*.f64N/A
neg-mul-1N/A
exp-lowering-exp.f64N/A
neg-mul-1N/A
neg-lowering-neg.f6498.2
Simplified98.2%
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
*-lowering-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f64N/A
Simplified100.0%
Taylor expanded in eps around inf
*-commutativeN/A
*-lowering-*.f64100.0
Simplified100.0%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f64100.0
Simplified100.0%
*-commutativeN/A
*-lowering-*.f64N/A
distribute-rgt-neg-outN/A
cosh-undefN/A
*-lowering-*.f64N/A
cosh-lowering-cosh.f64N/A
*-lowering-*.f64100.0
Applied egg-rr100.0%
Final simplification99.2%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (/ 1.0 eps))) (t_1 (+ -1.0 (/ 1.0 eps))))
(if (<=
(+
(* t_0 (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))
4.0)
(exp (- x))
(/
(/
(* (+ (/ 1.0 eps) (+ 1.0 t_1)) (+ 1.0 (+ 1.0 (/ 0.0 eps))))
(+ t_0 t_1))
2.0))))
double code(double x, double eps) {
double t_0 = 1.0 + (1.0 / eps);
double t_1 = -1.0 + (1.0 / eps);
double tmp;
if (((t_0 * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0) {
tmp = exp(-x);
} else {
tmp = ((((1.0 / eps) + (1.0 + t_1)) * (1.0 + (1.0 + (0.0 / eps)))) / (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 + (1.0d0 / eps)
t_1 = (-1.0d0) + (1.0d0 / eps)
if (((t_0 * exp((x * (eps + (-1.0d0))))) + (exp((x * ((-1.0d0) - eps))) * (1.0d0 + ((-1.0d0) / eps)))) <= 4.0d0) then
tmp = exp(-x)
else
tmp = ((((1.0d0 / eps) + (1.0d0 + t_1)) * (1.0d0 + (1.0d0 + (0.0d0 / eps)))) / (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 + (1.0 / eps);
double t_1 = -1.0 + (1.0 / eps);
double tmp;
if (((t_0 * Math.exp((x * (eps + -1.0)))) + (Math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0) {
tmp = Math.exp(-x);
} else {
tmp = ((((1.0 / eps) + (1.0 + t_1)) * (1.0 + (1.0 + (0.0 / eps)))) / (t_0 + t_1)) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = 1.0 + (1.0 / eps) t_1 = -1.0 + (1.0 / eps) tmp = 0 if ((t_0 * math.exp((x * (eps + -1.0)))) + (math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0: tmp = math.exp(-x) else: tmp = ((((1.0 / eps) + (1.0 + t_1)) * (1.0 + (1.0 + (0.0 / eps)))) / (t_0 + t_1)) / 2.0 return tmp
function code(x, eps) t_0 = Float64(1.0 + Float64(1.0 / eps)) t_1 = Float64(-1.0 + Float64(1.0 / eps)) tmp = 0.0 if (Float64(Float64(t_0 * exp(Float64(x * Float64(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 4.0) tmp = exp(Float64(-x)); else tmp = Float64(Float64(Float64(Float64(Float64(1.0 / eps) + Float64(1.0 + t_1)) * Float64(1.0 + Float64(1.0 + Float64(0.0 / eps)))) / Float64(t_0 + t_1)) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = 1.0 + (1.0 / eps); t_1 = -1.0 + (1.0 / eps); tmp = 0.0; if (((t_0 * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0) tmp = exp(-x); else tmp = ((((1.0 / eps) + (1.0 + t_1)) * (1.0 + (1.0 + (0.0 / eps)))) / (t_0 + t_1)) / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 * N[Exp[N[(x * N[(eps + -1.0), $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], N[Exp[(-x)], $MachinePrecision], N[(N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(1.0 + N[(0.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + t$95$1), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{1}{\varepsilon}\\
t_1 := -1 + \frac{1}{\varepsilon}\\
\mathbf{if}\;t\_0 \cdot e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 4:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\frac{1}{\varepsilon} + \left(1 + t\_1\right)\right) \cdot \left(1 + \left(1 + \frac{0}{\varepsilon}\right)\right)}{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))))) < 4Initial program 51.6%
Taylor expanded in eps around inf
*-lowering-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f64N/A
Simplified98.7%
Taylor expanded in eps around 0
distribute-rgt-inN/A
neg-mul-1N/A
distribute-lft-outN/A
metadata-evalN/A
*-lowering-*.f64N/A
neg-mul-1N/A
exp-lowering-exp.f64N/A
neg-mul-1N/A
neg-lowering-neg.f6498.2
Simplified98.2%
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
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f6454.3
Simplified54.3%
Taylor expanded in x around 0
+-lowering-+.f64N/A
/-lowering-/.f643.1
Simplified3.1%
sub-negN/A
flip-+N/A
sqr-negN/A
/-lowering-/.f64N/A
Applied egg-rr49.1%
Final simplification77.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ 1.0 (/ 1.0 eps))) (t_1 (+ -1.0 (/ 1.0 eps))))
(if (<=
(+
(* t_0 (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))
4.0)
(fma 0.5 (* (* x eps) (* x eps)) 1.0)
(/
(/
(* (+ (/ 1.0 eps) (+ 1.0 t_1)) (+ 1.0 (+ 1.0 (/ 0.0 eps))))
(+ t_0 t_1))
2.0))))
double code(double x, double eps) {
double t_0 = 1.0 + (1.0 / eps);
double t_1 = -1.0 + (1.0 / eps);
double tmp;
if (((t_0 * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)))) <= 4.0) {
tmp = fma(0.5, ((x * eps) * (x * eps)), 1.0);
} else {
tmp = ((((1.0 / eps) + (1.0 + t_1)) * (1.0 + (1.0 + (0.0 / eps)))) / (t_0 + t_1)) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(1.0 + Float64(1.0 / eps)) t_1 = Float64(-1.0 + Float64(1.0 / eps)) tmp = 0.0 if (Float64(Float64(t_0 * exp(Float64(x * Float64(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 4.0) tmp = fma(0.5, Float64(Float64(x * eps) * Float64(x * eps)), 1.0); else tmp = Float64(Float64(Float64(Float64(Float64(1.0 / eps) + Float64(1.0 + t_1)) * Float64(1.0 + Float64(1.0 + Float64(0.0 / eps)))) / Float64(t_0 + t_1)) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(t$95$0 * N[Exp[N[(x * N[(eps + -1.0), $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], N[(0.5 * N[(N[(x * eps), $MachinePrecision] * N[(x * eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(1.0 + N[(0.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + t$95$1), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{1}{\varepsilon}\\
t_1 := -1 + \frac{1}{\varepsilon}\\
\mathbf{if}\;t\_0 \cdot e^{x \cdot \left(\varepsilon + -1\right)} + e^{x \cdot \left(-1 - \varepsilon\right)} \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 4:\\
\;\;\;\;\mathsf{fma}\left(0.5, \left(x \cdot \varepsilon\right) \cdot \left(x \cdot \varepsilon\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\frac{1}{\varepsilon} + \left(1 + t\_1\right)\right) \cdot \left(1 + \left(1 + \frac{0}{\varepsilon}\right)\right)}{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))))) < 4Initial program 51.6%
Taylor expanded in x around 0
Simplified75.1%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6476.6
Simplified76.6%
associate-*r*N/A
unswap-sqrN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6479.2
Applied egg-rr79.2%
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
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f6454.3
Simplified54.3%
Taylor expanded in x around 0
+-lowering-+.f64N/A
/-lowering-/.f643.1
Simplified3.1%
sub-negN/A
flip-+N/A
sqr-negN/A
/-lowering-/.f64N/A
Applied egg-rr49.1%
Final simplification66.7%
(FPCore (x eps)
:precision binary64
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (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 * (eps + -1.0)))) + (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 * (eps + (-1.0d0))))) + (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 * (eps + -1.0)))) + (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 * (eps + -1.0)))) + (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(eps + -1.0)))) + 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 * (eps + -1.0)))) + (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[(eps + -1.0), $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(\varepsilon + -1\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 51.6%
Taylor expanded in x around 0
Simplified79.0%
if 4 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Taylor expanded in x around 0
Simplified86.6%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6486.6
Simplified86.6%
Taylor expanded in x around inf
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6486.6
Simplified86.6%
Final simplification82.1%
(FPCore (x eps) :precision binary64 (* 0.5 (+ (exp (- (* x eps) x)) (exp (* x (- -1.0 eps))))))
double code(double x, double eps) {
return 0.5 * (exp(((x * eps) - x)) + 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 * eps) - x)) + exp((x * ((-1.0d0) - eps))))
end function
public static double code(double x, double eps) {
return 0.5 * (Math.exp(((x * eps) - x)) + Math.exp((x * (-1.0 - eps))));
}
def code(x, eps): return 0.5 * (math.exp(((x * eps) - x)) + math.exp((x * (-1.0 - eps))))
function code(x, eps) return Float64(0.5 * Float64(exp(Float64(Float64(x * eps) - x)) + exp(Float64(x * Float64(-1.0 - eps))))) end
function tmp = code(x, eps) tmp = 0.5 * (exp(((x * eps) - x)) + exp((x * (-1.0 - eps)))); end
code[x_, eps_] := N[(0.5 * N[(N[Exp[N[(N[(x * eps), $MachinePrecision] - x), $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 \varepsilon - x} + e^{x \cdot \left(-1 - \varepsilon\right)}\right)
\end{array}
Initial program 71.6%
Taylor expanded in eps around inf
*-lowering-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f64N/A
Simplified99.2%
(FPCore (x eps)
:precision binary64
(if (<= x 0.0078)
(fma
0.5
(*
x
(fma
(+ eps 1.0)
(+ -1.0 (/ 1.0 eps))
(/ (fma eps (- (fma eps (+ (- 1.0 x) (fma x eps x)) 0.0) x) -1.0) eps)))
1.0)
(* 0.5 (* x (* x (* eps eps))))))
double code(double x, double eps) {
double tmp;
if (x <= 0.0078) {
tmp = fma(0.5, (x * fma((eps + 1.0), (-1.0 + (1.0 / eps)), (fma(eps, (fma(eps, ((1.0 - x) + fma(x, eps, x)), 0.0) - x), -1.0) / eps))), 1.0);
} else {
tmp = 0.5 * (x * (x * (eps * eps)));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 0.0078) tmp = fma(0.5, Float64(x * fma(Float64(eps + 1.0), Float64(-1.0 + Float64(1.0 / eps)), Float64(fma(eps, Float64(fma(eps, Float64(Float64(1.0 - x) + fma(x, eps, x)), 0.0) - x), -1.0) / eps))), 1.0); else tmp = Float64(0.5 * Float64(x * Float64(x * Float64(eps * eps)))); end return tmp end
code[x_, eps_] := If[LessEqual[x, 0.0078], N[(0.5 * N[(x * N[(N[(eps + 1.0), $MachinePrecision] * N[(-1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] + N[(N[(eps * N[(N[(eps * N[(N[(1.0 - x), $MachinePrecision] + N[(x * eps + x), $MachinePrecision]), $MachinePrecision] + 0.0), $MachinePrecision] - x), $MachinePrecision] + -1.0), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $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 0.0078:\\
\;\;\;\;\mathsf{fma}\left(0.5, x \cdot \mathsf{fma}\left(\varepsilon + 1, -1 + \frac{1}{\varepsilon}, \frac{\mathsf{fma}\left(\varepsilon, \mathsf{fma}\left(\varepsilon, \left(1 - x\right) + \mathsf{fma}\left(x, \varepsilon, x\right), 0\right) - x, -1\right)}{\varepsilon}\right), 1\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 < 0.0077999999999999996Initial program 61.4%
Taylor expanded in x around 0
Simplified91.8%
Taylor expanded in eps around 0
Simplified93.9%
if 0.0077999999999999996 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified46.8%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6447.3
Simplified47.3%
Taylor expanded in x around inf
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6464.4
Simplified64.4%
Final simplification86.0%
(FPCore (x eps) :precision binary64 (let* ((t_0 (* x (* x (* eps eps))))) (if (<= x 0.0078) (fma 0.5 t_0 1.0) (* 0.5 t_0))))
double code(double x, double eps) {
double t_0 = x * (x * (eps * eps));
double tmp;
if (x <= 0.0078) {
tmp = fma(0.5, t_0, 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 <= 0.0078) tmp = fma(0.5, t_0, 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, 0.0078], N[(0.5 * t$95$0 + 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 0.0078:\\
\;\;\;\;\mathsf{fma}\left(0.5, t\_0, 1\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot t\_0\\
\end{array}
\end{array}
if x < 0.0077999999999999996Initial program 61.4%
Taylor expanded in x around 0
Simplified91.8%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6492.9
Simplified92.9%
if 0.0077999999999999996 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified46.8%
Taylor expanded in eps around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6447.3
Simplified47.3%
Taylor expanded in x around inf
*-lowering-*.f64N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6464.4
Simplified64.4%
(FPCore (x eps) :precision binary64 (if (<= x -430.0) (fma -0.16666666666666666 (* x (* x x)) 1.0) (fma (* x x) (fma x 0.3333333333333333 -0.5) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -430.0) {
tmp = fma(-0.16666666666666666, (x * (x * x)), 1.0);
} else {
tmp = fma((x * x), fma(x, 0.3333333333333333, -0.5), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -430.0) tmp = fma(-0.16666666666666666, Float64(x * Float64(x * x)), 1.0); else tmp = fma(Float64(x * x), fma(x, 0.3333333333333333, -0.5), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -430.0], N[(-0.16666666666666666 * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(x * 0.3333333333333333 + -0.5), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -430:\\
\;\;\;\;\mathsf{fma}\left(-0.16666666666666666, x \cdot \left(x \cdot x\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, 0.3333333333333333, -0.5\right), 1\right)\\
\end{array}
\end{array}
if x < -430Initial program 100.0%
Taylor expanded in eps around inf
*-lowering-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f64N/A
Simplified100.0%
Taylor expanded in x around 0
Simplified16.7%
Taylor expanded in x around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
cube-multN/A
unpow2N/A
associate-*r*N/A
*-lowering-*.f64N/A
Simplified22.4%
Taylor expanded in eps around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6471.2
Simplified71.2%
if -430 < x Initial program 67.0%
Taylor expanded in eps around 0
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
distribute-rgt1-inN/A
distribute-rgt-out--N/A
*-commutativeN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f64N/A
+-lowering-+.f64N/A
Simplified68.6%
Taylor expanded in x around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
accelerator-lowering-fma.f6465.4
Simplified65.4%
(FPCore (x eps) :precision binary64 (fma -0.16666666666666666 (* x (* x x)) 1.0))
double code(double x, double eps) {
return fma(-0.16666666666666666, (x * (x * x)), 1.0);
}
function code(x, eps) return fma(-0.16666666666666666, Float64(x * Float64(x * x)), 1.0) end
code[x_, eps_] := N[(-0.16666666666666666 * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.16666666666666666, x \cdot \left(x \cdot x\right), 1\right)
\end{array}
Initial program 71.6%
Taylor expanded in eps around inf
*-lowering-*.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
+-lowering-+.f64N/A
Simplified99.2%
Taylor expanded in x around 0
Simplified45.8%
Taylor expanded in x around inf
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
cube-multN/A
unpow2N/A
associate-*r*N/A
*-lowering-*.f64N/A
Simplified46.1%
Taylor expanded in eps around 0
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6456.6
Simplified56.6%
(FPCore (x eps) :precision binary64 1.0)
double code(double x, double eps) {
return 1.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0
end function
public static double code(double x, double eps) {
return 1.0;
}
def code(x, eps): return 1.0
function code(x, eps) return 1.0 end
function tmp = code(x, eps) tmp = 1.0; end
code[x_, eps_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 71.6%
Taylor expanded in x around 0
Simplified47.6%
herbie shell --seed 2024198
(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))