
(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
(-
(* (exp (* (+ -1.0 eps) x)) (+ (/ 1.0 eps) 1.0))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))))
(if (<= t_0 0.0) (* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0)) (/ t_0 2.0))))
double code(double x, double eps) {
double t_0 = (exp(((-1.0 + eps) * x)) * ((1.0 / eps) + 1.0)) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = (exp((((-1.0d0) + eps) * x)) * ((1.0d0 / eps) + 1.0d0)) - (exp((((-1.0d0) - eps) * x)) * ((1.0d0 / eps) - 1.0d0))
if (t_0 <= 0.0d0) then
tmp = 0.5d0 * (((x + 1.0d0) / exp(x)) * 2.0d0)
else
tmp = t_0 / 2.0d0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (Math.exp(((-1.0 + eps) * x)) * ((1.0 / eps) + 1.0)) - (Math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = 0.5 * (((x + 1.0) / Math.exp(x)) * 2.0);
} else {
tmp = t_0 / 2.0;
}
return tmp;
}
def code(x, eps): t_0 = (math.exp(((-1.0 + eps) * x)) * ((1.0 / eps) + 1.0)) - (math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0)) tmp = 0 if t_0 <= 0.0: tmp = 0.5 * (((x + 1.0) / math.exp(x)) * 2.0) else: tmp = t_0 / 2.0 return tmp
function code(x, eps) t_0 = Float64(Float64(exp(Float64(Float64(-1.0 + eps) * x)) * Float64(Float64(1.0 / eps) + 1.0)) - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * Float64(Float64(1.0 / eps) - 1.0))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); else tmp = Float64(t_0 / 2.0); end return tmp end
function tmp_2 = code(x, eps) t_0 = (exp(((-1.0 + eps) * x)) * ((1.0 / eps) + 1.0)) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0)); tmp = 0.0; if (t_0 <= 0.0) tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0); else tmp = t_0 / 2.0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\left(-1 + \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} + 1\right) - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot \left(\frac{1}{\varepsilon} - 1\right)\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) < 0.0Initial program 33.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
if 0.0 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.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)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 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 (((exp(((-1.0 + eps) * x)) * t_0) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 4.0) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 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 (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(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 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[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[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $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:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\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 52.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
if 4 < (-.f64 (*.f64 (+.f64 #s(literal 1 binary64) (/.f64 #s(literal 1 binary64) eps)) (exp.f64 (neg.f64 (*.f64 (-.f64 #s(literal 1 binary64) eps) x)))) (*.f64 (-.f64 (/.f64 #s(literal 1 binary64) eps) #s(literal 1 binary64)) (exp.f64 (neg.f64 (*.f64 (+.f64 #s(literal 1 binary64) eps) x))))) Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6451.6
Applied rewrites51.6%
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.f6451.6
Applied rewrites51.6%
Final simplification83.0%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0)) (t_1 (- (/ 1.0 eps) 1.0)))
(if (<= eps 5.4e-10)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(if (<= eps 4.2e+70)
(/ (- (* (exp (* (+ -1.0 eps) x)) t_0) t_1) 2.0)
(if (<= eps 1.9e+281)
(/ (- t_0 (* (exp (* (- -1.0 eps) x)) t_1)) 2.0)
(/ (- (* (exp (* x eps)) t_0) t_1) 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 (eps <= 5.4e-10) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else if (eps <= 4.2e+70) {
tmp = ((exp(((-1.0 + eps) * x)) * t_0) - t_1) / 2.0;
} else if (eps <= 1.9e+281) {
tmp = (t_0 - (exp(((-1.0 - eps) * x)) * t_1)) / 2.0;
} else {
tmp = ((exp((x * eps)) * t_0) - t_1) / 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 (eps <= 5.4d-10) then
tmp = 0.5d0 * (((x + 1.0d0) / exp(x)) * 2.0d0)
else if (eps <= 4.2d+70) then
tmp = ((exp((((-1.0d0) + eps) * x)) * t_0) - t_1) / 2.0d0
else if (eps <= 1.9d+281) then
tmp = (t_0 - (exp((((-1.0d0) - eps) * x)) * t_1)) / 2.0d0
else
tmp = ((exp((x * eps)) * t_0) - t_1) / 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 (eps <= 5.4e-10) {
tmp = 0.5 * (((x + 1.0) / Math.exp(x)) * 2.0);
} else if (eps <= 4.2e+70) {
tmp = ((Math.exp(((-1.0 + eps) * x)) * t_0) - t_1) / 2.0;
} else if (eps <= 1.9e+281) {
tmp = (t_0 - (Math.exp(((-1.0 - eps) * x)) * t_1)) / 2.0;
} else {
tmp = ((Math.exp((x * eps)) * t_0) - t_1) / 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 eps <= 5.4e-10: tmp = 0.5 * (((x + 1.0) / math.exp(x)) * 2.0) elif eps <= 4.2e+70: tmp = ((math.exp(((-1.0 + eps) * x)) * t_0) - t_1) / 2.0 elif eps <= 1.9e+281: tmp = (t_0 - (math.exp(((-1.0 - eps) * x)) * t_1)) / 2.0 else: tmp = ((math.exp((x * eps)) * t_0) - t_1) / 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 (eps <= 5.4e-10) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); elseif (eps <= 4.2e+70) tmp = Float64(Float64(Float64(exp(Float64(Float64(-1.0 + eps) * x)) * t_0) - t_1) / 2.0); elseif (eps <= 1.9e+281) tmp = Float64(Float64(t_0 - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * t_1)) / 2.0); else tmp = Float64(Float64(Float64(exp(Float64(x * eps)) * t_0) - t_1) / 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 (eps <= 5.4e-10) tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0); elseif (eps <= 4.2e+70) tmp = ((exp(((-1.0 + eps) * x)) * t_0) - t_1) / 2.0; elseif (eps <= 1.9e+281) tmp = (t_0 - (exp(((-1.0 - eps) * x)) * t_1)) / 2.0; else tmp = ((exp((x * eps)) * t_0) - t_1) / 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[eps, 5.4e-10], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.2e+70], N[(N[(N[(N[Exp[N[(N[(-1.0 + eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - t$95$1), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[eps, 1.9e+281], N[(N[(t$95$0 - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - t$95$1), $MachinePrecision] / 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
t_1 := \frac{1}{\varepsilon} - 1\\
\mathbf{if}\;\varepsilon \leq 5.4 \cdot 10^{-10}:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{elif}\;\varepsilon \leq 4.2 \cdot 10^{+70}:\\
\;\;\;\;\frac{e^{\left(-1 + \varepsilon\right) \cdot x} \cdot t\_0 - t\_1}{2}\\
\mathbf{elif}\;\varepsilon \leq 1.9 \cdot 10^{+281}:\\
\;\;\;\;\frac{t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot t\_1}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{x \cdot \varepsilon} \cdot t\_0 - t\_1}{2}\\
\end{array}
\end{array}
if eps < 5.4e-10Initial program 60.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.1%
if 5.4e-10 < eps < 4.20000000000000015e70Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6481.8
Applied rewrites81.8%
if 4.20000000000000015e70 < eps < 1.90000000000000006e281Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6463.6
Applied rewrites63.6%
if 1.90000000000000006e281 < eps Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6461.2
Applied rewrites61.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6461.2
Applied rewrites61.2%
Final simplification73.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0))
(t_1 (- (/ 1.0 eps) 1.0))
(t_2 (/ (- (* (exp (* x eps)) t_0) t_1) 2.0)))
(if (<= eps 5.4e-10)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(if (<= eps 4.2e+70)
t_2
(if (<= eps 1.9e+281)
(/ (- t_0 (* (exp (* (- -1.0 eps) x)) t_1)) 2.0)
t_2)))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double t_1 = (1.0 / eps) - 1.0;
double t_2 = ((exp((x * eps)) * t_0) - t_1) / 2.0;
double tmp;
if (eps <= 5.4e-10) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else if (eps <= 4.2e+70) {
tmp = t_2;
} else if (eps <= 1.9e+281) {
tmp = (t_0 - (exp(((-1.0 - eps) * x)) * t_1)) / 2.0;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = (1.0d0 / eps) + 1.0d0
t_1 = (1.0d0 / eps) - 1.0d0
t_2 = ((exp((x * eps)) * t_0) - t_1) / 2.0d0
if (eps <= 5.4d-10) then
tmp = 0.5d0 * (((x + 1.0d0) / exp(x)) * 2.0d0)
else if (eps <= 4.2d+70) then
tmp = t_2
else if (eps <= 1.9d+281) then
tmp = (t_0 - (exp((((-1.0d0) - eps) * x)) * t_1)) / 2.0d0
else
tmp = t_2
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 t_2 = ((Math.exp((x * eps)) * t_0) - t_1) / 2.0;
double tmp;
if (eps <= 5.4e-10) {
tmp = 0.5 * (((x + 1.0) / Math.exp(x)) * 2.0);
} else if (eps <= 4.2e+70) {
tmp = t_2;
} else if (eps <= 1.9e+281) {
tmp = (t_0 - (Math.exp(((-1.0 - eps) * x)) * t_1)) / 2.0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, eps): t_0 = (1.0 / eps) + 1.0 t_1 = (1.0 / eps) - 1.0 t_2 = ((math.exp((x * eps)) * t_0) - t_1) / 2.0 tmp = 0 if eps <= 5.4e-10: tmp = 0.5 * (((x + 1.0) / math.exp(x)) * 2.0) elif eps <= 4.2e+70: tmp = t_2 elif eps <= 1.9e+281: tmp = (t_0 - (math.exp(((-1.0 - eps) * x)) * t_1)) / 2.0 else: tmp = t_2 return tmp
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) t_1 = Float64(Float64(1.0 / eps) - 1.0) t_2 = Float64(Float64(Float64(exp(Float64(x * eps)) * t_0) - t_1) / 2.0) tmp = 0.0 if (eps <= 5.4e-10) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); elseif (eps <= 4.2e+70) tmp = t_2; elseif (eps <= 1.9e+281) tmp = Float64(Float64(t_0 - Float64(exp(Float64(Float64(-1.0 - eps) * x)) * t_1)) / 2.0); else tmp = t_2; end return tmp end
function tmp_2 = code(x, eps) t_0 = (1.0 / eps) + 1.0; t_1 = (1.0 / eps) - 1.0; t_2 = ((exp((x * eps)) * t_0) - t_1) / 2.0; tmp = 0.0; if (eps <= 5.4e-10) tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0); elseif (eps <= 4.2e+70) tmp = t_2; elseif (eps <= 1.9e+281) tmp = (t_0 - (exp(((-1.0 - eps) * x)) * t_1)) / 2.0; else tmp = t_2; 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]}, Block[{t$95$2 = N[(N[(N[(N[Exp[N[(x * eps), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - t$95$1), $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[eps, 5.4e-10], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.2e+70], t$95$2, If[LessEqual[eps, 1.9e+281], N[(N[(t$95$0 - N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
t_1 := \frac{1}{\varepsilon} - 1\\
t_2 := \frac{e^{x \cdot \varepsilon} \cdot t\_0 - t\_1}{2}\\
\mathbf{if}\;\varepsilon \leq 5.4 \cdot 10^{-10}:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{elif}\;\varepsilon \leq 4.2 \cdot 10^{+70}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\varepsilon \leq 1.9 \cdot 10^{+281}:\\
\;\;\;\;\frac{t\_0 - e^{\left(-1 - \varepsilon\right) \cdot x} \cdot t\_1}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if eps < 5.4e-10Initial program 60.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.1%
if 5.4e-10 < eps < 4.20000000000000015e70 or 1.90000000000000006e281 < eps Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6476.9
Applied rewrites76.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6476.9
Applied rewrites76.9%
if 4.20000000000000015e70 < eps < 1.90000000000000006e281Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6463.6
Applied rewrites63.6%
Final simplification73.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (+ (/ 1.0 eps) 1.0))
(t_1 (/ (- (* (exp (* x eps)) t_0) (- (/ 1.0 eps) 1.0)) 2.0)))
(if (<= eps 5.4e-10)
(* 0.5 (* (/ (+ x 1.0) (exp x)) 2.0))
(if (<= eps 4.2e+70)
t_1
(if (<= eps 1.9e+281)
(/ (- t_0 (/ -1.0 (exp (fma x eps x)))) 2.0)
t_1)))))
double code(double x, double eps) {
double t_0 = (1.0 / eps) + 1.0;
double t_1 = ((exp((x * eps)) * t_0) - ((1.0 / eps) - 1.0)) / 2.0;
double tmp;
if (eps <= 5.4e-10) {
tmp = 0.5 * (((x + 1.0) / exp(x)) * 2.0);
} else if (eps <= 4.2e+70) {
tmp = t_1;
} else if (eps <= 1.9e+281) {
tmp = (t_0 - (-1.0 / exp(fma(x, eps, x)))) / 2.0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(1.0 / eps) + 1.0) t_1 = Float64(Float64(Float64(exp(Float64(x * eps)) * t_0) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0) tmp = 0.0 if (eps <= 5.4e-10) tmp = Float64(0.5 * Float64(Float64(Float64(x + 1.0) / exp(x)) * 2.0)); elseif (eps <= 4.2e+70) tmp = t_1; elseif (eps <= 1.9e+281) tmp = Float64(Float64(t_0 - Float64(-1.0 / exp(fma(x, eps, x)))) / 2.0); else tmp = t_1; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(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]}, If[LessEqual[eps, 5.4e-10], N[(0.5 * N[(N[(N[(x + 1.0), $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[eps, 4.2e+70], t$95$1, If[LessEqual[eps, 1.9e+281], N[(N[(t$95$0 - N[(-1.0 / N[Exp[N[(x * eps + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\varepsilon} + 1\\
t_1 := \frac{e^{x \cdot \varepsilon} \cdot t\_0 - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\mathbf{if}\;\varepsilon \leq 5.4 \cdot 10^{-10}:\\
\;\;\;\;0.5 \cdot \left(\frac{x + 1}{e^{x}} \cdot 2\right)\\
\mathbf{elif}\;\varepsilon \leq 4.2 \cdot 10^{+70}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\varepsilon \leq 1.9 \cdot 10^{+281}:\\
\;\;\;\;\frac{t\_0 - \frac{-1}{e^{\mathsf{fma}\left(x, \varepsilon, x\right)}}}{2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eps < 5.4e-10Initial program 60.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.1%
if 5.4e-10 < eps < 4.20000000000000015e70 or 1.90000000000000006e281 < eps Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6476.9
Applied rewrites76.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f6476.9
Applied rewrites76.9%
if 4.20000000000000015e70 < eps < 1.90000000000000006e281Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6463.6
Applied rewrites63.6%
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.f6463.6
Applied rewrites63.6%
Final simplification73.8%
(FPCore (x eps) :precision binary64 (* (exp (- x)) 1.0))
double code(double x, double eps) {
return exp(-x) * 1.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = exp(-x) * 1.0d0
end function
public static double code(double x, double eps) {
return Math.exp(-x) * 1.0;
}
def code(x, eps): return math.exp(-x) * 1.0
function code(x, eps) return Float64(exp(Float64(-x)) * 1.0) end
function tmp = code(x, eps) tmp = exp(-x) * 1.0; end
code[x_, eps_] := N[(N[Exp[(-x)], $MachinePrecision] * 1.0), $MachinePrecision]
\begin{array}{l}
\\
e^{-x} \cdot 1
\end{array}
Initial program 69.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites65.3%
Applied rewrites65.3%
Taylor expanded in x around 0
Applied rewrites77.4%
Final simplification77.4%
(FPCore (x eps) :precision binary64 (if (<= x 9.2e-7) (* (fma (fma (fma -0.16666666666666666 x 0.5) x -1.0) x 1.0) 1.0) (/ (- (+ (/ 1.0 eps) 1.0) (- (/ 1.0 eps) 1.0)) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 9.2e-7) {
tmp = fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0;
} else {
tmp = (((1.0 / eps) + 1.0) - ((1.0 / eps) - 1.0)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 9.2e-7) tmp = Float64(fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0); else tmp = Float64(Float64(Float64(Float64(1.0 / eps) + 1.0) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 9.2e-7], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[(N[(1.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.2 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{1}{\varepsilon} + 1\right) - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\end{array}
\end{array}
if x < 9.1999999999999998e-7Initial program 56.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.3%
Applied rewrites70.3%
Taylor expanded in x around 0
Applied rewrites87.2%
Taylor expanded in x around 0
Applied rewrites81.5%
if 9.1999999999999998e-7 < x Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6427.9
Applied rewrites27.9%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6452.2
Applied rewrites52.2%
Final simplification73.2%
(FPCore (x eps) :precision binary64 (if (<= x 1.6) (* (fma (fma (fma -0.16666666666666666 x 0.5) x -1.0) x 1.0) 1.0) (/ (- (/ 1.0 eps) (- (/ 1.0 eps) 1.0)) 2.0)))
double code(double x, double eps) {
double tmp;
if (x <= 1.6) {
tmp = fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0;
} else {
tmp = ((1.0 / eps) - ((1.0 / eps) - 1.0)) / 2.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 1.6) tmp = Float64(fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0); else tmp = Float64(Float64(Float64(1.0 / eps) - Float64(Float64(1.0 / eps) - 1.0)) / 2.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, 1.6], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[(1.0 / eps), $MachinePrecision] - N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.6:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\varepsilon} - \left(\frac{1}{\varepsilon} - 1\right)}{2}\\
\end{array}
\end{array}
if x < 1.6000000000000001Initial program 56.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites69.9%
Applied rewrites69.9%
Taylor expanded in x around 0
Applied rewrites86.8%
Taylor expanded in x around 0
Applied rewrites81.1%
if 1.6000000000000001 < x Initial program 100.0%
Taylor expanded in x around 0
lower--.f64N/A
lower-/.f6424.2
Applied rewrites24.2%
Taylor expanded in eps around 0
lower-/.f64N/A
neg-mul-1N/A
lower-exp.f64N/A
neg-mul-1N/A
lower-neg.f642.7
Applied rewrites2.7%
Taylor expanded in x around 0
Applied rewrites52.9%
Final simplification73.2%
(FPCore (x eps) :precision binary64 (if (<= eps 5.4e-10) (/ (+ x 1.0) (fma (fma 0.5 x 1.0) x 1.0)) (* (fma (fma 0.5 x -1.0) x 1.0) 1.0)))
double code(double x, double eps) {
double tmp;
if (eps <= 5.4e-10) {
tmp = (x + 1.0) / fma(fma(0.5, x, 1.0), x, 1.0);
} else {
tmp = fma(fma(0.5, x, -1.0), x, 1.0) * 1.0;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (eps <= 5.4e-10) tmp = Float64(Float64(x + 1.0) / fma(fma(0.5, x, 1.0), x, 1.0)); else tmp = Float64(fma(fma(0.5, x, -1.0), x, 1.0) * 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[eps, 5.4e-10], N[(N[(x + 1.0), $MachinePrecision] / N[(N[(0.5 * x + 1.0), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq 5.4 \cdot 10^{-10}:\\
\;\;\;\;\frac{x + 1}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot 1\\
\end{array}
\end{array}
if eps < 5.4e-10Initial program 60.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.1%
Taylor expanded in x around 0
Applied rewrites65.9%
Applied rewrites65.9%
if 5.4e-10 < eps Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites28.6%
Applied rewrites28.6%
Taylor expanded in x around 0
Applied rewrites60.1%
Taylor expanded in x around 0
Applied rewrites61.4%
Final simplification64.9%
(FPCore (x eps) :precision binary64 (if (<= x -1400.0) (* (fma (fma (fma -0.16666666666666666 x 0.5) x -1.0) x 1.0) 1.0) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -1400.0) {
tmp = fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1400.0) tmp = Float64(fma(fma(fma(-0.16666666666666666, x, 0.5), x, -1.0), x, 1.0) * 1.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1400.0], N[(N[(N[(N[(-0.16666666666666666 * x + 0.5), $MachinePrecision] * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1400:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, x, 0.5\right), x, -1\right), x, 1\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -1400Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.0%
Applied rewrites0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites68.3%
if -1400 < x Initial program 64.4%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.0%
Taylor expanded in x around 0
Applied rewrites68.9%
Final simplification68.8%
(FPCore (x eps) :precision binary64 (if (<= x -1400.0) (* (fma (fma 0.5 x -1.0) x 1.0) 1.0) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))
double code(double x, double eps) {
double tmp;
if (x <= -1400.0) {
tmp = fma(fma(0.5, x, -1.0), x, 1.0) * 1.0;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1400.0) tmp = Float64(fma(fma(0.5, x, -1.0), x, 1.0) * 1.0); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1400.0], N[(N[(N[(0.5 * x + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1400:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, -1\right), x, 1\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)\\
\end{array}
\end{array}
if x < -1400Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites0.0%
Applied rewrites0.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites48.7%
if -1400 < x Initial program 64.4%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.0%
Taylor expanded in x around 0
Applied rewrites68.9%
Final simplification66.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 69.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites65.3%
Taylor expanded in x around 0
Applied rewrites60.0%
(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 69.0%
Taylor expanded in x around 0
Applied rewrites51.1%
herbie shell --seed 2024276
(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))