
(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 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (exp (- x))) (t_1 (+ (/ 1.0 eps) 1.0)))
(if (<=
(-
(* (exp (* (+ -1.0 eps) x)) t_1)
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
2.0)
(fma x t_0 t_0)
(/ (- (* (exp (* x eps)) t_1) (/ -1.0 (exp (fma x eps x)))) 2.0))))
double code(double x, double eps) {
double t_0 = exp(-x);
double t_1 = (1.0 / eps) + 1.0;
double tmp;
if (((exp(((-1.0 + eps) * x)) * t_1) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 2.0) {
tmp = fma(x, t_0, t_0);
} else {
tmp = ((exp((x * eps)) * t_1) - (-1.0 / exp(fma(x, eps, x)))) / 2.0;
}
return tmp;
}
function code(x, eps) t_0 = exp(Float64(-x)) t_1 = Float64(Float64(1.0 / eps) + 1.0) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(-1.0 + eps) * x)) * t_1) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 2.0) tmp = fma(x, t_0, t_0); else tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * t_1) - Float64(-1.0 / exp(fma(x, eps, x)))) / 2.0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, Block[{t$95$1 = 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$1), $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[(x * t$95$0 + t$95$0), $MachinePrecision], N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * t$95$1), $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 := e^{-x}\\
t_1 := \frac{1}{\varepsilon} + 1\\
\mathbf{if}\;e^{\left(-1 + \varepsilon\right) \cdot x} \cdot t\_1 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right) \leq 2:\\
\;\;\;\;\mathsf{fma}\left(x, t\_0, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot t\_1 - \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 56.4%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
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.f64100.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)))
4.0)
(* (+ 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 (((exp(((-1.0 + eps) * x)) * t_0) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) {
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(exp(Float64(Float64(-1.0 + eps) * x)) * t_0) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) <= 4.0) 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[(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], 4.0], 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}\;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 4:\\
\;\;\;\;\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))))) < 4Initial program 57.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.3%
Applied rewrites99.3%
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 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
rem-exp-logN/A
log-recN/A
lower-+.f64N/A
log-recN/A
rem-exp-logN/A
lower-/.f6450.8
Applied rewrites50.8%
Final simplification77.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)) (t_1 (exp (- x))))
(if (<= eps 0.5)
(fma x t_1 t_1)
(if (<= eps 5e+198)
(/ (- (* (exp (* (+ -1.0 eps) x)) t_0) (- (/ 1.0 eps) 1.0)) 2.0)
(/ (- 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 t_1 = exp(-x);
double tmp;
if (eps <= 0.5) {
tmp = fma(x, t_1, t_1);
} else if (eps <= 5e+198) {
tmp = ((exp(((-1.0 + eps) * x)) * t_0) - ((1.0 / eps) - 1.0)) / 2.0;
} 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) t_1 = exp(Float64(-x)) tmp = 0.0 if (eps <= 0.5) tmp = fma(x, t_1, t_1); elseif (eps <= 5e+198) 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(-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]}, Block[{t$95$1 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[eps, 0.5], N[(x * t$95$1 + t$95$1), $MachinePrecision], If[LessEqual[eps, 5e+198], 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[(-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\\
t_1 := e^{-x}\\
\mathbf{if}\;\varepsilon \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(x, t\_1, t\_1\right)\\
\mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{+198}:\\
\;\;\;\;\frac{e^{\left(-1 + \varepsilon\right) \cdot x} \cdot t\_0 - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\right)}}}{2}\\
\end{array}
\end{array}
if eps < 0.5Initial program 67.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.9%
Applied rewrites67.9%
Applied rewrites67.9%
if 0.5 < eps < 5.00000000000000049e198Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6466.9
Applied rewrites66.9%
if 5.00000000000000049e198 < 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%
Taylor expanded in x around 0
+-commutativeN/A
rem-exp-logN/A
log-recN/A
lower-+.f64N/A
log-recN/A
rem-exp-logN/A
lower-/.f6458.5
Applied rewrites58.5%
Final simplification66.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= eps 0.5)
(* (+ x 1.0) (exp (- x)))
(if (<= eps 5e+198)
(/ (- (* (exp (* (+ -1.0 eps) x)) t_0) (- (/ 1.0 eps) 1.0)) 2.0)
(/ (- 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 (eps <= 0.5) {
tmp = (x + 1.0) * exp(-x);
} else if (eps <= 5e+198) {
tmp = ((exp(((-1.0 + eps) * x)) * t_0) - ((1.0 / eps) - 1.0)) / 2.0;
} 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 (eps <= 0.5) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); elseif (eps <= 5e+198) 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(-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[eps, 0.5], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5e+198], 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[(-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}\;\varepsilon \leq 0.5:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{+198}:\\
\;\;\;\;\frac{e^{\left(-1 + \varepsilon\right) \cdot x} \cdot t\_0 - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\right)}}}{2}\\
\end{array}
\end{array}
if eps < 0.5Initial program 67.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.9%
Applied rewrites67.9%
if 0.5 < eps < 5.00000000000000049e198Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6466.9
Applied rewrites66.9%
if 5.00000000000000049e198 < 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%
Taylor expanded in x around 0
+-commutativeN/A
rem-exp-logN/A
log-recN/A
lower-+.f64N/A
log-recN/A
rem-exp-logN/A
lower-/.f6458.5
Applied rewrites58.5%
Final simplification66.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)))
(if (<= eps 0.5)
(* (+ x 1.0) (exp (- x)))
(if (<= eps 5e+198)
(/ (- (* (exp (* x eps)) t_0) (- (/ 1.0 eps) 1.0)) 2.0)
(/ (- 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 (eps <= 0.5) {
tmp = (x + 1.0) * exp(-x);
} else if (eps <= 5e+198) {
tmp = ((exp((x * eps)) * t_0) - ((1.0 / eps) - 1.0)) / 2.0;
} 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 (eps <= 0.5) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); elseif (eps <= 5e+198) tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * t_0) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); 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[eps, 0.5], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 5e+198], N[(N[(N[(N[Exp[N[(x * eps), $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[(-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}\;\varepsilon \leq 0.5:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{elif}\;\varepsilon \leq 5 \cdot 10^{+198}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot t\_0 - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\right)}}}{2}\\
\end{array}
\end{array}
if eps < 0.5Initial program 67.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.9%
Applied rewrites67.9%
if 0.5 < eps < 5.00000000000000049e198Initial 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.f6499.6
Applied rewrites99.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6466.9
Applied rewrites66.9%
if 5.00000000000000049e198 < 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%
Taylor expanded in x around 0
+-commutativeN/A
rem-exp-logN/A
log-recN/A
lower-+.f64N/A
log-recN/A
rem-exp-logN/A
lower-/.f6458.5
Applied rewrites58.5%
Final simplification66.7%
(FPCore (x eps)
:precision binary64
(if (<= x -4.5e-120)
(/ (- (+ (/ 1.0 eps) 1.0) (/ -1.0 (exp (fma x eps x)))) 2.0)
(if (<= x 330.0)
(* (+ x 1.0) (exp (- x)))
(/ (- (* (/ 1.0 eps) (exp (* x eps))) (- (/ 1.0 eps) 1.0)) 2.0))))
double code(double x, double eps) {
double tmp;
if (x <= -4.5e-120) {
tmp = (((1.0 / eps) + 1.0) - (-1.0 / exp(fma(x, eps, x)))) / 2.0;
} else if (x <= 330.0) {
tmp = (x + 1.0) * exp(-x);
} else {
tmp = (((1.0 / eps) * exp((x * eps))) - ((1.0 / eps) - 1.0)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -4.5e-120) tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(-1.0 / exp(fma(x, eps, x)))) / 2.0); elseif (x <= 330.0) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); else tmp = Float64(Float64(Float64(Float64(1.0 / eps) * exp(Float64(x * eps))) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -4.5e-120], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(-1.0 / N[Exp[N[(x * eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[x, 330.0], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] * N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.5 \cdot 10^{-120}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\right)}}}{2}\\
\mathbf{elif}\;x \leq 330:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\varepsilon} \cdot e^{x \cdot \varepsilon} - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\end{array}
\end{array}
if x < -4.5e-120Initial program 87.5%
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.f6485.9
Applied rewrites85.9%
Taylor expanded in x around 0
+-commutativeN/A
rem-exp-logN/A
log-recN/A
lower-+.f64N/A
log-recN/A
rem-exp-logN/A
lower-/.f6443.7
Applied rewrites43.7%
if -4.5e-120 < x < 330Initial program 50.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites82.9%
Applied rewrites82.9%
if 330 < 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 eps around inf
*-commutativeN/A
lower-*.f6462.7
Applied rewrites62.7%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6448.5
Applied rewrites48.5%
Taylor expanded in eps around 0
lower-/.f6448.5
Applied rewrites48.5%
(FPCore (x eps) :precision binary64 (let* ((t_0 (exp (- x)))) (if (<= x -21.5) (* (/ t_0 eps) 0.5) (* (+ x 1.0) t_0))))
double code(double x, double eps) {
double t_0 = exp(-x);
double tmp;
if (x <= -21.5) {
tmp = (t_0 / eps) * 0.5;
} else {
tmp = (x + 1.0) * t_0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-x)
if (x <= (-21.5d0)) then
tmp = (t_0 / eps) * 0.5d0
else
tmp = (x + 1.0d0) * t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.exp(-x);
double tmp;
if (x <= -21.5) {
tmp = (t_0 / eps) * 0.5;
} else {
tmp = (x + 1.0) * t_0;
}
return tmp;
}
def code(x, eps): t_0 = math.exp(-x) tmp = 0 if x <= -21.5: tmp = (t_0 / eps) * 0.5 else: tmp = (x + 1.0) * t_0 return tmp
function code(x, eps) t_0 = exp(Float64(-x)) tmp = 0.0 if (x <= -21.5) tmp = Float64(Float64(t_0 / eps) * 0.5); else tmp = Float64(Float64(x + 1.0) * t_0); end return tmp end
function tmp_2 = code(x, eps) t_0 = exp(-x); tmp = 0.0; if (x <= -21.5) tmp = (t_0 / eps) * 0.5; else tmp = (x + 1.0) * t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[x, -21.5], N[(N[(t$95$0 / eps), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(x + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;x \leq -21.5:\\
\;\;\;\;\frac{t\_0}{\varepsilon} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x + 1\right) \cdot t\_0\\
\end{array}
\end{array}
if x < -21.5Initial program 100.0%
Applied rewrites0.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
neg-mul-1N/A
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f6448.7
Applied rewrites48.7%
if -21.5 < x Initial program 72.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites65.2%
Applied rewrites65.2%
(FPCore (x eps)
:precision binary64
(if (<= eps 1.85)
(* (+ x 1.0) (exp (- x)))
(if (<= eps 8e+219)
(* (fma (fma 0.5 x -1.0) x 1.0) (+ x 1.0))
(/
(- (+ (/ 1.0 eps) 1.0) (* (fma (- -1.0 eps) x 1.0) (- (/ 1.0 eps) 1.0)))
2.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 1.85) {
tmp = (x + 1.0) * exp(-x);
} else if (eps <= 8e+219) {
tmp = fma(fma(0.5, x, -1.0), x, 1.0) * (x + 1.0);
} else {
tmp = (((1.0 / eps) + 1.0) - (fma((-1.0 - eps), x, 1.0) * ((1.0 / eps) - 1.0))) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 1.85) tmp = Float64(Float64(x + 1.0) * exp(Float64(-x))); elseif (eps <= 8e+219) tmp = Float64(fma(fma(0.5, x, -1.0), x, 1.0) * Float64(x + 1.0)); else tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(fma(Float64(-1.0 - eps), x, 1.0) * Float64(Float64(1.0 / eps) - 1.0))) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 1.85], N[(N[(x + 1.0), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 8e+219], N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(N[(-1.0 - eps), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 1.85:\\
\;\;\;\;\left(x + 1\right) \cdot e^{-x}\\
\mathbf{elif}\;\varepsilon \leq 8 \cdot 10^{+219}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \mathsf{fma}\left(-1 - \varepsilon, x, 1\right) \cdot \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\end{array}
\end{array}
if eps < 1.8500000000000001Initial program 67.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.9%
Applied rewrites67.9%
if 1.8500000000000001 < eps < 7.99999999999999972e219Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites29.6%
Applied rewrites29.6%
Taylor expanded in x around 0
Applied rewrites48.9%
if 7.99999999999999972e219 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6446.8
Applied rewrites46.8%
Taylor expanded in x around 0
neg-mul-1N/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f644.9
Applied rewrites4.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6438.5
Applied rewrites38.5%
Final simplification62.0%
(FPCore (x eps)
:precision binary64
(if (<= eps 5300.0)
(/ 1.0 (fma (fma (fma 0.375 x -0.3333333333333333) x 0.5) (* x x) 1.0))
(if (<= eps 8e+219)
(* (fma (fma 0.5 x -1.0) x 1.0) (+ x 1.0))
(/
(- (+ (/ 1.0 eps) 1.0) (* (fma (- -1.0 eps) x 1.0) (- (/ 1.0 eps) 1.0)))
2.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 5300.0) {
tmp = 1.0 / fma(fma(fma(0.375, x, -0.3333333333333333), x, 0.5), (x * x), 1.0);
} else if (eps <= 8e+219) {
tmp = fma(fma(0.5, x, -1.0), x, 1.0) * (x + 1.0);
} else {
tmp = (((1.0 / eps) + 1.0) - (fma((-1.0 - eps), x, 1.0) * ((1.0 / eps) - 1.0))) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 5300.0) tmp = Float64(1.0 / fma(fma(fma(0.375, x, -0.3333333333333333), x, 0.5), Float64(x * x), 1.0)); elseif (eps <= 8e+219) tmp = Float64(fma(fma(0.5, x, -1.0), x, 1.0) * Float64(x + 1.0)); else tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(fma(Float64(-1.0 - eps), x, 1.0) * Float64(Float64(1.0 / eps) - 1.0))) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 5300.0], N[(1.0 / N[(N[(N[(0.375 * x + -0.3333333333333333), $MachinePrecision] * x + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 8e+219], N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(N[(-1.0 - eps), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 5300:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.375, x, -0.3333333333333333\right), x, 0.5\right), x \cdot x, 1\right)}\\
\mathbf{elif}\;\varepsilon \leq 8 \cdot 10^{+219}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \left(x + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \mathsf{fma}\left(-1 - \varepsilon, x, 1\right) \cdot \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\end{array}
\end{array}
if eps < 5300Initial program 67.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.9%
Taylor expanded in x around 0
Applied rewrites61.1%
Applied rewrites61.1%
Taylor expanded in x around 0
Applied rewrites62.2%
if 5300 < eps < 7.99999999999999972e219Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites29.6%
Applied rewrites29.6%
Taylor expanded in x around 0
Applied rewrites48.9%
if 7.99999999999999972e219 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6446.8
Applied rewrites46.8%
Taylor expanded in x around 0
neg-mul-1N/A
+-commutativeN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
distribute-lft-inN/A
metadata-evalN/A
mul-1-negN/A
unsub-negN/A
lower--.f644.9
Applied rewrites4.9%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6438.5
Applied rewrites38.5%
Final simplification57.8%
(FPCore (x eps) :precision binary64 (if (<= eps 5300.0) (/ 1.0 (fma (fma (fma 0.375 x -0.3333333333333333) x 0.5) (* x x) 1.0)) (* (fma (fma 0.5 x -1.0) x 1.0) (+ x 1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 5300.0) {
tmp = 1.0 / fma(fma(fma(0.375, x, -0.3333333333333333), x, 0.5), (x * x), 1.0);
} else {
tmp = fma(fma(0.5, x, -1.0), x, 1.0) * (x + 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 5300.0) tmp = Float64(1.0 / fma(fma(fma(0.375, x, -0.3333333333333333), x, 0.5), Float64(x * x), 1.0)); else tmp = Float64(fma(fma(0.5, x, -1.0), x, 1.0) * Float64(x + 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 5300.0], N[(1.0 / N[(N[(N[(0.375 * x + -0.3333333333333333), $MachinePrecision] * x + 0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 5300:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.375, x, -0.3333333333333333\right), x, 0.5\right), x \cdot x, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \left(x + 1\right)\\
\end{array}
\end{array}
if eps < 5300Initial program 67.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.9%
Taylor expanded in x around 0
Applied rewrites61.1%
Applied rewrites61.1%
Taylor expanded in x around 0
Applied rewrites62.2%
if 5300 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites20.9%
Applied rewrites20.9%
Taylor expanded in x around 0
Applied rewrites39.2%
Final simplification56.2%
(FPCore (x eps) :precision binary64 (if (<= eps 5300.0) (/ (+ x 1.0) (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 1.0)) (* (fma (fma 0.5 x -1.0) x 1.0) (+ x 1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 5300.0) {
tmp = (x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0);
} else {
tmp = fma(fma(0.5, x, -1.0), x, 1.0) * (x + 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 5300.0) tmp = Float64(Float64(x + 1.0) / fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 1.0)); else tmp = Float64(fma(fma(0.5, x, -1.0), x, 1.0) * Float64(x + 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 5300.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], N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 5300:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \left(x + 1\right)\\
\end{array}
\end{array}
if eps < 5300Initial program 67.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.9%
Applied rewrites67.9%
Taylor expanded in x around 0
Applied rewrites61.1%
if 5300 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites20.9%
Applied rewrites20.9%
Taylor expanded in x around 0
Applied rewrites39.2%
Final simplification55.5%
(FPCore (x eps) :precision binary64 (if (<= eps 5300.0) (/ 1.0 (fma (* (fma -0.3333333333333333 x 0.5) x) x 1.0)) (* (fma (fma 0.5 x -1.0) x 1.0) (+ x 1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 5300.0) {
tmp = 1.0 / fma((fma(-0.3333333333333333, x, 0.5) * x), x, 1.0);
} else {
tmp = fma(fma(0.5, x, -1.0), x, 1.0) * (x + 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 5300.0) tmp = Float64(1.0 / fma(Float64(fma(-0.3333333333333333, x, 0.5) * x), x, 1.0)); else tmp = Float64(fma(fma(0.5, x, -1.0), x, 1.0) * Float64(x + 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 5300.0], N[(1.0 / N[(N[(N[(-0.3333333333333333 * x + 0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 5300:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, x, 0.5\right) \cdot x, x, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \left(x + 1\right)\\
\end{array}
\end{array}
if eps < 5300Initial program 67.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.9%
Taylor expanded in x around 0
Applied rewrites61.1%
Applied rewrites61.1%
Taylor expanded in x around 0
Applied rewrites61.0%
if 5300 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites20.9%
Applied rewrites20.9%
Taylor expanded in x around 0
Applied rewrites39.2%
Final simplification55.4%
(FPCore (x eps) :precision binary64 (if (<= eps 5300.0) (/ 1.0 (fma (* x x) 0.5 1.0)) (* (fma (fma 0.5 x -1.0) x 1.0) (+ x 1.0))))
double code(double x, double eps) {
double tmp;
if (eps <= 5300.0) {
tmp = 1.0 / fma((x * x), 0.5, 1.0);
} else {
tmp = fma(fma(0.5, x, -1.0), x, 1.0) * (x + 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 5300.0) tmp = Float64(1.0 / fma(Float64(x * x), 0.5, 1.0)); else tmp = Float64(fma(fma(0.5, x, -1.0), x, 1.0) * Float64(x + 1.0)); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 5300.0], N[(1.0 / N[(N[(x * x), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 5300:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(x \cdot x, 0.5, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot \left(x + 1\right)\\
\end{array}
\end{array}
if eps < 5300Initial program 67.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.9%
Taylor expanded in x around 0
Applied rewrites61.1%
Applied rewrites61.1%
Taylor expanded in x around 0
Applied rewrites58.6%
if 5300 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites20.9%
Applied rewrites20.9%
Taylor expanded in x around 0
Applied rewrites39.2%
Final simplification53.6%
(FPCore (x eps) :precision binary64 (if (<= x 8.5e+24) 1.0 (* (* (fma 0.3333333333333333 x -0.5) x) x)))
double code(double x, double eps) {
double tmp;
if (x <= 8.5e+24) {
tmp = 1.0;
} else {
tmp = (fma(0.3333333333333333, x, -0.5) * x) * x;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 8.5e+24) tmp = 1.0; else tmp = Float64(Float64(fma(0.3333333333333333, x, -0.5) * x) * x); end return tmp end
code[x_, eps_] := If[LessEqual[x, 8.5e+24], 1.0, N[(N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{+24}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right) \cdot x\right) \cdot x\\
\end{array}
\end{array}
if x < 8.49999999999999959e24Initial program 64.9%
Taylor expanded in x around 0
Applied rewrites57.6%
if 8.49999999999999959e24 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites46.0%
Taylor expanded in x around 0
Applied rewrites39.5%
Taylor expanded in x around inf
Applied rewrites39.5%
(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 76.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites55.8%
Taylor expanded in x around 0
Applied rewrites51.4%
(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 76.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites55.8%
Taylor expanded in x around 0
Applied rewrites51.4%
Taylor expanded in x around inf
Applied rewrites51.3%
(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 76.1%
Taylor expanded in x around 0
Applied rewrites40.1%
herbie shell --seed 2024295
(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))