
(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 (- -1.0 eps)))) (t_1 (/ (+ 1.0 eps) eps)))
(if (<=
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* t_0 (+ 1.0 (/ -1.0 eps))))
2.0)
(* 0.5 (/ (+ 2.0 (+ x x)) (exp x)))
(pow
(exp -1.0)
(- (log (* 0.5 (fma t_0 t_1 (* t_1 (exp (- (* eps x) x)))))))))))
double code(double x, double eps) {
double t_0 = exp((x * (-1.0 - eps)));
double t_1 = (1.0 + eps) / eps;
double tmp;
if ((((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (t_0 * (1.0 + (-1.0 / eps)))) <= 2.0) {
tmp = 0.5 * ((2.0 + (x + x)) / exp(x));
} else {
tmp = pow(exp(-1.0), -log((0.5 * fma(t_0, t_1, (t_1 * exp(((eps * x) - x)))))));
}
return tmp;
}
function code(x, eps) t_0 = exp(Float64(x * Float64(-1.0 - eps))) t_1 = Float64(Float64(1.0 + eps) / eps) tmp = 0.0 if (Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) + Float64(t_0 * Float64(1.0 + Float64(-1.0 / eps)))) <= 2.0) tmp = Float64(0.5 * Float64(Float64(2.0 + Float64(x + x)) / exp(x))); else tmp = exp(-1.0) ^ Float64(-log(Float64(0.5 * fma(t_0, t_1, Float64(t_1 * exp(Float64(Float64(eps * x) - x))))))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 + eps), $MachinePrecision] / eps), $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[(t$95$0 * N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], N[(0.5 * N[(N[(2.0 + N[(x + x), $MachinePrecision]), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[Exp[-1.0], $MachinePrecision], (-N[Log[N[(0.5 * N[(t$95$0 * t$95$1 + N[(t$95$1 * N[Exp[N[(N[(eps * x), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(-1 - \varepsilon\right)}\\
t_1 := \frac{1 + \varepsilon}{\varepsilon}\\
\mathbf{if}\;\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + t\_0 \cdot \left(1 + \frac{-1}{\varepsilon}\right) \leq 2:\\
\;\;\;\;0.5 \cdot \frac{2 + \left(x + x\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;{\left(e^{-1}\right)}^{\left(-\log \left(0.5 \cdot \mathsf{fma}\left(t\_0, t\_1, t\_1 \cdot e^{\varepsilon \cdot x - x}\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))))) < 2Initial program 55.7%
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
Simplified100.0%
*-commutativeN/A
exp-negN/A
un-div-invN/A
/-lowering-/.f64N/A
+-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0
Applied egg-rr100.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 99.9%
Applied egg-rr99.9%
Applied egg-rr99.9%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (* x (- -1.0 eps))))
(t_1 (+ 1.0 (/ -1.0 eps)))
(t_2 (* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))))
(if (<= (+ t_2 (* t_0 t_1)) 0.0)
(* 0.5 (/ (+ 2.0 (+ x x)) (exp x)))
(exp (- (log (/ 2.0 (fma t_0 t_1 t_2))))))))
double code(double x, double eps) {
double t_0 = exp((x * (-1.0 - eps)));
double t_1 = 1.0 + (-1.0 / eps);
double t_2 = (1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)));
double tmp;
if ((t_2 + (t_0 * t_1)) <= 0.0) {
tmp = 0.5 * ((2.0 + (x + x)) / exp(x));
} else {
tmp = exp(-log((2.0 / fma(t_0, t_1, t_2))));
}
return tmp;
}
function code(x, eps) t_0 = exp(Float64(x * Float64(-1.0 - eps))) t_1 = Float64(1.0 + Float64(-1.0 / eps)) t_2 = Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(x * Float64(eps + -1.0)))) tmp = 0.0 if (Float64(t_2 + Float64(t_0 * t_1)) <= 0.0) tmp = Float64(0.5 * Float64(Float64(2.0 + Float64(x + x)) / exp(x))); else tmp = exp(Float64(-log(Float64(2.0 / fma(t_0, t_1, t_2))))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Exp[N[(x * N[(-1.0 - eps), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(x * N[(eps + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$2 + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision], 0.0], N[(0.5 * N[(N[(2.0 + N[(x + x), $MachinePrecision]), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[(-N[Log[N[(2.0 / N[(t$95$0 * t$95$1 + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{x \cdot \left(-1 - \varepsilon\right)}\\
t_1 := 1 + \frac{-1}{\varepsilon}\\
t_2 := \left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)}\\
\mathbf{if}\;t\_2 + t\_0 \cdot t\_1 \leq 0:\\
\;\;\;\;0.5 \cdot \frac{2 + \left(x + x\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;e^{-\log \left(\frac{2}{\mathsf{fma}\left(t\_0, t\_1, t\_2\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 42.8%
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
Simplified100.0%
*-commutativeN/A
exp-negN/A
un-div-invN/A
/-lowering-/.f64N/A
+-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.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 99.9%
Applied egg-rr99.9%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0
(+
(* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
(* (exp (* x (- -1.0 eps))) (+ 1.0 (/ -1.0 eps))))))
(if (<= t_0 0.0) (* 0.5 (/ (+ 2.0 (+ x x)) (exp x))) (/ t_0 2.0))))
double code(double x, double eps) {
double t_0 = ((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)));
double tmp;
if (t_0 <= 0.0) {
tmp = 0.5 * ((2.0 + (x + x)) / exp(x));
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 + (1.0d0 / eps)) * exp((x * (eps + (-1.0d0))))) + (exp((x * ((-1.0d0) - eps))) * (1.0d0 + ((-1.0d0) / eps)))
if (t_0 <= 0.0d0) then
tmp = 0.5d0 * ((2.0d0 + (x + x)) / exp(x))
else
tmp = t_0 / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = ((1.0 + (1.0 / eps)) * Math.exp((x * (eps + -1.0)))) + (Math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps)));
double tmp;
if (t_0 <= 0.0) {
tmp = 0.5 * ((2.0 + (x + x)) / Math.exp(x));
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = ((1.0 + (1.0 / eps)) * math.exp((x * (eps + -1.0)))) + (math.exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps))) tmp = 0 if t_0 <= 0.0: tmp = 0.5 * ((2.0 + (x + x)) / math.exp(x)) else: tmp = t_0 / 2.0 return tmp
function code(x, eps) t_0 = 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)))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(0.5 * Float64(Float64(2.0 + Float64(x + x)) / exp(x))); else tmp = Float64(t_0 / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = ((1.0 + (1.0 / eps)) * exp((x * (eps + -1.0)))) + (exp((x * (-1.0 - eps))) * (1.0 + (-1.0 / eps))); tmp = 0.0; if (t_0 <= 0.0) tmp = 0.5 * ((2.0 + (x + x)) / exp(x)); else tmp = t_0 / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(1.0 + N[(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]}, If[LessEqual[t$95$0, 0.0], N[(0.5 * N[(N[(2.0 + N[(x + x), $MachinePrecision]), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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)\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;0.5 \cdot \frac{2 + \left(x + x\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 0.0Initial program 42.8%
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
Simplified100.0%
*-commutativeN/A
exp-negN/A
un-div-invN/A
/-lowering-/.f64N/A
+-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.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 99.9%
Final simplification99.9%
(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))))
2.0)
(* 0.5 (/ (+ 2.0 (+ x x)) (exp x)))
(fma x (* x (fma 0.5 (* eps eps) -0.5)) 1.0)))
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)))) <= 2.0) {
tmp = 0.5 * ((2.0 + (x + x)) / exp(x));
} else {
tmp = fma(x, (x * fma(0.5, (eps * eps), -0.5)), 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(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 2.0) tmp = Float64(0.5 * Float64(Float64(2.0 + Float64(x + x)) / exp(x))); else tmp = fma(x, Float64(x * fma(0.5, Float64(eps * eps), -0.5)), 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[(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], 2.0], N[(0.5 * N[(N[(2.0 + N[(x + x), $MachinePrecision]), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(0.5 * N[(eps * eps), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $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 2:\\
\;\;\;\;0.5 \cdot \frac{2 + \left(x + x\right)}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(0.5, \varepsilon \cdot \varepsilon, -0.5\right), 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.7%
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
Simplified100.0%
*-commutativeN/A
exp-negN/A
un-div-invN/A
/-lowering-/.f64N/A
+-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
exp-lowering-exp.f64100.0
Applied egg-rr100.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 99.9%
Taylor expanded in x around 0
Simplified88.8%
Taylor expanded in eps around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
sub-negN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6488.8
Simplified88.8%
Final simplification94.5%
(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))))
2.0)
(* (exp (- x)) (+ 1.0 x))
(fma x (* x (fma 0.5 (* eps eps) -0.5)) 1.0)))
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)))) <= 2.0) {
tmp = exp(-x) * (1.0 + x);
} else {
tmp = fma(x, (x * fma(0.5, (eps * eps), -0.5)), 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(eps + -1.0)))) + Float64(exp(Float64(x * Float64(-1.0 - eps))) * Float64(1.0 + Float64(-1.0 / eps)))) <= 2.0) tmp = Float64(exp(Float64(-x)) * Float64(1.0 + x)); else tmp = fma(x, Float64(x * fma(0.5, Float64(eps * eps), -0.5)), 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[(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], 2.0], N[(N[Exp[(-x)], $MachinePrecision] * N[(1.0 + x), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(0.5 * N[(eps * eps), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $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 2:\\
\;\;\;\;e^{-x} \cdot \left(1 + x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(0.5, \varepsilon \cdot \varepsilon, -0.5\right), 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.7%
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
Simplified100.0%
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
+-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
exp-lowering-exp.f64N/A
neg-lowering-neg.f64100.0
Applied egg-rr100.0%
Taylor expanded in x around inf
distribute-rgt-inN/A
neg-mul-1N/A
neg-mul-1N/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
rgt-mult-inverseN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
exp-lowering-exp.f64N/A
neg-mul-1N/A
neg-lowering-neg.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0
Simplified100.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 99.9%
Taylor expanded in x around 0
Simplified88.8%
Taylor expanded in eps around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
sub-negN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6488.8
Simplified88.8%
Final simplification94.5%
(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))))
1e+300)
1.0
(* (* eps eps) (* 0.5 (* x x)))))
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)))) <= 1e+300) {
tmp = 1.0;
} else {
tmp = (eps * eps) * (0.5 * (x * x));
}
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)))) <= 1d+300) then
tmp = 1.0d0
else
tmp = (eps * eps) * (0.5d0 * (x * x))
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)))) <= 1e+300) {
tmp = 1.0;
} else {
tmp = (eps * eps) * (0.5 * (x * x));
}
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)))) <= 1e+300: tmp = 1.0 else: tmp = (eps * eps) * (0.5 * (x * x)) 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)))) <= 1e+300) tmp = 1.0; else tmp = Float64(Float64(eps * eps) * Float64(0.5 * Float64(x * x))); 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)))) <= 1e+300) tmp = 1.0; else tmp = (eps * eps) * (0.5 * (x * x)); 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], 1e+300], 1.0, N[(N[(eps * eps), $MachinePrecision] * N[(0.5 * N[(x * x), $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 10^{+300}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(\varepsilon \cdot \varepsilon\right) \cdot \left(0.5 \cdot \left(x \cdot x\right)\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 1.0000000000000001e300Initial program 56.6%
Taylor expanded in x around 0
Simplified67.9%
if 1.0000000000000001e300 < (-.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
Simplified89.3%
Taylor expanded in eps around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
sub-negN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6489.3
Simplified89.3%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6480.8
Simplified80.8%
Taylor expanded in x around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
associate-*r*N/A
unpow2N/A
cube-multN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lft-mult-inverseN/A
metadata-evalN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6480.4
Simplified80.4%
Final simplification74.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))))
1e+300)
1.0
(* eps (* eps (* 0.5 (* x x))))))
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)))) <= 1e+300) {
tmp = 1.0;
} else {
tmp = eps * (eps * (0.5 * (x * x)));
}
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)))) <= 1d+300) then
tmp = 1.0d0
else
tmp = eps * (eps * (0.5d0 * (x * x)))
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)))) <= 1e+300) {
tmp = 1.0;
} else {
tmp = eps * (eps * (0.5 * (x * x)));
}
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)))) <= 1e+300: tmp = 1.0 else: tmp = eps * (eps * (0.5 * (x * x))) 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)))) <= 1e+300) tmp = 1.0; else tmp = Float64(eps * Float64(eps * Float64(0.5 * Float64(x * x)))); 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)))) <= 1e+300) tmp = 1.0; else tmp = eps * (eps * (0.5 * (x * x))); 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], 1e+300], 1.0, N[(eps * N[(eps * N[(0.5 * N[(x * x), $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 10^{+300}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\varepsilon \cdot \left(0.5 \cdot \left(x \cdot x\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))))) < 1.0000000000000001e300Initial program 56.6%
Taylor expanded in x around 0
Simplified67.9%
if 1.0000000000000001e300 < (-.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
Simplified89.3%
Taylor expanded in eps around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
sub-negN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6489.3
Simplified89.3%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6472.3
Simplified72.3%
Final simplification70.1%
(FPCore (x eps) :precision binary64 (if (<= x 550.0) 1.0 (if (<= x 1.6e+159) 0.0 (fma (* x x) (fma x 0.3333333333333333 -0.5) 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= 550.0) {
tmp = 1.0;
} else if (x <= 1.6e+159) {
tmp = 0.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 <= 550.0) tmp = 1.0; elseif (x <= 1.6e+159) tmp = 0.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, 550.0], 1.0, If[LessEqual[x, 1.6e+159], 0.0, 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 550:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+159}:\\
\;\;\;\;0\\
\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 < 550Initial program 66.3%
Taylor expanded in x around 0
Simplified53.5%
if 550 < x < 1.59999999999999992e159Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in eps around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
/-lowering-/.f6460.2
Simplified60.2%
div060.2
Applied egg-rr60.2%
if 1.59999999999999992e159 < x Initial program 100.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
Simplified37.4%
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.f6464.2
Simplified64.2%
(FPCore (x eps) :precision binary64 (if (<= x 9.2e-6) (fma x (* x (fma 0.5 (* eps eps) -0.5)) 1.0) (* (* eps eps) (* 0.5 (* x x)))))
double code(double x, double eps) {
double tmp;
if (x <= 9.2e-6) {
tmp = fma(x, (x * fma(0.5, (eps * eps), -0.5)), 1.0);
} else {
tmp = (eps * eps) * (0.5 * (x * x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 9.2e-6) tmp = fma(x, Float64(x * fma(0.5, Float64(eps * eps), -0.5)), 1.0); else tmp = Float64(Float64(eps * eps) * Float64(0.5 * Float64(x * x))); end return tmp end
code[x_, eps_] := If[LessEqual[x, 9.2e-6], N[(x * N[(x * N[(0.5 * N[(eps * eps), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(eps * eps), $MachinePrecision] * N[(0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.2 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(0.5, \varepsilon \cdot \varepsilon, -0.5\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\varepsilon \cdot \varepsilon\right) \cdot \left(0.5 \cdot \left(x \cdot x\right)\right)\\
\end{array}
\end{array}
if x < 9.2e-6Initial program 65.9%
Taylor expanded in x around 0
Simplified88.3%
Taylor expanded in eps around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
sub-negN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6488.3
Simplified88.3%
if 9.2e-6 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified48.4%
Taylor expanded in eps around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
sub-negN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6447.9
Simplified47.9%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6448.3
Simplified48.3%
Taylor expanded in x around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
associate-*r*N/A
unpow2N/A
cube-multN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lft-mult-inverseN/A
metadata-evalN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6463.4
Simplified63.4%
(FPCore (x eps) :precision binary64 (if (<= x 9.2e-6) (fma x (* eps (* eps (* x 0.5))) 1.0) (* (* eps eps) (* 0.5 (* x x)))))
double code(double x, double eps) {
double tmp;
if (x <= 9.2e-6) {
tmp = fma(x, (eps * (eps * (x * 0.5))), 1.0);
} else {
tmp = (eps * eps) * (0.5 * (x * x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 9.2e-6) tmp = fma(x, Float64(eps * Float64(eps * Float64(x * 0.5))), 1.0); else tmp = Float64(Float64(eps * eps) * Float64(0.5 * Float64(x * x))); end return tmp end
code[x_, eps_] := If[LessEqual[x, 9.2e-6], N[(x * N[(eps * N[(eps * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(eps * eps), $MachinePrecision] * N[(0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.2 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(x, \varepsilon \cdot \left(\varepsilon \cdot \left(x \cdot 0.5\right)\right), 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\varepsilon \cdot \varepsilon\right) \cdot \left(0.5 \cdot \left(x \cdot x\right)\right)\\
\end{array}
\end{array}
if x < 9.2e-6Initial program 65.9%
Taylor expanded in x around 0
Simplified88.3%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6487.7
Simplified87.7%
if 9.2e-6 < x Initial program 100.0%
Taylor expanded in x around 0
Simplified48.4%
Taylor expanded in eps around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
metadata-evalN/A
sub-negN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
unpow2N/A
*-lowering-*.f6447.9
Simplified47.9%
Taylor expanded in eps around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6448.3
Simplified48.3%
Taylor expanded in x around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
associate-*r*N/A
unpow2N/A
cube-multN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
associate-*r*N/A
associate-*l*N/A
lft-mult-inverseN/A
metadata-evalN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6463.4
Simplified63.4%
Final simplification79.4%
(FPCore (x eps) :precision binary64 (if (<= x 550.0) 1.0 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 550.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 <= 550.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 <= 550.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 550.0: tmp = 1.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 550.0) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 550.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 550.0], 1.0, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 550:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 550Initial program 66.3%
Taylor expanded in x around 0
Simplified53.5%
if 550 < x Initial program 100.0%
Applied egg-rr100.0%
Taylor expanded in eps around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
/-lowering-/.f6448.5
Simplified48.5%
div048.5
Applied egg-rr48.5%
(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 77.6%
Applied egg-rr77.6%
Taylor expanded in eps around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
/-lowering-/.f6417.9
Simplified17.9%
div017.9
Applied egg-rr17.9%
herbie shell --seed 2024204
(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))