
(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 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<=
(-
(* (exp (* (- eps 1.0) x)) t_0)
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
2.0)
(* 0.5 (* (+ (- (+ x 1.0) -1.0) x) (exp (- x))))
(/ (- (* (exp (fma eps x (- x))) t_0) (- (exp (- (fma x eps x))))) 2.0))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (((exp(((eps - 1.0) * x)) * t_0) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 2.0) {
tmp = 0.5 * ((((x + 1.0) - -1.0) + x) * exp(-x));
} else {
tmp = ((exp(fma(eps, x, -x)) * t_0) - -exp(-fma(x, eps, x))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * t_0) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 2.0) tmp = Float64(0.5 * Float64(Float64(Float64(Float64(x + 1.0) - -1.0) + x) * exp(Float64(-x)))); else tmp = Float64(Float64(Float64(exp(fma(eps, x, Float64(-x))) * t_0) - Float64(-exp(Float64(-fma(x, eps, x))))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], N[(0.5 * N[(N[(N[(N[(x + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Exp[N[(eps * x + (-x)), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;e^{\left(\varepsilon - 1\right) \cdot x} \cdot t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 2:\\
\;\;\;\;0.5 \cdot \left(\left(\left(\left(x + 1\right) - -1\right) + x\right) \cdot e^{-x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\mathsf{fma}\left(\varepsilon, x, -x\right)} \cdot t\_0 - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)}{2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 2Initial program 47.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6441.8
Applied rewrites41.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
if 2 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in eps around 0
sub-negN/A
neg-mul-1N/A
lower-fma.f64N/A
neg-mul-1N/A
lower-neg.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<=
(-
(* (exp (* (- eps 1.0) x)) t_0)
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
2.0)
(* 0.5 (* (+ (- (+ x 1.0) -1.0) x) (exp (- x))))
(/ (- (* (exp (* x eps)) t_0) (- (exp (- (fma x eps x))))) 2.0))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (((exp(((eps - 1.0) * x)) * t_0) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 2.0) {
tmp = 0.5 * ((((x + 1.0) - -1.0) + x) * exp(-x));
} else {
tmp = ((exp((x * eps)) * t_0) - -exp(-fma(x, eps, x))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * t_0) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 2.0) tmp = Float64(0.5 * Float64(Float64(Float64(Float64(x + 1.0) - -1.0) + x) * exp(Float64(-x)))); else tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * t_0) - Float64(-exp(Float64(-fma(x, eps, x))))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], N[(0.5 * N[(N[(N[(N[(x + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;e^{\left(\varepsilon - 1\right) \cdot x} \cdot t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 2:\\
\;\;\;\;0.5 \cdot \left(\left(\left(\left(x + 1\right) - -1\right) + x\right) \cdot e^{-x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot t\_0 - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)}{2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 2Initial program 47.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6441.8
Applied rewrites41.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
if 2 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in eps around inf
lower-*.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (/ 1.0 eps) 1.0)) (t_1 (+ (/ 1.0 eps) 1.0)))
(if (<=
(- (* (exp (* (- eps 1.0) x)) t_1) (* (exp (* (- -1.0 eps) x)) t_0))
4.0)
(* 0.5 (* (+ (- (+ x 1.0) -1.0) x) (exp (- x))))
(/
(-
(* (fma (fma (* (pow (- eps 1.0) 2.0) x) 0.5 (- eps 1.0)) x 1.0) t_1)
t_0)
2.0))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) - 1.0;
double t_1 = (1.0 / eps) + 1.0;
double tmp;
if (((exp(((eps - 1.0) * x)) * t_1) - (exp(((-1.0 - eps) * x)) * t_0)) <= 4.0) {
tmp = 0.5 * ((((x + 1.0) - -1.0) + x) * exp(-x));
} else {
tmp = ((fma(fma((pow((eps - 1.0), 2.0) * x), 0.5, (eps - 1.0)), x, 1.0) * t_1) - t_0) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) - 1.0) t_1 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * t_1) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * t_0)) <= 4.0) tmp = Float64(0.5 * Float64(Float64(Float64(Float64(x + 1.0) - -1.0) + x) * exp(Float64(-x)))); else tmp = Float64(Float64(Float64(fma(fma(Float64((Float64(eps - 1.0) ^ 2.0) * x), 0.5, Float64(eps - 1.0)), x, 1.0) * t_1) - t_0) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 4.0], N[(0.5 * N[(N[(N[(N[(x + 1.0), $MachinePrecision] - -1.0), $MachinePrecision] + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[Power[N[(eps - 1.0), $MachinePrecision], 2.0], $MachinePrecision] * x), $MachinePrecision] * 0.5 + N[(eps - 1.0), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision] - t$95$0), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} - 1\\
t_1 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;e^{\left(\varepsilon - 1\right) \cdot x} \cdot t\_1 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot t\_0 \leq 4:\\
\;\;\;\;0.5 \cdot \left(\left(\left(\left(x + 1\right) - -1\right) + x\right) \cdot e^{-x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left({\left(\varepsilon - 1\right)}^{2} \cdot x, 0.5, \varepsilon - 1\right), x, 1\right) \cdot t\_1 - t\_0}{2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 4Initial program 47.7%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6442.6
Applied rewrites42.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
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
lower--.f64N/A
lower-/.f6444.7
Applied rewrites44.7%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower--.f6479.2
Applied rewrites79.2%
Final simplification90.0%
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (exp (* (- eps 1.0) x)) (+ (/ 1.0 eps) 1.0))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
5.0)
(/ (+ x 1.0) (fma (fma 0.5 x 1.0) x 1.0))
(* (fma (fma x 0.5 -1.0) x 1.0) 1.0)))
double code(double x, double eps) {
double tmp;
if (((exp(((eps - 1.0) * x)) * ((1.0 / eps) + 1.0)) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 5.0) {
tmp = (x + 1.0) / fma(fma(0.5, x, 1.0), x, 1.0);
} else {
tmp = fma(fma(x, 0.5, -1.0), x, 1.0) * 1.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * Float64(Float64(1.0 / eps) + 1.0)) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 5.0) tmp = Float64(Float64(x + 1.0) / fma(fma(0.5, x, 1.0), x, 1.0)); else tmp = Float64(fma(fma(x, 0.5, -1.0), x, 1.0) * 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5.0], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.5 * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 0.5 + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{\left(\varepsilon - 1\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} + 1\right) - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 5:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), x, 1\right) \cdot 1\\
\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))))) < 5Initial program 48.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.5%
Taylor expanded in x around 0
Applied rewrites85.9%
Applied rewrites85.9%
if 5 < (-.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 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites1.5%
Applied rewrites1.5%
Taylor expanded in x around 0
Applied rewrites38.6%
Taylor expanded in x around 0
Applied rewrites37.3%
Final simplification63.9%
(FPCore (x eps) :precision binary64 (if (<= x 4.8e-52) (/ (- 1.0 (/ -1.0 (exp (fma eps x x)))) 2.0) (/ (- (* (exp (* x eps)) (+ (/ 1.0 eps) 1.0)) (/ 1.0 eps)) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 4.8e-52) {
tmp = (1.0 - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
} else {
tmp = ((exp((x * eps)) * ((1.0 / eps) + 1.0)) - (1.0 / eps)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 4.8e-52) tmp = Float64(Float64(1.0 - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); else tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * Float64(Float64(1.0 / eps) + 1.0)) - Float64(1.0 / eps)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 4.8e-52], N[(N[(1.0 - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.8 \cdot 10^{-52}:\\
\;\;\;\;\frac{1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot \left(\frac{1}{\varepsilon} + 1\right) - \frac{1}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < 4.8000000000000003e-52Initial program 60.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6456.0
Applied rewrites56.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6436.5
Applied rewrites36.5%
Taylor expanded in eps around inf
Applied rewrites80.1%
if 4.8000000000000003e-52 < x Initial program 98.7%
Taylor expanded in eps around 0
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6465.8
Applied rewrites65.8%
Taylor expanded in x around 0
Applied rewrites22.8%
Taylor expanded in eps around inf
lower-*.f6443.1
Applied rewrites43.1%
Final simplification69.0%
(FPCore (x eps)
:precision binary64
(if (<= eps 8.2e+69)
(* 1.0 (exp (- x)))
(if (<= eps 5e+259)
(/ (- (* (exp (* (- eps 1.0) x)) (+ (/ 1.0 eps) 1.0)) -1.0) 2.0)
(/ (- 1.0 (/ -1.0 (exp (fma eps x x)))) 2.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 8.2e+69) {
tmp = 1.0 * exp(-x);
} else if (eps <= 5e+259) {
tmp = ((exp(((eps - 1.0) * x)) * ((1.0 / eps) + 1.0)) - -1.0) / 2.0;
} else {
tmp = (1.0 - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 8.2e+69) tmp = Float64(1.0 * exp(Float64(-x))); elseif (eps <= 5e+259) tmp = Float64(Float64(Float64(exp(Float64(Float64(eps - 1.0) * x)) * Float64(Float64(1.0 / eps) + 1.0)) - -1.0) / 2.0); else tmp = Float64(Float64(1.0 - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 8.2e+69], N[(1.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5e+259], N[(N[(N[(N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(1.0 - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 8.2 \cdot 10^{+69}:\\
\;\;\;\;1 \cdot e^{-x}\\
\mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{+259}:\\
\;\;\;\;\frac{e^{\left(\varepsilon - 1\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} + 1\right) - -1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\end{array}
\end{array}
if eps < 8.1999999999999998e69Initial program 63.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.3%
Applied rewrites66.2%
Taylor expanded in x around 0
Applied rewrites77.6%
if 8.1999999999999998e69 < eps < 5.00000000000000033e259Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites56.8%
if 5.00000000000000033e259 < eps Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6468.8
Applied rewrites68.8%
Taylor expanded in eps around inf
Applied rewrites68.8%
Final simplification73.8%
(FPCore (x eps) :precision binary64 (if (<= x 4.8e-52) (/ (- 1.0 (/ -1.0 (exp (fma eps x x)))) 2.0) (/ (- (* 1.0 (exp (* (- eps 1.0) x))) (/ 1.0 eps)) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 4.8e-52) {
tmp = (1.0 - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
} else {
tmp = ((1.0 * exp(((eps - 1.0) * x))) - (1.0 / eps)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 4.8e-52) tmp = Float64(Float64(1.0 - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); else tmp = Float64(Float64(Float64(1.0 * exp(Float64(Float64(eps - 1.0) * x))) - Float64(1.0 / eps)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 4.8e-52], N[(N[(1.0 - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(1.0 * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.8 \cdot 10^{-52}:\\
\;\;\;\;\frac{1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot e^{\left(\varepsilon - 1\right) \cdot x} - \frac{1}{\varepsilon}}{2}\\
\end{array}
\end{array}
if x < 4.8000000000000003e-52Initial program 60.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6456.0
Applied rewrites56.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6436.5
Applied rewrites36.5%
Taylor expanded in eps around inf
Applied rewrites80.1%
if 4.8000000000000003e-52 < x Initial program 98.7%
Taylor expanded in eps around 0
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6465.8
Applied rewrites65.8%
Taylor expanded in x around 0
Applied rewrites22.8%
Taylor expanded in eps around inf
Applied rewrites22.8%
Final simplification62.9%
(FPCore (x eps)
:precision binary64
(if (<= x -2e-298)
(/ (- 1.0 (/ -1.0 (exp (fma eps x x)))) 2.0)
(if (<= x 1e+220)
(* (* (/ (+ x 1.0) (exp x)) 2.0) 0.5)
(/ (* 1.0 (fma x x -1.0)) (- x 1.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -2e-298) {
tmp = (1.0 - (-1.0 / exp(fma(eps, x, x)))) / 2.0;
} else if (x <= 1e+220) {
tmp = (((x + 1.0) / exp(x)) * 2.0) * 0.5;
} else {
tmp = (1.0 * fma(x, x, -1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -2e-298) tmp = Float64(Float64(1.0 - Float64(-1.0 / exp(fma(eps, x, x)))) / 2.0); elseif (x <= 1e+220) tmp = Float64(Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0) * 0.5); else tmp = Float64(Float64(1.0 * fma(x, x, -1.0)) / Float64(x - 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[x, -2e-298], N[(N[(1.0 - N[(-1.0 / N[Exp[N[(eps * x + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 1e+220], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(1.0 * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-298}:\\
\;\;\;\;\frac{1 - \frac{-1}{e^{\mathsf{fma}\left(\varepsilon, x, x\right)}}}{2}\\
\mathbf{elif}\;x \leq 10^{+220}:\\
\;\;\;\;\left(\frac{x + 1}{e^{x}} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\end{array}
\end{array}
if x < -1.99999999999999982e-298Initial program 62.2%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
+-commutativeN/A
lower-fma.f6459.4
Applied rewrites59.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6438.0
Applied rewrites38.0%
Taylor expanded in eps around inf
Applied rewrites78.0%
if -1.99999999999999982e-298 < x < 1e220Initial program 76.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites60.2%
if 1e220 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites36.0%
Applied rewrites36.0%
Taylor expanded in x around 0
Applied rewrites6.0%
Applied rewrites65.5%
Final simplification69.2%
(FPCore (x eps) :precision binary64 (if (<= x 1e+220) (* 1.0 (exp (- x))) (/ (* 1.0 (fma x x -1.0)) (- x 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= 1e+220) {
tmp = 1.0 * exp(-x);
} else {
tmp = (1.0 * fma(x, x, -1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 1e+220) tmp = Float64(1.0 * exp(Float64(-x))); else tmp = Float64(Float64(1.0 * fma(x, x, -1.0)) / Float64(x - 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[x, 1e+220], N[(1.0 * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+220}:\\
\;\;\;\;1 \cdot e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\end{array}
\end{array}
if x < 1e220Initial program 69.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites56.1%
Applied rewrites56.1%
Taylor expanded in x around 0
Applied rewrites73.9%
if 1e220 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites36.0%
Applied rewrites36.0%
Taylor expanded in x around 0
Applied rewrites6.0%
Applied rewrites65.5%
Final simplification73.2%
(FPCore (x eps)
:precision binary64
(if (<= x 1.6)
(* (fma (fma (fma -0.16666666666666666 x 0.5) x -1.0) x 1.0) 1.0)
(if (<= x 1.25e+271)
(/ (- (+ (/ 1.0 eps) 1.0) (- (/ 1.0 eps) 1.0)) 2.0)
(fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= 1.6) {
tmp = fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0;
} else if (x <= 1.25e+271) {
tmp = (((1.0 / eps) + 1.0) - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 1.6) tmp = Float64(fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0); elseif (x <= 1.25e+271) tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 1.6], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[x, 1.25e+271], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right) \cdot 1\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{+271}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < 1.6000000000000001Initial program 61.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites56.2%
Applied rewrites56.2%
Taylor expanded in x around 0
Applied rewrites78.6%
Taylor expanded in x around 0
Applied rewrites71.9%
if 1.6000000000000001 < x < 1.2500000000000001e271Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6420.7
Applied rewrites20.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6455.7
Applied rewrites55.7%
if 1.2500000000000001e271 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites21.3%
Taylor expanded in x around 0
Applied rewrites80.3%
Final simplification68.5%
(FPCore (x eps)
:precision binary64
(if (<= x 1.6)
(* (fma (fma (fma -0.16666666666666666 x 0.5) x -1.0) x 1.0) 1.0)
(if (<= x 1.25e+271)
(/ (- (+ (/ 1.0 eps) 1.0) (/ 1.0 eps)) 2.0)
(fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= 1.6) {
tmp = fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0;
} else if (x <= 1.25e+271) {
tmp = (((1.0 / eps) + 1.0) - (1.0 / eps)) / 2.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 1.6) tmp = Float64(fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0); elseif (x <= 1.25e+271) tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(1.0 / eps)) / 2.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 1.6], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[x, 1.25e+271], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right) \cdot 1\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{+271}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \frac{1}{\varepsilon}}{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < 1.6000000000000001Initial program 61.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites56.2%
Applied rewrites56.2%
Taylor expanded in x around 0
Applied rewrites78.6%
Taylor expanded in x around 0
Applied rewrites71.9%
if 1.6000000000000001 < x < 1.2500000000000001e271Initial program 100.0%
Taylor expanded in eps around 0
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6473.3
Applied rewrites73.3%
Taylor expanded in x around 0
Applied rewrites20.4%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6455.7
Applied rewrites55.7%
if 1.2500000000000001e271 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites21.3%
Taylor expanded in x around 0
Applied rewrites80.3%
Final simplification68.5%
(FPCore (x eps) :precision binary64 (if (<= x -0.9) (* (fma (fma (fma -0.16666666666666666 x 0.5) x -1.0) x 1.0) 1.0) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -0.9) {
tmp = fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -0.9) tmp = Float64(fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -0.9], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.9:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -0.900000000000000022Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.1%
Applied rewrites0.1%
Taylor expanded in x around 0
Applied rewrites97.8%
Taylor expanded in x around 0
Applied rewrites69.5%
if -0.900000000000000022 < x Initial program 65.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites65.9%
Taylor expanded in x around 0
Applied rewrites60.9%
Final simplification62.4%
(FPCore (x eps) :precision binary64 (if (<= x -0.9) (* (fma (fma x 0.5 -1.0) x 1.0) 1.0) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -0.9) {
tmp = fma(fma(x, 0.5, -1.0), x, 1.0) * 1.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -0.9) tmp = Float64(fma(fma(x, 0.5, -1.0), x, 1.0) * 1.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -0.9], N[(N[(N[(x * 0.5 + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.9:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), x, 1\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -0.900000000000000022Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.1%
Applied rewrites0.1%
Taylor expanded in x around 0
Applied rewrites97.8%
Taylor expanded in x around 0
Applied rewrites50.4%
if -0.900000000000000022 < x Initial program 65.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites65.9%
Taylor expanded in x around 0
Applied rewrites60.9%
Final simplification59.1%
(FPCore (x eps) :precision binary64 (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))
double code(double x, double eps) {
return fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
function code(x, eps) return fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0) end
code[x_, eps_] := N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)
\end{array}
Initial program 71.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites54.6%
Taylor expanded in x around 0
Applied rewrites50.5%
(FPCore (x eps) :precision binary64 1.0)
double code(double x, double eps) {
return 1.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = 1.0d0
end function
public static double code(double x, double eps) {
return 1.0;
}
def code(x, eps): return 1.0
function code(x, eps) return 1.0 end
function tmp = code(x, eps) tmp = 1.0; end
code[x_, eps_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 71.6%
Taylor expanded in x around 0
Applied rewrites42.1%
herbie shell --seed 2024249
(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))