
(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 13 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 (* (+ -1.0 eps) x)) t_0)
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
2.0)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(/ (- (* (exp (* x eps)) t_0) (- (exp (- (fma x eps x))))) 2.0))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (((exp(((-1.0 + eps) * x)) * t_0) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 2.0) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else {
tmp = ((exp((x * eps)) * t_0) - -exp(-fma(x, eps, x))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(-1.0 + eps) * 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(x + 1.0) / exp(x)) * 2.0)); else tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * t_0) - Float64(-exp(Float64(-fma(x, eps, x))))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(N[Exp[N[(N[(-1.0 + eps), $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[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;e^{\left(-1 + \varepsilon\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(\frac{x + 1}{e^{x}} \cdot 2\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 56.1%
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
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<=
(-
(* (exp (* (+ -1.0 eps) x)) t_0)
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
3.0)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(/ (- t_0 (- (exp (- (fma x eps x))))) 2.0))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (((exp(((-1.0 + eps) * x)) * t_0) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 3.0) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else {
tmp = (t_0 - -exp(-fma(x, eps, x))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(-1.0 + eps) * x)) * t_0) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 3.0) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); else tmp = Float64(Float64(t_0 - Float64(-exp(Float64(-fma(x, eps, x))))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[N[(N[(N[Exp[N[(N[(-1.0 + eps), $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], 3.0], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;e^{\left(-1 + \varepsilon\right) \cdot x} \cdot t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 3:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)}{2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 3Initial program 56.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
if 3 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6441.8
Applied rewrites41.8%
Final simplification70.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= eps 1.0)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(if (<= eps 3.4e+57)
(/ (- (* (exp (* (+ -1.0 eps) x)) t_0) (- (/ 1.0 eps) 1.0)) 2.0)
(/ (- t_0 (- (exp (- (fma x eps x))))) 2.0)))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (eps <= 1.0) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else if (eps <= 3.4e+57) {
tmp = ((exp(((-1.0 + eps) * x)) * t_0) - ((1.0 / eps) - 1.0)) / 2.0;
} else {
tmp = (t_0 - -exp(-fma(x, eps, x))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (eps <= 1.0) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); elseif (eps <= 3.4e+57) tmp = Float64(Float64(Float64(exp(Float64(Float64(-1.0 + eps) * x)) * t_0) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); else tmp = Float64(Float64(t_0 - Float64(-exp(Float64(-fma(x, eps, x))))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[eps, 1.0], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.4e+57], N[(N[(N[(N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;\varepsilon \leq 1:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{elif}\;\varepsilon \leq 3.4 \cdot 10^{+57}:\\
\;\;\;\;\frac{e^{\left(-1 + \varepsilon\right) \cdot x} \cdot t\_0 - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)}{2}\\
\end{array}
\end{array}
if eps < 1Initial program 68.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites64.4%
if 1 < eps < 3.39999999999999992e57Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6479.6
Applied rewrites79.6%
if 3.39999999999999992e57 < eps Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6454.5
Applied rewrites54.5%
Final simplification62.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= eps 205.0)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(if (<= eps 3.4e+57)
(/ (- (* (exp (* x eps)) t_0) -1.0) 2.0)
(/ (- t_0 (- (exp (- (fma x eps x))))) 2.0)))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double tmp;
if (eps <= 205.0) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else if (eps <= 3.4e+57) {
tmp = ((exp((x * eps)) * t_0) - -1.0) / 2.0;
} else {
tmp = (t_0 - -exp(-fma(x, eps, x))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (eps <= 205.0) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); elseif (eps <= 3.4e+57) tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * t_0) - -1.0) / 2.0); else tmp = Float64(Float64(t_0 - Float64(-exp(Float64(-fma(x, eps, x))))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[eps, 205.0], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 3.4e+57], N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - -1.0), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(t$95$0 - (-N[Exp[(-N[(x * eps + x), $MachinePrecision])], $MachinePrecision])), $MachinePrecision] / 2.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;\varepsilon \leq 205:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{elif}\;\varepsilon \leq 3.4 \cdot 10^{+57}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot t\_0 - -1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - \left(-e^{-\mathsf{fma}\left(x, \varepsilon, x\right)}\right)}{2}\\
\end{array}
\end{array}
if eps < 205Initial program 68.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites64.6%
if 205 < eps < 3.39999999999999992e57Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites78.1%
if 3.39999999999999992e57 < eps Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6454.5
Applied rewrites54.5%
Final simplification62.8%
(FPCore (x eps)
:precision binary64
(if (<= x -710.0)
(/ (- (/ (exp (- x)) eps) (fma (- eps -1.0) x -1.0)) 2.0)
(if (<= x 4.8e+106)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(if (<= x 3.8e+281)
(fma (* 0.3333333333333333 x) (* x x) 1.0)
(/ (+ x 1.0) (* (fma 0.16666666666666666 x 0.5) (* x x)))))))
double code(double x, double eps) {
double tmp;
if (x <= -710.0) {
tmp = ((exp(-x) / eps) - fma((eps - -1.0), x, -1.0)) / 2.0;
} else if (x <= 4.8e+106) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else if (x <= 3.8e+281) {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
} else {
tmp = (x + 1.0) / (fma(0.16666666666666666, x, 0.5) * (x * x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -710.0) tmp = Float64(Float64(Float64(exp(Float64(-x)) / eps) - fma(Float64(eps - -1.0), x, -1.0)) / 2.0); elseif (x <= 4.8e+106) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); elseif (x <= 3.8e+281) tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); else tmp = Float64(Float64(x + 1.0) / Float64(fma(0.16666666666666666, x, 0.5) * Float64(x * x))); end return tmp end
code[x_, eps_] := If[LessEqual[x, -710.0], N[(N[(N[(N[Exp[(-x)], $MachinePrecision] / eps), $MachinePrecision] - N[(N[(eps - -1.0), $MachinePrecision] * x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 4.8e+106], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.8e+281], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -710:\\
\;\;\;\;\frac{\frac{e^{-x}}{\varepsilon} - \mathsf{fma}\left(\varepsilon - -1, x, -1\right)}{2}\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{+106}:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+281}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if x < -710Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites51.0%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6438.1
Applied rewrites38.1%
if -710 < x < 4.8000000000000001e106Initial program 65.5%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites65.9%
if 4.8000000000000001e106 < x < 3.80000000000000012e281Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites39.1%
Taylor expanded in x around 0
Applied rewrites62.5%
Taylor expanded in x around inf
Applied rewrites62.5%
if 3.80000000000000012e281 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.1%
Taylor expanded in x around 0
Applied rewrites78.1%
Taylor expanded in x around inf
Applied rewrites78.1%
Applied rewrites78.1%
Final simplification61.2%
(FPCore (x eps)
:precision binary64
(if (<= eps 1.0)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(if (<= eps 9e+224)
(fma (* 0.3333333333333333 x) (* x x) 1.0)
(if (<= eps 3.5e+273)
(/ (- (+ (/ 1.0 eps) 1.0) (fma (- eps -1.0) x -1.0)) 2.0)
(/ (+ x 1.0) (* (fma 0.16666666666666666 x 0.5) (* x x)))))))
double code(double x, double eps) {
double tmp;
if (eps <= 1.0) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else if (eps <= 9e+224) {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
} else if (eps <= 3.5e+273) {
tmp = (((1.0 / eps) + 1.0) - fma((eps - -1.0), x, -1.0)) / 2.0;
} else {
tmp = (x + 1.0) / (fma(0.16666666666666666, x, 0.5) * (x * x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 1.0) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); elseif (eps <= 9e+224) tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); elseif (eps <= 3.5e+273) tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - fma(Float64(eps - -1.0), x, -1.0)) / 2.0); else tmp = Float64(Float64(x + 1.0) / Float64(fma(0.16666666666666666, x, 0.5) * Float64(x * x))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 1.0], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 9e+224], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[eps, 3.5e+273], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(eps - -1.0), $MachinePrecision] * x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{elif}\;\varepsilon \leq 9 \cdot 10^{+224}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\mathbf{elif}\;\varepsilon \leq 3.5 \cdot 10^{+273}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \mathsf{fma}\left(\varepsilon - -1, x, -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if eps < 1Initial program 68.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites64.4%
if 1 < eps < 8.9999999999999995e224Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites23.2%
Taylor expanded in x around 0
Applied rewrites41.3%
Taylor expanded in x around inf
Applied rewrites41.3%
if 8.9999999999999995e224 < eps < 3.50000000000000011e273Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites66.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6450.0
Applied rewrites50.0%
if 3.50000000000000011e273 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites5.0%
Taylor expanded in x around 0
Applied rewrites5.0%
Taylor expanded in x around inf
Applied rewrites44.2%
Applied rewrites44.2%
Final simplification57.7%
(FPCore (x eps)
:precision binary64
(if (<= eps 1.0)
(* (+ x 1.0) (exp (- x)))
(if (<= eps 9e+224)
(fma (* 0.3333333333333333 x) (* x x) 1.0)
(if (<= eps 3.5e+273)
(/ (- (+ (/ 1.0 eps) 1.0) (fma (- eps -1.0) x -1.0)) 2.0)
(/ (+ x 1.0) (* (fma 0.16666666666666666 x 0.5) (* x x)))))))
double code(double x, double eps) {
double tmp;
if (eps <= 1.0) {
tmp = (x + 1.0) * exp(-x);
} else if (eps <= 9e+224) {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
} else if (eps <= 3.5e+273) {
tmp = (((1.0 / eps) + 1.0) - fma((eps - -1.0), x, -1.0)) / 2.0;
} else {
tmp = (x + 1.0) / (fma(0.16666666666666666, x, 0.5) * (x * x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 1.0) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); elseif (eps <= 9e+224) tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); elseif (eps <= 3.5e+273) tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - fma(Float64(eps - -1.0), x, -1.0)) / 2.0); else tmp = Float64(Float64(x + 1.0) / Float64(fma(0.16666666666666666, x, 0.5) * Float64(x * x))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 1.0], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 9e+224], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[eps, 3.5e+273], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(eps - -1.0), $MachinePrecision] * x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{elif}\;\varepsilon \leq 9 \cdot 10^{+224}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\mathbf{elif}\;\varepsilon \leq 3.5 \cdot 10^{+273}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \mathsf{fma}\left(\varepsilon - -1, x, -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if eps < 1Initial program 68.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites64.4%
Applied rewrites64.3%
if 1 < eps < 8.9999999999999995e224Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites23.2%
Taylor expanded in x around 0
Applied rewrites41.3%
Taylor expanded in x around inf
Applied rewrites41.3%
if 8.9999999999999995e224 < eps < 3.50000000000000011e273Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites66.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6450.0
Applied rewrites50.0%
if 3.50000000000000011e273 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites5.0%
Taylor expanded in x around 0
Applied rewrites5.0%
Taylor expanded in x around inf
Applied rewrites44.2%
Applied rewrites44.2%
Final simplification57.6%
(FPCore (x eps)
:precision binary64
(if (<= eps 480.0)
(/ (+ x 1.0) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
(if (<= eps 9e+224)
(fma (* 0.3333333333333333 x) (* x x) 1.0)
(if (<= eps 3.5e+273)
(/ (- (+ (/ 1.0 eps) 1.0) (fma (- eps -1.0) x -1.0)) 2.0)
(/ (+ x 1.0) (* (fma 0.16666666666666666 x 0.5) (* x x)))))))
double code(double x, double eps) {
double tmp;
if (eps <= 480.0) {
tmp = (x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
} else if (eps <= 9e+224) {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
} else if (eps <= 3.5e+273) {
tmp = (((1.0 / eps) + 1.0) - fma((eps - -1.0), x, -1.0)) / 2.0;
} else {
tmp = (x + 1.0) / (fma(0.16666666666666666, x, 0.5) * (x * x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 480.0) tmp = Float64(Float64(x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)); elseif (eps <= 9e+224) tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); elseif (eps <= 3.5e+273) tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - fma(Float64(eps - -1.0), x, -1.0)) / 2.0); else tmp = Float64(Float64(x + 1.0) / Float64(fma(0.16666666666666666, x, 0.5) * Float64(x * x))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 480.0], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 9e+224], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[eps, 3.5e+273], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(eps - -1.0), $MachinePrecision] * x + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 480:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\\
\mathbf{elif}\;\varepsilon \leq 9 \cdot 10^{+224}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\mathbf{elif}\;\varepsilon \leq 3.5 \cdot 10^{+273}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \mathsf{fma}\left(\varepsilon - -1, x, -1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if eps < 480Initial program 68.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites64.6%
Taylor expanded in x around 0
Applied rewrites59.9%
Applied rewrites59.9%
if 480 < eps < 8.9999999999999995e224Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites21.9%
Taylor expanded in x around 0
Applied rewrites40.4%
Taylor expanded in x around inf
Applied rewrites40.4%
if 8.9999999999999995e224 < eps < 3.50000000000000011e273Initial program 100.0%
Taylor expanded in eps around inf
exp-negN/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-exp.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites66.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6450.0
Applied rewrites50.0%
if 3.50000000000000011e273 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites5.0%
Taylor expanded in x around 0
Applied rewrites5.0%
Taylor expanded in x around inf
Applied rewrites44.2%
Applied rewrites44.2%
Final simplification54.5%
(FPCore (x eps)
:precision binary64
(if (<= eps 480.0)
(/ (+ x 1.0) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
(if (<= eps 5e+259)
(fma (* 0.3333333333333333 x) (* x x) 1.0)
(/ (+ x 1.0) (* (fma 0.16666666666666666 x 0.5) (* x x))))))
double code(double x, double eps) {
double tmp;
if (eps <= 480.0) {
tmp = (x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
} else if (eps <= 5e+259) {
tmp = fma((0.3333333333333333 * x), (x * x), 1.0);
} else {
tmp = (x + 1.0) / (fma(0.16666666666666666, x, 0.5) * (x * x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 480.0) tmp = Float64(Float64(x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)); elseif (eps <= 5e+259) tmp = fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0); else tmp = Float64(Float64(x + 1.0) / Float64(fma(0.16666666666666666, x, 0.5) * Float64(x * x))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 480.0], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5e+259], N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 480:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)}\\
\mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{+259}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if eps < 480Initial program 68.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites64.6%
Taylor expanded in x around 0
Applied rewrites59.9%
Applied rewrites59.9%
if 480 < eps < 5.00000000000000033e259Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites22.9%
Taylor expanded in x around 0
Applied rewrites42.8%
Taylor expanded in x around inf
Applied rewrites42.8%
if 5.00000000000000033e259 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites4.4%
Taylor expanded in x around 0
Applied rewrites4.6%
Taylor expanded in x around inf
Applied rewrites39.0%
Applied rewrites39.0%
Final simplification54.5%
(FPCore (x eps) :precision binary64 (if (<= eps 5e+259) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0) (/ (+ x 1.0) (* (fma 0.16666666666666666 x 0.5) (* x x)))))
double code(double x, double eps) {
double tmp;
if (eps <= 5e+259) {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
} else {
tmp = (x + 1.0) / (fma(0.16666666666666666, x, 0.5) * (x * x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 5e+259) tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); else tmp = Float64(Float64(x + 1.0) / Float64(fma(0.16666666666666666, x, 0.5) * Float64(x * x))); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 5e+259], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 5 \cdot 10^{+259}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(0.16666666666666666, x, 0.5\right) \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if eps < 5.00000000000000033e259Initial program 77.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites52.6%
Taylor expanded in x around 0
Applied rewrites49.7%
if 5.00000000000000033e259 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites4.4%
Taylor expanded in x around 0
Applied rewrites4.6%
Taylor expanded in x around inf
Applied rewrites39.0%
Applied rewrites39.0%
Final simplification49.3%
(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 78.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites51.1%
Taylor expanded in x around 0
Applied rewrites49.0%
(FPCore (x eps) :precision binary64 (fma (* 0.3333333333333333 x) (* x x) 1.0))
double code(double x, double eps) {
return fma((0.3333333333333333 * x), (x * x), 1.0);
}
function code(x, eps) return fma(Float64(0.3333333333333333 * x), Float64(x * x), 1.0) end
code[x_, eps_] := N[(N[(0.3333333333333333 * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.3333333333333333 \cdot x, x \cdot x, 1\right)
\end{array}
Initial program 78.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites51.1%
Taylor expanded in x around 0
Applied rewrites49.0%
Taylor expanded in x around inf
Applied rewrites48.8%
(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 78.1%
Taylor expanded in x around 0
Applied rewrites38.8%
herbie shell --seed 2024331
(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))