
(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 14 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 (<=
(-
(* t_0 (exp (* (- eps 1.0) x)))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
2.0)
(* (+ x 1.0) (exp (- x)))
(/ (- (* t_0 (exp (* x eps))) (/ -1.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 (((t_0 * exp(((eps - 1.0) * x))) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 2.0) {
tmp = (x + 1.0) * exp(-x);
} else {
tmp = ((t_0 * exp((x * eps))) - (-1.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(t_0 * exp(Float64(Float64(eps - 1.0) * x))) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 2.0) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); else tmp = Float64(Float64(Float64(t_0 * exp(Float64(x * eps))) - Float64(-1.0 / exp(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[(t$95$0 * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $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], 2.0], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$0 * N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;t\_0 \cdot e^{\left(\varepsilon - 1\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 2:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 \cdot e^{x \cdot \varepsilon} - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\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 52.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
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 99.9%
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.f6499.9
Applied rewrites99.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Final simplification100.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (/ 1.0 eps) 1.0)) (t_1 (+ (/ 1.0 eps) 1.0)))
(if (<=
(- (* t_1 (exp (* (- eps 1.0) x))) (* (exp (* (- -1.0 eps) x)) t_0))
4.0)
(* (+ x 1.0) (exp (- x)))
(/ (- (* t_1 (exp (* x eps))) 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 (((t_1 * exp(((eps - 1.0) * x))) - (exp(((-1.0 - eps) * x)) * t_0)) <= 4.0) {
tmp = (x + 1.0) * exp(-x);
} else {
tmp = ((t_1 * exp((x * eps))) - 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) :: t_1
real(8) :: tmp
t_0 = (1.0d0 / eps) - 1.0d0
t_1 = (1.0d0 / eps) + 1.0d0
if (((t_1 * exp(((eps - 1.0d0) * x))) - (exp((((-1.0d0) - eps) * x)) * t_0)) <= 4.0d0) then
tmp = (x + 1.0d0) * exp(-x)
else
tmp = ((t_1 * exp((x * eps))) - t_0) / 2.0d0
end if
code = tmp
end function
public static 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 (((t_1 * Math.exp(((eps - 1.0) * x))) - (Math.exp(((-1.0 - eps) * x)) * t_0)) <= 4.0) {
tmp = (x + 1.0) * Math.exp(-x);
} else {
tmp = ((t_1 * Math.exp((x * eps))) - t_0) / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = (1.0 / eps) - 1.0 t_1 = (1.0 / eps) + 1.0 tmp = 0 if ((t_1 * math.exp(((eps - 1.0) * x))) - (math.exp(((-1.0 - eps) * x)) * t_0)) <= 4.0: tmp = (x + 1.0) * math.exp(-x) else: tmp = ((t_1 * math.exp((x * eps))) - 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(t_1 * exp(Float64(Float64(eps - 1.0) * x))) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * t_0)) <= 4.0) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); else tmp = Float64(Float64(Float64(t_1 * exp(Float64(x * eps))) - t_0) / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = (1.0 / eps) - 1.0; t_1 = (1.0 / eps) + 1.0; tmp = 0.0; if (((t_1 * exp(((eps - 1.0) * x))) - (exp(((-1.0 - eps) * x)) * t_0)) <= 4.0) tmp = (x + 1.0) * exp(-x); else tmp = ((t_1 * exp((x * eps))) - t_0) / 2.0; end tmp_2 = 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[(t$95$1 * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 4.0], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$1 * N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $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}\;t\_1 \cdot e^{\left(\varepsilon - 1\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot t\_0 \leq 4:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 \cdot e^{x \cdot \varepsilon} - 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 52.5%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Applied rewrites99.8%
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 99.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6449.2
Applied rewrites49.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6449.2
Applied rewrites49.2%
Final simplification79.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<=
(-
(* t_0 (exp (* (- eps 1.0) x)))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
5e+99)
(* (+ x 1.0) (exp (- x)))
(/ (- t_0 (/ -1.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 (((t_0 * exp(((eps - 1.0) * x))) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 5e+99) {
tmp = (x + 1.0) * exp(-x);
} else {
tmp = (t_0 - (-1.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(t_0 * exp(Float64(Float64(eps - 1.0) * x))) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 5e+99) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); else tmp = Float64(Float64(t_0 - Float64(-1.0 / exp(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[(t$95$0 * N[Exp[N[(N[(eps - 1.0), $MachinePrecision] * x), $MachinePrecision]], $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], 5e+99], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - N[(-1.0 / N[Exp[N[(x * eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;t\_0 \cdot e^{\left(\varepsilon - 1\right) \cdot x} - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 5 \cdot 10^{+99}:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\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))))) < 5.00000000000000008e99Initial program 52.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.2%
Applied rewrites99.2%
if 5.00000000000000008e99 < (-.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%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6453.5
Applied rewrites53.5%
Final simplification81.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= x -720.0)
(/ (- (/ t_0 eps) (- (/ 1.0 eps) 1.0)) 2.0)
(if (<= x -1.3e-176)
(fma
(* 0.5 x)
(fma (- eps 1.0) (/ 1.0 eps) (* (fma (- eps) eps 1.0) (/ 1.0 eps)))
1.0)
(if (<= x 2.5e+126)
(* (+ x 1.0) t_0)
(fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))))))
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if (x <= -720.0) {
tmp = ((t_0 / eps) - ((1.0 / eps) - 1.0)) / 2.0;
} else if (x <= -1.3e-176) {
tmp = fma((0.5 * x), fma((eps - 1.0), (1.0 / eps), (fma(-eps, eps, 1.0) * (1.0 / eps))), 1.0);
} else if (x <= 2.5e+126) {
tmp = (x + 1.0) * t_0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -720.0) tmp = Float64(Float64(Float64(t_0 / eps) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); elseif (x <= -1.3e-176) tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), Float64(1.0 / eps), Float64(fma(Float64(-eps), eps, 1.0) * Float64(1.0 / eps))), 1.0); elseif (x <= 2.5e+126) tmp = Float64(Float64(x + 1.0) * t_0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -720.0], N[(N[(N[(t$95$0 / eps), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, -1.3e-176], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * N[(1.0 / eps), $MachinePrecision] + N[(N[((-eps) * eps + 1.0), $MachinePrecision] * N[(1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[x, 2.5e+126], N[(N[(x + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -720:\\
\;\;\;\;\frac{\frac{t\_0}{\varepsilon} - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{elif}\;x \leq -1.3 \cdot 10^{-176}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, \frac{1}{\varepsilon}, \mathsf{fma}\left(-\varepsilon, \varepsilon, 1\right) \cdot \frac{1}{\varepsilon}\right), 1\right)\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+126}:\\
\;\;\;\;\left(x + 1\right) \cdot t\_0\\
\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 < -720Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6453.2
Applied rewrites53.2%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6448.3
Applied rewrites48.3%
if -720 < x < -1.29999999999999996e-176Initial program 52.6%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites68.8%
Taylor expanded in eps around 0
Applied rewrites77.2%
Applied rewrites77.2%
Taylor expanded in eps around 0
Applied rewrites77.0%
if -1.29999999999999996e-176 < x < 2.49999999999999989e126Initial program 63.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.4%
Applied rewrites75.4%
if 2.49999999999999989e126 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites60.2%
Final simplification70.1%
(FPCore (x eps)
:precision binary64
(if (<= eps 0.0126)
(* (+ x 1.0) (exp (- x)))
(if (<= eps 1.85e+261)
(/ (* (fma (fma 0.5 x -1.0) x 1.0) (fma x x -1.0)) (- x 1.0))
(fma
(* 0.5 x)
(fma (- eps 1.0) (+ (/ 1.0 eps) 1.0) (* (* eps eps) (/ -1.0 eps)))
1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 0.0126) {
tmp = (x + 1.0) * exp(-x);
} else if (eps <= 1.85e+261) {
tmp = (fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / (x - 1.0);
} else {
tmp = fma((0.5 * x), fma((eps - 1.0), ((1.0 / eps) + 1.0), ((eps * eps) * (-1.0 / eps))), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 0.0126) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); elseif (eps <= 1.85e+261) tmp = Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / Float64(x - 1.0)); else tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), Float64(Float64(1.0 / eps) + 1.0), Float64(Float64(eps * eps) * Float64(-1.0 / eps))), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 0.0126], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 1.85e+261], N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] + N[(N[(eps * eps), $MachinePrecision] * N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 0.0126:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{elif}\;\varepsilon \leq 1.85 \cdot 10^{+261}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, \frac{1}{\varepsilon} + 1, \left(\varepsilon \cdot \varepsilon\right) \cdot \frac{-1}{\varepsilon}\right), 1\right)\\
\end{array}
\end{array}
if eps < 0.0126Initial program 61.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites71.2%
Applied rewrites71.2%
if 0.0126 < eps < 1.85e261Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites32.5%
Applied rewrites32.5%
Taylor expanded in x around 0
Applied rewrites55.1%
Applied rewrites56.8%
if 1.85e261 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites11.2%
Taylor expanded in eps around 0
Applied rewrites50.3%
Applied rewrites50.3%
Taylor expanded in eps around inf
Applied rewrites50.3%
Final simplification67.2%
(FPCore (x eps)
:precision binary64
(if (<= eps 19.0)
(*
(*
(/ (+ x 1.0) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
2.0)
0.5)
(if (<= eps 1.85e+261)
(/ (* (fma (fma 0.5 x -1.0) x 1.0) (fma x x -1.0)) (- x 1.0))
(fma
(* 0.5 x)
(fma (- eps 1.0) (+ (/ 1.0 eps) 1.0) (* (* eps eps) (/ -1.0 eps)))
1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 19.0) {
tmp = (((x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5;
} else if (eps <= 1.85e+261) {
tmp = (fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / (x - 1.0);
} else {
tmp = fma((0.5 * x), fma((eps - 1.0), ((1.0 / eps) + 1.0), ((eps * eps) * (-1.0 / eps))), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 19.0) tmp = Float64(Float64(Float64(Float64(x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5); elseif (eps <= 1.85e+261) tmp = Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / Float64(x - 1.0)); else tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), Float64(Float64(1.0 / eps) + 1.0), Float64(Float64(eps * eps) * Float64(-1.0 / eps))), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 19.0], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[eps, 1.85e+261], N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] + N[(N[(eps * eps), $MachinePrecision] * N[(-1.0 / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 19:\\
\;\;\;\;\left(\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)} \cdot 2\right) \cdot 0.5\\
\mathbf{elif}\;\varepsilon \leq 1.85 \cdot 10^{+261}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, \frac{1}{\varepsilon} + 1, \left(\varepsilon \cdot \varepsilon\right) \cdot \frac{-1}{\varepsilon}\right), 1\right)\\
\end{array}
\end{array}
if eps < 19Initial program 62.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.8%
Taylor expanded in x around 0
Applied rewrites67.0%
if 19 < eps < 1.85e261Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites33.1%
Applied rewrites33.1%
Taylor expanded in x around 0
Applied rewrites56.2%
Applied rewrites57.9%
if 1.85e261 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites11.2%
Taylor expanded in eps around 0
Applied rewrites50.3%
Applied rewrites50.3%
Taylor expanded in eps around inf
Applied rewrites50.3%
Final simplification64.3%
(FPCore (x eps)
:precision binary64
(if (<= eps 19.0)
(*
(*
(/ (+ x 1.0) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
2.0)
0.5)
(if (<= eps 1.85e+261)
(/ (* (fma (fma 0.5 x -1.0) x 1.0) (fma x x -1.0)) (- x 1.0))
(fma
(* 0.5 x)
(fma (- eps 1.0) (+ (/ 1.0 eps) 1.0) (/ (* (- eps) eps) eps))
1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 19.0) {
tmp = (((x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5;
} else if (eps <= 1.85e+261) {
tmp = (fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / (x - 1.0);
} else {
tmp = fma((0.5 * x), fma((eps - 1.0), ((1.0 / eps) + 1.0), ((-eps * eps) / eps)), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 19.0) tmp = Float64(Float64(Float64(Float64(x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5); elseif (eps <= 1.85e+261) tmp = Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / Float64(x - 1.0)); else tmp = fma(Float64(0.5 * x), fma(Float64(eps - 1.0), Float64(Float64(1.0 / eps) + 1.0), Float64(Float64(Float64(-eps) * eps) / eps)), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 19.0], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[eps, 1.85e+261], N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(eps - 1.0), $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] + N[(N[((-eps) * eps), $MachinePrecision] / eps), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 19:\\
\;\;\;\;\left(\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)} \cdot 2\right) \cdot 0.5\\
\mathbf{elif}\;\varepsilon \leq 1.85 \cdot 10^{+261}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\varepsilon - 1, \frac{1}{\varepsilon} + 1, \frac{\left(-\varepsilon\right) \cdot \varepsilon}{\varepsilon}\right), 1\right)\\
\end{array}
\end{array}
if eps < 19Initial program 62.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.8%
Taylor expanded in x around 0
Applied rewrites67.0%
if 19 < eps < 1.85e261Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites33.1%
Applied rewrites33.1%
Taylor expanded in x around 0
Applied rewrites56.2%
Applied rewrites57.9%
if 1.85e261 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites11.2%
Taylor expanded in eps around 0
Applied rewrites50.3%
Taylor expanded in eps around inf
Applied rewrites50.3%
Final simplification64.3%
(FPCore (x eps)
:precision binary64
(if (<= eps 19.0)
(*
(*
(/ (+ x 1.0) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0))
2.0)
0.5)
(/ (* (fma (fma 0.5 x -1.0) x 1.0) (fma x x -1.0)) (- x 1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 19.0) {
tmp = (((x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5;
} else {
tmp = (fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 19.0) tmp = Float64(Float64(Float64(Float64(x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)) * 2.0) * 0.5); else tmp = Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / Float64(x - 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 19.0], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 19:\\
\;\;\;\;\left(\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 1\right)} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\end{array}
\end{array}
if eps < 19Initial program 62.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.8%
Taylor expanded in x around 0
Applied rewrites67.0%
if 19 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites28.8%
Applied rewrites28.8%
Taylor expanded in x around 0
Applied rewrites47.5%
Applied rewrites49.0%
Final simplification62.5%
(FPCore (x eps) :precision binary64 (if (<= eps 19.0) (* (* (/ (+ x 1.0) (fma (fma 0.5 x 1.0) x 1.0)) 2.0) 0.5) (/ (* (fma (fma 0.5 x -1.0) x 1.0) (fma x x -1.0)) (- x 1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 19.0) {
tmp = (((x + 1.0) / fma(fma(0.5, x, 1.0), x, 1.0)) * 2.0) * 0.5;
} else {
tmp = (fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / (x - 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 19.0) tmp = Float64(Float64(Float64(Float64(x + 1.0) / fma(fma(0.5, x, 1.0), x, 1.0)) * 2.0) * 0.5); else tmp = Float64(Float64(fma(fma(0.5, x, -1.0), x, 1.0) * fma(x, x, -1.0)) / Float64(x - 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 19.0], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.5 * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(x - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 19:\\
\;\;\;\;\left(\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right)} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \mathsf{fma}\left(x, x, -1\right)}{x - 1}\\
\end{array}
\end{array}
if eps < 19Initial program 62.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.8%
Taylor expanded in x around 0
Applied rewrites64.8%
if 19 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites28.8%
Applied rewrites28.8%
Taylor expanded in x around 0
Applied rewrites47.5%
Applied rewrites49.0%
Final simplification60.9%
(FPCore (x eps) :precision binary64 (if (<= eps 19.0) (* (* (/ (+ x 1.0) (fma (fma 0.5 x 1.0) x 1.0)) 2.0) 0.5) (* (+ x 1.0) (fma (fma 0.5 x -1.0) x 1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 19.0) {
tmp = (((x + 1.0) / fma(fma(0.5, x, 1.0), x, 1.0)) * 2.0) * 0.5;
} else {
tmp = (x + 1.0) * fma(fma(0.5, x, -1.0), x, 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 19.0) tmp = Float64(Float64(Float64(Float64(x + 1.0) / fma(fma(0.5, x, 1.0), x, 1.0)) * 2.0) * 0.5); else tmp = Float64(Float64(x + 1.0) * fma(fma(0.5, x, -1.0), x, 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 19.0], N[(N[(N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.5 * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] * N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 19:\\
\;\;\;\;\left(\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right)} \cdot 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x + 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right)\\
\end{array}
\end{array}
if eps < 19Initial program 62.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.8%
Taylor expanded in x around 0
Applied rewrites64.8%
if 19 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites28.8%
Applied rewrites28.8%
Taylor expanded in x around 0
Applied rewrites47.5%
Final simplification60.5%
(FPCore (x eps) :precision binary64 (if (<= x 520.0) 1.0 (if (<= x 2.5e+126) 0.0 (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))))
double code(double x, double eps) {
double tmp;
if (x <= 520.0) {
tmp = 1.0;
} else if (x <= 2.5e+126) {
tmp = 0.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 <= 520.0) tmp = 1.0; elseif (x <= 2.5e+126) tmp = 0.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, 520.0], 1.0, If[LessEqual[x, 2.5e+126], 0.0, 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 520:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+126}:\\
\;\;\;\;0\\
\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 < 520Initial program 60.7%
Taylor expanded in x around 0
Applied rewrites67.6%
if 520 < x < 2.49999999999999989e126Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites3.1%
Taylor expanded in eps around inf
Applied rewrites2.7%
Applied rewrites11.9%
Taylor expanded in eps around 0
Applied rewrites42.3%
if 2.49999999999999989e126 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites60.2%
(FPCore (x eps) :precision binary64 (if (<= x 520.0) 1.0 (if (<= x 2.5e+126) 0.0 (* (* (fma 0.3333333333333333 x -0.5) x) x))))
double code(double x, double eps) {
double tmp;
if (x <= 520.0) {
tmp = 1.0;
} else if (x <= 2.5e+126) {
tmp = 0.0;
} else {
tmp = (fma(0.3333333333333333, x, -0.5) * x) * x;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 520.0) tmp = 1.0; elseif (x <= 2.5e+126) tmp = 0.0; else tmp = Float64(Float64(fma(0.3333333333333333, x, -0.5) * x) * x); end return tmp end
code[x_, eps_] := If[LessEqual[x, 520.0], 1.0, If[LessEqual[x, 2.5e+126], 0.0, N[(N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 520:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{+126}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right) \cdot x\right) \cdot x\\
\end{array}
\end{array}
if x < 520Initial program 60.7%
Taylor expanded in x around 0
Applied rewrites67.6%
if 520 < x < 2.49999999999999989e126Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites3.1%
Taylor expanded in eps around inf
Applied rewrites2.7%
Applied rewrites11.9%
Taylor expanded in eps around 0
Applied rewrites42.3%
if 2.49999999999999989e126 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites60.2%
Taylor expanded in x around inf
Applied rewrites60.2%
(FPCore (x eps) :precision binary64 (if (<= x 520.0) 1.0 0.0))
double code(double x, double eps) {
double tmp;
if (x <= 520.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 <= 520.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 <= 520.0) {
tmp = 1.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 520.0: tmp = 1.0 else: tmp = 0.0 return tmp
function code(x, eps) tmp = 0.0 if (x <= 520.0) tmp = 1.0; else tmp = 0.0; end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 520.0) tmp = 1.0; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 520.0], 1.0, 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 520:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 520Initial program 60.7%
Taylor expanded in x around 0
Applied rewrites67.6%
if 520 < x Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites3.1%
Taylor expanded in eps around inf
Applied rewrites2.6%
Applied rewrites15.5%
Taylor expanded in eps around 0
Applied rewrites41.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 71.6%
Taylor expanded in x around 0
Applied rewrites49.7%
herbie shell --seed 2024327
(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))