
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))
double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((1.0d0 + (1.0d0 / eps)) * exp(-((1.0d0 - eps) * x))) - (((1.0d0 / eps) - 1.0d0) * exp(-((1.0d0 + eps) * x)))) / 2.0d0
end function
public static double code(double x, double eps) {
return (((1.0 + (1.0 / eps)) * Math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * Math.exp(-((1.0 + eps) * x)))) / 2.0;
}
def code(x, eps): return (((1.0 + (1.0 / eps)) * math.exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * math.exp(-((1.0 + eps) * x)))) / 2.0
function code(x, eps) return Float64(Float64(Float64(Float64(1.0 + Float64(1.0 / eps)) * exp(Float64(-Float64(Float64(1.0 - eps) * x)))) - Float64(Float64(Float64(1.0 / eps) - 1.0) * exp(Float64(-Float64(Float64(1.0 + eps) * x))))) / 2.0) end
function tmp = code(x, eps) tmp = (((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0; end
code[x_, eps_] := N[(N[(N[(N[(1.0 + N[(1.0 / eps), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[(1.0 - eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(1.0 / eps), $MachinePrecision] - 1.0), $MachinePrecision] * N[Exp[(-N[(N[(1.0 + eps), $MachinePrecision] * x), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}
\end{array}
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 1.4e-8)
(* 0.5 (* (+ (+ 2.0 x) x) (exp (- x))))
(/
(-
(* (exp (* (- eps_m 1.0) x)) (+ (/ 1.0 eps_m) 1.0))
(* (exp (* (- -1.0 eps_m) x)) (- (/ 1.0 eps_m) 1.0)))
2.0)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.4e-8) {
tmp = 0.5 * (((2.0 + x) + x) * exp(-x));
} else {
tmp = ((exp(((eps_m - 1.0) * x)) * ((1.0 / eps_m) + 1.0)) - (exp(((-1.0 - eps_m) * x)) * ((1.0 / eps_m) - 1.0))) / 2.0;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 1.4d-8) then
tmp = 0.5d0 * (((2.0d0 + x) + x) * exp(-x))
else
tmp = ((exp(((eps_m - 1.0d0) * x)) * ((1.0d0 / eps_m) + 1.0d0)) - (exp((((-1.0d0) - eps_m) * x)) * ((1.0d0 / eps_m) - 1.0d0))) / 2.0d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.4e-8) {
tmp = 0.5 * (((2.0 + x) + x) * Math.exp(-x));
} else {
tmp = ((Math.exp(((eps_m - 1.0) * x)) * ((1.0 / eps_m) + 1.0)) - (Math.exp(((-1.0 - eps_m) * x)) * ((1.0 / eps_m) - 1.0))) / 2.0;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.4e-8: tmp = 0.5 * (((2.0 + x) + x) * math.exp(-x)) else: tmp = ((math.exp(((eps_m - 1.0) * x)) * ((1.0 / eps_m) + 1.0)) - (math.exp(((-1.0 - eps_m) * x)) * ((1.0 / eps_m) - 1.0))) / 2.0 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.4e-8) tmp = Float64(0.5 * Float64(Float64(Float64(2.0 + x) + x) * exp(Float64(-x)))); else tmp = Float64(Float64(Float64(exp(Float64(Float64(eps_m - 1.0) * x)) * Float64(Float64(1.0 / eps_m) + 1.0)) - Float64(exp(Float64(Float64(-1.0 - eps_m) * x)) * Float64(Float64(1.0 / eps_m) - 1.0))) / 2.0); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 1.4e-8) tmp = 0.5 * (((2.0 + x) + x) * exp(-x)); else tmp = ((exp(((eps_m - 1.0) * x)) * ((1.0 / eps_m) + 1.0)) - (exp(((-1.0 - eps_m) * x)) * ((1.0 / eps_m) - 1.0))) / 2.0; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.4e-8], N[(0.5 * N[(N[(N[(2.0 + x), $MachinePrecision] + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1.4 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\left(\left(2 + x\right) + x\right) \cdot e^{-x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\left(eps\_m - 1\right) \cdot x} \cdot \left(\frac{1}{eps\_m} + 1\right) - e^{\left(-1 - eps\_m\right) \cdot x} \cdot \left(\frac{1}{eps\_m} - 1\right)}{2}\\
\end{array}
\end{array}
if eps < 1.4e-8Initial program 68.5%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites69.5%
if 1.4e-8 < eps Initial program 100.0%
Final simplification77.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(let* ((t_0 (- (/ 1.0 eps_m) 1.0))
(t_1 (- (/ (- eps_m 1.0) eps_m) (- 1.0 eps_m))))
(if (<=
(-
(* (exp (* (- eps_m 1.0) x)) (+ (/ 1.0 eps_m) 1.0))
(* (exp (* (- -1.0 eps_m) x)) t_0))
1e+39)
(* 0.5 (* (+ (+ 2.0 x) x) (exp (- x))))
(fma
(* 0.5 x)
(fma
(*
(fma
(- -1.0 eps_m)
(- (+ (/ (+ 1.0 eps_m) eps_m) -1.0) eps_m)
(* t_1 (- eps_m 1.0)))
0.5)
x
(fma t_0 (+ 1.0 eps_m) t_1))
1.0))))eps_m = fabs(eps);
double code(double x, double eps_m) {
double t_0 = (1.0 / eps_m) - 1.0;
double t_1 = ((eps_m - 1.0) / eps_m) - (1.0 - eps_m);
double tmp;
if (((exp(((eps_m - 1.0) * x)) * ((1.0 / eps_m) + 1.0)) - (exp(((-1.0 - eps_m) * x)) * t_0)) <= 1e+39) {
tmp = 0.5 * (((2.0 + x) + x) * exp(-x));
} else {
tmp = fma((0.5 * x), fma((fma((-1.0 - eps_m), ((((1.0 + eps_m) / eps_m) + -1.0) - eps_m), (t_1 * (eps_m - 1.0))) * 0.5), x, fma(t_0, (1.0 + eps_m), t_1)), 1.0);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) t_0 = Float64(Float64(1.0 / eps_m) - 1.0) t_1 = Float64(Float64(Float64(eps_m - 1.0) / eps_m) - Float64(1.0 - eps_m)) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps_m - 1.0) * x)) * Float64(Float64(1.0 / eps_m) + 1.0)) - Float64(exp(Float64(Float64(-1.0 - eps_m) * x)) * t_0)) <= 1e+39) tmp = Float64(0.5 * Float64(Float64(Float64(2.0 + x) + x) * exp(Float64(-x)))); else tmp = fma(Float64(0.5 * x), fma(Float64(fma(Float64(-1.0 - eps_m), Float64(Float64(Float64(Float64(1.0 + eps_m) / eps_m) + -1.0) - eps_m), Float64(t_1 * Float64(eps_m - 1.0))) * 0.5), x, fma(t_0, Float64(1.0 + eps_m), t_1)), 1.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision]
code[x_, eps$95$m_] := Block[{t$95$0 = N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(eps$95$m - 1.0), $MachinePrecision] / eps$95$m), $MachinePrecision] - N[(1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 1e+39], N[(0.5 * N[(N[(N[(2.0 + x), $MachinePrecision] + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * N[(N[(N[(N[(-1.0 - eps$95$m), $MachinePrecision] * N[(N[(N[(N[(1.0 + eps$95$m), $MachinePrecision] / eps$95$m), $MachinePrecision] + -1.0), $MachinePrecision] - eps$95$m), $MachinePrecision] + N[(t$95$1 * N[(eps$95$m - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * x + N[(t$95$0 * N[(1.0 + eps$95$m), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]]]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
t_0 := \frac{1}{eps\_m} - 1\\
t_1 := \frac{eps\_m - 1}{eps\_m} - \left(1 - eps\_m\right)\\
\mathbf{if}\;e^{\left(eps\_m - 1\right) \cdot x} \cdot \left(\frac{1}{eps\_m} + 1\right) - e^{\left(-1 - eps\_m\right) \cdot x} \cdot t\_0 \leq 10^{+39}:\\
\;\;\;\;0.5 \cdot \left(\left(\left(2 + x\right) + x\right) \cdot e^{-x}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.5 \cdot x, \mathsf{fma}\left(\mathsf{fma}\left(-1 - eps\_m, \left(\frac{1 + eps\_m}{eps\_m} + -1\right) - eps\_m, t\_1 \cdot \left(eps\_m - 1\right)\right) \cdot 0.5, x, \mathsf{fma}\left(t\_0, 1 + eps\_m, t\_1\right)\right), 1\right)\\
\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))))) < 9.9999999999999994e38Initial program 59.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.6%
if 9.9999999999999994e38 < (-.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.1%
Taylor expanded in x around 0
Applied rewrites83.8%
Final simplification92.1%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<=
(-
(* (exp (* (- eps_m 1.0) x)) (+ (/ 1.0 eps_m) 1.0))
(* (exp (* (- -1.0 eps_m) x)) (- (/ 1.0 eps_m) 1.0)))
1e+39)
(* 0.5 (* (+ (+ 2.0 x) x) (exp (- x))))
(*
(fma
(fma
(fma (- eps_m 1.0) (- eps_m 1.0) (* (- -1.0 eps_m) (- -1.0 eps_m)))
(* 0.5 x)
-2.0)
x
2.0)
0.5)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (((exp(((eps_m - 1.0) * x)) * ((1.0 / eps_m) + 1.0)) - (exp(((-1.0 - eps_m) * x)) * ((1.0 / eps_m) - 1.0))) <= 1e+39) {
tmp = 0.5 * (((2.0 + x) + x) * exp(-x));
} else {
tmp = fma(fma(fma((eps_m - 1.0), (eps_m - 1.0), ((-1.0 - eps_m) * (-1.0 - eps_m))), (0.5 * x), -2.0), x, 2.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps_m - 1.0) * x)) * Float64(Float64(1.0 / eps_m) + 1.0)) - Float64(exp(Float64(Float64(-1.0 - eps_m) * x)) * Float64(Float64(1.0 / eps_m) - 1.0))) <= 1e+39) tmp = Float64(0.5 * Float64(Float64(Float64(2.0 + x) + x) * exp(Float64(-x)))); else tmp = Float64(fma(fma(fma(Float64(eps_m - 1.0), Float64(eps_m - 1.0), Float64(Float64(-1.0 - eps_m) * Float64(-1.0 - eps_m))), Float64(0.5 * x), -2.0), x, 2.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[N[(N[(N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+39], N[(0.5 * N[(N[(N[(2.0 + x), $MachinePrecision] + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(eps$95$m - 1.0), $MachinePrecision] * N[(eps$95$m - 1.0), $MachinePrecision] + N[(N[(-1.0 - eps$95$m), $MachinePrecision] * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * x), $MachinePrecision] + -2.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;e^{\left(eps\_m - 1\right) \cdot x} \cdot \left(\frac{1}{eps\_m} + 1\right) - e^{\left(-1 - eps\_m\right) \cdot x} \cdot \left(\frac{1}{eps\_m} - 1\right) \leq 10^{+39}:\\
\;\;\;\;0.5 \cdot \left(\left(\left(2 + x\right) + x\right) \cdot e^{-x}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(eps\_m - 1, eps\_m - 1, \left(-1 - eps\_m\right) \cdot \left(-1 - eps\_m\right)\right), 0.5 \cdot x, -2\right), x, 2\right) \cdot 0.5\\
\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))))) < 9.9999999999999994e38Initial program 59.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.6%
if 9.9999999999999994e38 < (-.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.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites19.0%
Taylor expanded in x around 0
Applied rewrites83.8%
Final simplification92.1%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<=
(-
(* (exp (* (- eps_m 1.0) x)) (+ (/ 1.0 eps_m) 1.0))
(* (exp (* (- -1.0 eps_m) x)) (- (/ 1.0 eps_m) 1.0)))
1e+39)
(exp (- x))
(*
(fma
(fma
(fma (- eps_m 1.0) (- eps_m 1.0) (* (- -1.0 eps_m) (- -1.0 eps_m)))
(* 0.5 x)
-2.0)
x
2.0)
0.5)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (((exp(((eps_m - 1.0) * x)) * ((1.0 / eps_m) + 1.0)) - (exp(((-1.0 - eps_m) * x)) * ((1.0 / eps_m) - 1.0))) <= 1e+39) {
tmp = exp(-x);
} else {
tmp = fma(fma(fma((eps_m - 1.0), (eps_m - 1.0), ((-1.0 - eps_m) * (-1.0 - eps_m))), (0.5 * x), -2.0), x, 2.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (Float64(Float64(exp(Float64(Float64(eps_m - 1.0) * x)) * Float64(Float64(1.0 / eps_m) + 1.0)) - Float64(exp(Float64(Float64(-1.0 - eps_m) * x)) * Float64(Float64(1.0 / eps_m) - 1.0))) <= 1e+39) tmp = exp(Float64(-x)); else tmp = Float64(fma(fma(fma(Float64(eps_m - 1.0), Float64(eps_m - 1.0), Float64(Float64(-1.0 - eps_m) * Float64(-1.0 - eps_m))), Float64(0.5 * x), -2.0), x, 2.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[N[(N[(N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[Exp[N[(N[(-1.0 - eps$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+39], N[Exp[(-x)], $MachinePrecision], N[(N[(N[(N[(N[(eps$95$m - 1.0), $MachinePrecision] * N[(eps$95$m - 1.0), $MachinePrecision] + N[(N[(-1.0 - eps$95$m), $MachinePrecision] * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * x), $MachinePrecision] + -2.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;e^{\left(eps\_m - 1\right) \cdot x} \cdot \left(\frac{1}{eps\_m} + 1\right) - e^{\left(-1 - eps\_m\right) \cdot x} \cdot \left(\frac{1}{eps\_m} - 1\right) \leq 10^{+39}:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(eps\_m - 1, eps\_m - 1, \left(-1 - eps\_m\right) \cdot \left(-1 - eps\_m\right)\right), 0.5 \cdot x, -2\right), x, 2\right) \cdot 0.5\\
\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))))) < 9.9999999999999994e38Initial program 59.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.1%
Taylor expanded in eps around 0
Applied rewrites95.8%
if 9.9999999999999994e38 < (-.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.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.1%
Taylor expanded in x around 0
Applied rewrites19.0%
Taylor expanded in x around 0
Applied rewrites83.8%
Final simplification90.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 1.4e-8) (* 0.5 (* (+ (+ 2.0 x) x) (exp (- x)))) (* (+ (exp (* (- eps_m 1.0) x)) (exp (* (- -1.0 eps_m) x))) 0.5)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.4e-8) {
tmp = 0.5 * (((2.0 + x) + x) * exp(-x));
} else {
tmp = (exp(((eps_m - 1.0) * x)) + exp(((-1.0 - eps_m) * x))) * 0.5;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 1.4d-8) then
tmp = 0.5d0 * (((2.0d0 + x) + x) * exp(-x))
else
tmp = (exp(((eps_m - 1.0d0) * x)) + exp((((-1.0d0) - eps_m) * x))) * 0.5d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.4e-8) {
tmp = 0.5 * (((2.0 + x) + x) * Math.exp(-x));
} else {
tmp = (Math.exp(((eps_m - 1.0) * x)) + Math.exp(((-1.0 - eps_m) * x))) * 0.5;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.4e-8: tmp = 0.5 * (((2.0 + x) + x) * math.exp(-x)) else: tmp = (math.exp(((eps_m - 1.0) * x)) + math.exp(((-1.0 - eps_m) * x))) * 0.5 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.4e-8) tmp = Float64(0.5 * Float64(Float64(Float64(2.0 + x) + x) * exp(Float64(-x)))); else tmp = Float64(Float64(exp(Float64(Float64(eps_m - 1.0) * x)) + exp(Float64(Float64(-1.0 - eps_m) * x))) * 0.5); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 1.4e-8) tmp = 0.5 * (((2.0 + x) + x) * exp(-x)); else tmp = (exp(((eps_m - 1.0) * x)) + exp(((-1.0 - eps_m) * x))) * 0.5; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.4e-8], N[(0.5 * N[(N[(N[(2.0 + x), $MachinePrecision] + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(N[(-1.0 - eps$95$m), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1.4 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\left(\left(2 + x\right) + x\right) \cdot e^{-x}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{\left(eps\_m - 1\right) \cdot x} + e^{\left(-1 - eps\_m\right) \cdot x}\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 1.4e-8Initial program 68.5%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites69.5%
if 1.4e-8 < eps Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Final simplification77.6%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= eps_m 1.4e-8) (* 0.5 (* (+ (+ 2.0 x) x) (exp (- x)))) (* (+ (exp (* (- x) eps_m)) (exp (* (- eps_m 1.0) x))) 0.5)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.4e-8) {
tmp = 0.5 * (((2.0 + x) + x) * exp(-x));
} else {
tmp = (exp((-x * eps_m)) + exp(((eps_m - 1.0) * x))) * 0.5;
}
return tmp;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
real(8) :: tmp
if (eps_m <= 1.4d-8) then
tmp = 0.5d0 * (((2.0d0 + x) + x) * exp(-x))
else
tmp = (exp((-x * eps_m)) + exp(((eps_m - 1.0d0) * x))) * 0.5d0
end if
code = tmp
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
double tmp;
if (eps_m <= 1.4e-8) {
tmp = 0.5 * (((2.0 + x) + x) * Math.exp(-x));
} else {
tmp = (Math.exp((-x * eps_m)) + Math.exp(((eps_m - 1.0) * x))) * 0.5;
}
return tmp;
}
eps_m = math.fabs(eps) def code(x, eps_m): tmp = 0 if eps_m <= 1.4e-8: tmp = 0.5 * (((2.0 + x) + x) * math.exp(-x)) else: tmp = (math.exp((-x * eps_m)) + math.exp(((eps_m - 1.0) * x))) * 0.5 return tmp
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 1.4e-8) tmp = Float64(0.5 * Float64(Float64(Float64(2.0 + x) + x) * exp(Float64(-x)))); else tmp = Float64(Float64(exp(Float64(Float64(-x) * eps_m)) + exp(Float64(Float64(eps_m - 1.0) * x))) * 0.5); end return tmp end
eps_m = abs(eps); function tmp_2 = code(x, eps_m) tmp = 0.0; if (eps_m <= 1.4e-8) tmp = 0.5 * (((2.0 + x) + x) * exp(-x)); else tmp = (exp((-x * eps_m)) + exp(((eps_m - 1.0) * x))) * 0.5; end tmp_2 = tmp; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 1.4e-8], N[(0.5 * N[(N[(N[(2.0 + x), $MachinePrecision] + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[N[((-x) * eps$95$m), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 1.4 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\left(\left(2 + x\right) + x\right) \cdot e^{-x}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{\left(-x\right) \cdot eps\_m} + e^{\left(eps\_m - 1\right) \cdot x}\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 1.4e-8Initial program 68.5%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites69.5%
if 1.4e-8 < eps Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in eps around inf
Applied rewrites100.0%
Final simplification77.6%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 0.0152)
(* 0.5 (* (+ (+ 2.0 x) x) (exp (- x))))
(/
(-
(* (exp (* (- eps_m 1.0) x)) (+ (/ 1.0 eps_m) 1.0))
(*
(fma (* (fma (* 0.5 x) (+ 1.0 eps_m) -1.0) (+ 1.0 eps_m)) x 1.0)
(- (/ 1.0 eps_m) 1.0)))
2.0)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.0152) {
tmp = 0.5 * (((2.0 + x) + x) * exp(-x));
} else {
tmp = ((exp(((eps_m - 1.0) * x)) * ((1.0 / eps_m) + 1.0)) - (fma((fma((0.5 * x), (1.0 + eps_m), -1.0) * (1.0 + eps_m)), x, 1.0) * ((1.0 / eps_m) - 1.0))) / 2.0;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 0.0152) tmp = Float64(0.5 * Float64(Float64(Float64(2.0 + x) + x) * exp(Float64(-x)))); else tmp = Float64(Float64(Float64(exp(Float64(Float64(eps_m - 1.0) * x)) * Float64(Float64(1.0 / eps_m) + 1.0)) - Float64(fma(Float64(fma(Float64(0.5 * x), Float64(1.0 + eps_m), -1.0) * Float64(1.0 + eps_m)), x, 1.0) * Float64(Float64(1.0 / eps_m) - 1.0))) / 2.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 0.0152], N[(0.5 * N[(N[(N[(2.0 + x), $MachinePrecision] + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] * N[(N[(1.0 / eps$95$m), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(N[(0.5 * x), $MachinePrecision] * N[(1.0 + eps$95$m), $MachinePrecision] + -1.0), $MachinePrecision] * N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(N[(1.0 / eps$95$m), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 0.0152:\\
\;\;\;\;0.5 \cdot \left(\left(\left(2 + x\right) + x\right) \cdot e^{-x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\left(eps\_m - 1\right) \cdot x} \cdot \left(\frac{1}{eps\_m} + 1\right) - \mathsf{fma}\left(\mathsf{fma}\left(0.5 \cdot x, 1 + eps\_m, -1\right) \cdot \left(1 + eps\_m\right), x, 1\right) \cdot \left(\frac{1}{eps\_m} - 1\right)}{2}\\
\end{array}
\end{array}
if eps < 0.0152Initial program 68.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites69.8%
if 0.0152 < eps Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
unpow2N/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-+.f6490.3
Applied rewrites90.3%
Final simplification75.1%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= eps_m 0.0152)
(* 0.5 (* (+ (+ 2.0 x) x) (exp (- x))))
(*
(+
(fma (fma (* (fma eps_m x x) (+ 1.0 eps_m)) 0.5 (- -1.0 eps_m)) x 1.0)
(exp (* (- eps_m 1.0) x)))
0.5)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (eps_m <= 0.0152) {
tmp = 0.5 * (((2.0 + x) + x) * exp(-x));
} else {
tmp = (fma(fma((fma(eps_m, x, x) * (1.0 + eps_m)), 0.5, (-1.0 - eps_m)), x, 1.0) + exp(((eps_m - 1.0) * x))) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (eps_m <= 0.0152) tmp = Float64(0.5 * Float64(Float64(Float64(2.0 + x) + x) * exp(Float64(-x)))); else tmp = Float64(Float64(fma(fma(Float64(fma(eps_m, x, x) * Float64(1.0 + eps_m)), 0.5, Float64(-1.0 - eps_m)), x, 1.0) + exp(Float64(Float64(eps_m - 1.0) * x))) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[eps$95$m, 0.0152], N[(0.5 * N[(N[(N[(2.0 + x), $MachinePrecision] + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(eps$95$m * x + x), $MachinePrecision] * N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] + N[Exp[N[(N[(eps$95$m - 1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;eps\_m \leq 0.0152:\\
\;\;\;\;0.5 \cdot \left(\left(\left(2 + x\right) + x\right) \cdot e^{-x}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(eps\_m, x, x\right) \cdot \left(1 + eps\_m\right), 0.5, -1 - eps\_m\right), x, 1\right) + e^{\left(eps\_m - 1\right) \cdot x}\right) \cdot 0.5\\
\end{array}
\end{array}
if eps < 0.0152Initial program 68.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites69.8%
if 0.0152 < eps Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites90.3%
Final simplification75.1%
eps_m = (fabs.f64 eps)
(FPCore (x eps_m)
:precision binary64
(if (<= x 9.4e-172)
(* (fma (* (* (* (- 1.0 x) x) eps_m) eps_m) x 2.0) 0.5)
(*
(fma
(-
(fma
(fma
(fma (- 1.0 eps_m) (- 1.0 eps_m) (* (- -1.0 eps_m) (- -1.0 eps_m)))
0.5
(*
(fma
(* 0.16666666666666666 (- eps_m 1.0))
(* (- eps_m 1.0) (- eps_m 1.0))
(* 1.0 (* -0.16666666666666666 (+ 1.0 eps_m))))
x))
x
(- (- eps_m 1.0) eps_m))
1.0)
x
2.0)
0.5)))eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 9.4e-172) {
tmp = fma(((((1.0 - x) * x) * eps_m) * eps_m), x, 2.0) * 0.5;
} else {
tmp = fma((fma(fma(fma((1.0 - eps_m), (1.0 - eps_m), ((-1.0 - eps_m) * (-1.0 - eps_m))), 0.5, (fma((0.16666666666666666 * (eps_m - 1.0)), ((eps_m - 1.0) * (eps_m - 1.0)), (1.0 * (-0.16666666666666666 * (1.0 + eps_m)))) * x)), x, ((eps_m - 1.0) - eps_m)) - 1.0), x, 2.0) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 9.4e-172) tmp = Float64(fma(Float64(Float64(Float64(Float64(1.0 - x) * x) * eps_m) * eps_m), x, 2.0) * 0.5); else tmp = Float64(fma(Float64(fma(fma(fma(Float64(1.0 - eps_m), Float64(1.0 - eps_m), Float64(Float64(-1.0 - eps_m) * Float64(-1.0 - eps_m))), 0.5, Float64(fma(Float64(0.16666666666666666 * Float64(eps_m - 1.0)), Float64(Float64(eps_m - 1.0) * Float64(eps_m - 1.0)), Float64(1.0 * Float64(-0.16666666666666666 * Float64(1.0 + eps_m)))) * x)), x, Float64(Float64(eps_m - 1.0) - eps_m)) - 1.0), x, 2.0) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 9.4e-172], N[(N[(N[(N[(N[(N[(1.0 - x), $MachinePrecision] * x), $MachinePrecision] * eps$95$m), $MachinePrecision] * eps$95$m), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(1.0 - eps$95$m), $MachinePrecision] * N[(1.0 - eps$95$m), $MachinePrecision] + N[(N[(-1.0 - eps$95$m), $MachinePrecision] * N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(N[(0.16666666666666666 * N[(eps$95$m - 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(eps$95$m - 1.0), $MachinePrecision] * N[(eps$95$m - 1.0), $MachinePrecision]), $MachinePrecision] + N[(1.0 * N[(-0.16666666666666666 * N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * x + N[(N[(eps$95$m - 1.0), $MachinePrecision] - eps$95$m), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.4 \cdot 10^{-172}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(1 - x\right) \cdot x\right) \cdot eps\_m\right) \cdot eps\_m, x, 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(1 - eps\_m, 1 - eps\_m, \left(-1 - eps\_m\right) \cdot \left(-1 - eps\_m\right)\right), 0.5, \mathsf{fma}\left(0.16666666666666666 \cdot \left(eps\_m - 1\right), \left(eps\_m - 1\right) \cdot \left(eps\_m - 1\right), 1 \cdot \left(-0.16666666666666666 \cdot \left(1 + eps\_m\right)\right)\right) \cdot x\right), x, \left(eps\_m - 1\right) - eps\_m\right) - 1, x, 2\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 9.39999999999999952e-172Initial program 70.1%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.7%
Taylor expanded in x around 0
Applied rewrites53.4%
Taylor expanded in eps around inf
Applied rewrites89.1%
if 9.39999999999999952e-172 < x Initial program 85.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.4%
Taylor expanded in x around 0
Applied rewrites27.1%
Taylor expanded in eps around 0
Applied rewrites43.4%
Final simplification69.4%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (* (+ 1.0 (fma (fma (* (fma eps_m x x) (+ 1.0 eps_m)) 0.5 (- -1.0 eps_m)) x 1.0)) 0.5))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return (1.0 + fma(fma((fma(eps_m, x, x) * (1.0 + eps_m)), 0.5, (-1.0 - eps_m)), x, 1.0)) * 0.5;
}
eps_m = abs(eps) function code(x, eps_m) return Float64(Float64(1.0 + fma(fma(Float64(fma(eps_m, x, x) * Float64(1.0 + eps_m)), 0.5, Float64(-1.0 - eps_m)), x, 1.0)) * 0.5) end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(1.0 + N[(N[(N[(N[(eps$95$m * x + x), $MachinePrecision] * N[(1.0 + eps$95$m), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(-1.0 - eps$95$m), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\left(1 + \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(eps\_m, x, x\right) \cdot \left(1 + eps\_m\right), 0.5, -1 - eps\_m\right), x, 1\right)\right) \cdot 0.5
\end{array}
Initial program 76.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites60.4%
Taylor expanded in x around 0
Applied rewrites75.1%
Final simplification75.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x 1.32e+20) (* (fma (* (* (* (- 1.0 x) x) eps_m) eps_m) x 2.0) 0.5) (* (* (fma (fma x 0.5 -1.0) x 1.0) (+ (+ 2.0 x) x)) 0.5)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= 1.32e+20) {
tmp = fma(((((1.0 - x) * x) * eps_m) * eps_m), x, 2.0) * 0.5;
} else {
tmp = (fma(fma(x, 0.5, -1.0), x, 1.0) * ((2.0 + x) + x)) * 0.5;
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= 1.32e+20) tmp = Float64(fma(Float64(Float64(Float64(Float64(1.0 - x) * x) * eps_m) * eps_m), x, 2.0) * 0.5); else tmp = Float64(Float64(fma(fma(x, 0.5, -1.0), x, 1.0) * Float64(Float64(2.0 + x) + x)) * 0.5); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, 1.32e+20], N[(N[(N[(N[(N[(N[(1.0 - x), $MachinePrecision] * x), $MachinePrecision] * eps$95$m), $MachinePrecision] * eps$95$m), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(x * 0.5 + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * N[(N[(2.0 + x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.32 \cdot 10^{+20}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\left(1 - x\right) \cdot x\right) \cdot eps\_m\right) \cdot eps\_m, x, 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), x, 1\right) \cdot \left(\left(2 + x\right) + x\right)\right) \cdot 0.5\\
\end{array}
\end{array}
if x < 1.32e20Initial program 67.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.2%
Taylor expanded in x around 0
Applied rewrites55.3%
Taylor expanded in eps around inf
Applied rewrites86.6%
if 1.32e20 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites50.1%
Taylor expanded in x around 0
Applied rewrites42.6%
Final simplification74.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -210000.0) (* (fma (fma (fma -0.3333333333333333 x 1.0) x -2.0) x 2.0) 0.5) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -210000.0) {
tmp = fma(fma(fma(-0.3333333333333333, x, 1.0), x, -2.0), x, 2.0) * 0.5;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -210000.0) tmp = Float64(fma(fma(fma(-0.3333333333333333, x, 1.0), x, -2.0), x, 2.0) * 0.5); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -210000.0], N[(N[(N[(N[(-0.3333333333333333 * x + 1.0), $MachinePrecision] * x + -2.0), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -210000:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, x, 1\right), x, -2\right), x, 2\right) \cdot 0.5\\
\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 < -2.1e5Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites31.6%
Taylor expanded in eps around 0
Applied rewrites67.3%
if -2.1e5 < x Initial program 73.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites65.5%
Taylor expanded in x around 0
Applied rewrites60.3%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (if (<= x -62.0) (* (+ (fma (- -1.0 eps_m) x 1.0) 1.0) 0.5) (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0)))
eps_m = fabs(eps);
double code(double x, double eps_m) {
double tmp;
if (x <= -62.0) {
tmp = (fma((-1.0 - eps_m), x, 1.0) + 1.0) * 0.5;
} else {
tmp = fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
return tmp;
}
eps_m = abs(eps) function code(x, eps_m) tmp = 0.0 if (x <= -62.0) tmp = Float64(Float64(fma(Float64(-1.0 - eps_m), x, 1.0) + 1.0) * 0.5); else tmp = fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0); end return tmp end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := If[LessEqual[x, -62.0], N[(N[(N[(N[(-1.0 - eps$95$m), $MachinePrecision] * x + 1.0), $MachinePrecision] + 1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -62:\\
\;\;\;\;\left(\mathsf{fma}\left(-1 - eps\_m, x, 1\right) + 1\right) \cdot 0.5\\
\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 < -62Initial program 97.3%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.3%
Taylor expanded in x around 0
Applied rewrites44.9%
Taylor expanded in x around 0
Applied rewrites20.4%
if -62 < x Initial program 73.4%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites65.6%
Taylor expanded in x around 0
Applied rewrites60.9%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 (fma (fma 0.3333333333333333 x -0.5) (* x x) 1.0))
eps_m = fabs(eps);
double code(double x, double eps_m) {
return fma(fma(0.3333333333333333, x, -0.5), (x * x), 1.0);
}
eps_m = abs(eps) function code(x, eps_m) return fma(fma(0.3333333333333333, x, -0.5), Float64(x * x), 1.0) end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := N[(N[(0.3333333333333333 * x + -0.5), $MachinePrecision] * N[(x * x), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
\mathsf{fma}\left(\mathsf{fma}\left(0.3333333333333333, x, -0.5\right), x \cdot x, 1\right)
\end{array}
Initial program 76.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites56.6%
Taylor expanded in x around 0
Applied rewrites52.1%
eps_m = (fabs.f64 eps) (FPCore (x eps_m) :precision binary64 1.0)
eps_m = fabs(eps);
double code(double x, double eps_m) {
return 1.0;
}
eps_m = abs(eps)
real(8) function code(x, eps_m)
real(8), intent (in) :: x
real(8), intent (in) :: eps_m
code = 1.0d0
end function
eps_m = Math.abs(eps);
public static double code(double x, double eps_m) {
return 1.0;
}
eps_m = math.fabs(eps) def code(x, eps_m): return 1.0
eps_m = abs(eps) function code(x, eps_m) return 1.0 end
eps_m = abs(eps); function tmp = code(x, eps_m) tmp = 1.0; end
eps_m = N[Abs[eps], $MachinePrecision] code[x_, eps$95$m_] := 1.0
\begin{array}{l}
eps_m = \left|\varepsilon\right|
\\
1
\end{array}
Initial program 76.9%
Taylor expanded in x around 0
Applied rewrites41.0%
herbie shell --seed 2024240
(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))