
(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 10 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 (* 0.5 (+ (exp (* (- -1.0 eps) x)) (exp (fma eps x (- x))))))
double code(double x, double eps) {
return 0.5 * (exp(((-1.0 - eps) * x)) + exp(fma(eps, x, -x)));
}
function code(x, eps) return Float64(0.5 * Float64(exp(Float64(Float64(-1.0 - eps) * x)) + exp(fma(eps, x, Float64(-x))))) end
code[x_, eps_] := N[(0.5 * N[(N[Exp[N[(N[(-1.0 - eps), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision] + N[Exp[N[(eps * x + (-x)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(e^{\left(-1 - \varepsilon\right) \cdot x} + e^{\mathsf{fma}\left(\varepsilon, x, -x\right)}\right)
\end{array}
Initial program 70.5%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.3%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (exp (* (+ -1.0 eps) x)) (+ (/ 1.0 eps) 1.0))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
2.000000005377993)
(* (* (+ (+ 2.0 x) x) (exp (- x))) 0.5)
(*
(fma
(fma
(* (fma (+ eps 1.0) (+ eps 1.0) (* (+ -1.0 eps) (+ -1.0 eps))) 0.5)
x
(+ (- -2.0 eps) eps))
x
2.0)
0.5)))
double code(double x, double eps) {
double tmp;
if (((exp(((-1.0 + eps) * x)) * ((1.0 / eps) + 1.0)) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 2.000000005377993) {
tmp = (((2.0 + x) + x) * exp(-x)) * 0.5;
} else {
tmp = fma(fma((fma((eps + 1.0), (eps + 1.0), ((-1.0 + eps) * (-1.0 + eps))) * 0.5), x, ((-2.0 - eps) + eps)), x, 2.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (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))) <= 2.000000005377993) tmp = Float64(Float64(Float64(Float64(2.0 + x) + x) * exp(Float64(-x))) * 0.5); else tmp = Float64(fma(fma(Float64(fma(Float64(eps + 1.0), Float64(eps + 1.0), Float64(Float64(-1.0 + eps) * Float64(-1.0 + eps))) * 0.5), x, Float64(Float64(-2.0 - eps) + eps)), x, 2.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[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], 2.000000005377993], N[(N[(N[(N[(2.0 + x), $MachinePrecision] + x), $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(N[(N[(eps + 1.0), $MachinePrecision] * N[(eps + 1.0), $MachinePrecision] + N[(N[(-1.0 + eps), $MachinePrecision] * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * x + N[(N[(-2.0 - eps), $MachinePrecision] + eps), $MachinePrecision]), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;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) \leq 2.000000005377993:\\
\;\;\;\;\left(\left(\left(2 + x\right) + x\right) \cdot e^{-x}\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon + 1, \varepsilon + 1, \left(-1 + \varepsilon\right) \cdot \left(-1 + \varepsilon\right)\right) \cdot 0.5, x, \left(-2 - \varepsilon\right) + \varepsilon\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))))) < 2.0000000053779932Initial program 50.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.6%
if 2.0000000053779932 < (-.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.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites80.3%
Final simplification91.6%
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (exp (* (+ -1.0 eps) x)) (+ (/ 1.0 eps) 1.0))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
2.000000005377993)
(exp (- x))
(*
(fma
(fma
(* (fma (+ eps 1.0) (+ eps 1.0) (* (+ -1.0 eps) (+ -1.0 eps))) 0.5)
x
(+ (- -2.0 eps) eps))
x
2.0)
0.5)))
double code(double x, double eps) {
double tmp;
if (((exp(((-1.0 + eps) * x)) * ((1.0 / eps) + 1.0)) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 2.000000005377993) {
tmp = exp(-x);
} else {
tmp = fma(fma((fma((eps + 1.0), (eps + 1.0), ((-1.0 + eps) * (-1.0 + eps))) * 0.5), x, ((-2.0 - eps) + eps)), x, 2.0) * 0.5;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (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))) <= 2.000000005377993) tmp = exp(Float64(-x)); else tmp = Float64(fma(fma(Float64(fma(Float64(eps + 1.0), Float64(eps + 1.0), Float64(Float64(-1.0 + eps) * Float64(-1.0 + eps))) * 0.5), x, Float64(Float64(-2.0 - eps) + eps)), x, 2.0) * 0.5); end return tmp end
code[x_, eps_] := If[LessEqual[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], 2.000000005377993], N[Exp[(-x)], $MachinePrecision], N[(N[(N[(N[(N[(N[(eps + 1.0), $MachinePrecision] * N[(eps + 1.0), $MachinePrecision] + N[(N[(-1.0 + eps), $MachinePrecision] * N[(-1.0 + eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * x + N[(N[(-2.0 - eps), $MachinePrecision] + eps), $MachinePrecision]), $MachinePrecision] * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;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) \leq 2.000000005377993:\\
\;\;\;\;e^{-x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\varepsilon + 1, \varepsilon + 1, \left(-1 + \varepsilon\right) \cdot \left(-1 + \varepsilon\right)\right) \cdot 0.5, x, \left(-2 - \varepsilon\right) + \varepsilon\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))))) < 2.0000000053779932Initial program 50.3%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.7%
Taylor expanded in eps around 0
Applied rewrites98.4%
if 2.0000000053779932 < (-.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.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites80.3%
Final simplification90.9%
(FPCore (x eps)
:precision binary64
(if (<=
(-
(* (exp (* (+ -1.0 eps) x)) (+ (/ 1.0 eps) 1.0))
(* (exp (* (- -1.0 eps) x)) (- (/ 1.0 eps) 1.0)))
5.0)
1.0
(* (* x x) (* (* eps eps) 0.5))))
double code(double x, double eps) {
double tmp;
if (((exp(((-1.0 + eps) * x)) * ((1.0 / eps) + 1.0)) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 5.0) {
tmp = 1.0;
} else {
tmp = (x * x) * ((eps * eps) * 0.5);
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (((exp((((-1.0d0) + eps) * x)) * ((1.0d0 / eps) + 1.0d0)) - (exp((((-1.0d0) - eps) * x)) * ((1.0d0 / eps) - 1.0d0))) <= 5.0d0) then
tmp = 1.0d0
else
tmp = (x * x) * ((eps * eps) * 0.5d0)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (((Math.exp(((-1.0 + eps) * x)) * ((1.0 / eps) + 1.0)) - (Math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 5.0) {
tmp = 1.0;
} else {
tmp = (x * x) * ((eps * eps) * 0.5);
}
return tmp;
}
def code(x, eps): tmp = 0 if ((math.exp(((-1.0 + eps) * x)) * ((1.0 / eps) + 1.0)) - (math.exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 5.0: tmp = 1.0 else: tmp = (x * x) * ((eps * eps) * 0.5) return tmp
function code(x, eps) tmp = 0.0 if (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))) <= 5.0) tmp = 1.0; else tmp = Float64(Float64(x * x) * Float64(Float64(eps * eps) * 0.5)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (((exp(((-1.0 + eps) * x)) * ((1.0 / eps) + 1.0)) - (exp(((-1.0 - eps) * x)) * ((1.0 / eps) - 1.0))) <= 5.0) tmp = 1.0; else tmp = (x * x) * ((eps * eps) * 0.5); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[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], 5.0], 1.0, N[(N[(x * x), $MachinePrecision] * N[(N[(eps * eps), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;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) \leq 5:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot 0.5\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))))) < 5Initial program 50.1%
Taylor expanded in x around 0
Applied rewrites77.6%
if 5 < (-.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
Applied rewrites80.1%
Taylor expanded in eps around 0
Applied rewrites80.1%
Taylor expanded in eps around inf
Applied rewrites68.7%
Final simplification73.9%
(FPCore (x eps) :precision binary64 (if (<= x 45.0) (fma (* (fma (* 0.5 eps) eps -0.5) x) x 1.0) (if (<= x 1.5e+80) (* 0.0 eps) (* (* x x) (* (* eps eps) 0.5)))))
double code(double x, double eps) {
double tmp;
if (x <= 45.0) {
tmp = fma((fma((0.5 * eps), eps, -0.5) * x), x, 1.0);
} else if (x <= 1.5e+80) {
tmp = 0.0 * eps;
} else {
tmp = (x * x) * ((eps * eps) * 0.5);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 45.0) tmp = fma(Float64(fma(Float64(0.5 * eps), eps, -0.5) * x), x, 1.0); elseif (x <= 1.5e+80) tmp = Float64(0.0 * eps); else tmp = Float64(Float64(x * x) * Float64(Float64(eps * eps) * 0.5)); end return tmp end
code[x_, eps_] := If[LessEqual[x, 45.0], N[(N[(N[(N[(0.5 * eps), $MachinePrecision] * eps + -0.5), $MachinePrecision] * x), $MachinePrecision] * x + 1.0), $MachinePrecision], If[LessEqual[x, 1.5e+80], N[(0.0 * eps), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(N[(eps * eps), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 45:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5 \cdot \varepsilon, \varepsilon, -0.5\right) \cdot x, x, 1\right)\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+80}:\\
\;\;\;\;0 \cdot \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if x < 45Initial program 60.4%
Taylor expanded in x around 0
Applied rewrites89.6%
Taylor expanded in eps around 0
Applied rewrites89.7%
if 45 < x < 1.49999999999999993e80Initial program 96.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites3.2%
Applied rewrites11.0%
Applied rewrites46.5%
Taylor expanded in eps around inf
Applied rewrites59.1%
if 1.49999999999999993e80 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites51.8%
Taylor expanded in eps around 0
Applied rewrites51.2%
Taylor expanded in eps around inf
Applied rewrites64.5%
Final simplification82.5%
(FPCore (x eps) :precision binary64 (if (<= x 780.0) (fma (* (* (* eps eps) x) 0.5) x 1.0) (if (<= x 1.5e+80) (* 0.0 eps) (* (* x x) (* (* eps eps) 0.5)))))
double code(double x, double eps) {
double tmp;
if (x <= 780.0) {
tmp = fma((((eps * eps) * x) * 0.5), x, 1.0);
} else if (x <= 1.5e+80) {
tmp = 0.0 * eps;
} else {
tmp = (x * x) * ((eps * eps) * 0.5);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 780.0) tmp = fma(Float64(Float64(Float64(eps * eps) * x) * 0.5), x, 1.0); elseif (x <= 1.5e+80) tmp = Float64(0.0 * eps); else tmp = Float64(Float64(x * x) * Float64(Float64(eps * eps) * 0.5)); end return tmp end
code[x_, eps_] := If[LessEqual[x, 780.0], N[(N[(N[(N[(eps * eps), $MachinePrecision] * x), $MachinePrecision] * 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision], If[LessEqual[x, 1.5e+80], N[(0.0 * eps), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(N[(eps * eps), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 780:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(\varepsilon \cdot \varepsilon\right) \cdot x\right) \cdot 0.5, x, 1\right)\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{+80}:\\
\;\;\;\;0 \cdot \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if x < 780Initial program 60.1%
Taylor expanded in x around 0
Applied rewrites89.2%
Taylor expanded in eps around 0
Applied rewrites89.2%
Taylor expanded in eps around inf
Applied rewrites89.2%
if 780 < x < 1.49999999999999993e80Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites2.9%
Applied rewrites11.1%
Applied rewrites48.4%
Taylor expanded in eps around inf
Applied rewrites61.5%
if 1.49999999999999993e80 < x Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites51.8%
Taylor expanded in eps around 0
Applied rewrites51.2%
Taylor expanded in eps around inf
Applied rewrites64.5%
Final simplification82.4%
(FPCore (x eps) :precision binary64 (if (<= x 1.0) (* (fma -2.0 x 2.0) 0.5) (if (<= x 1e+215) (* 0.0 eps) (* (fma (fma x 0.5 -1.0) x 1.0) x))))
double code(double x, double eps) {
double tmp;
if (x <= 1.0) {
tmp = fma(-2.0, x, 2.0) * 0.5;
} else if (x <= 1e+215) {
tmp = 0.0 * eps;
} else {
tmp = fma(fma(x, 0.5, -1.0), x, 1.0) * x;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 1.0) tmp = Float64(fma(-2.0, x, 2.0) * 0.5); elseif (x <= 1e+215) tmp = Float64(0.0 * eps); else tmp = Float64(fma(fma(x, 0.5, -1.0), x, 1.0) * x); end return tmp end
code[x_, eps_] := If[LessEqual[x, 1.0], N[(N[(-2.0 * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[x, 1e+215], N[(0.0 * eps), $MachinePrecision], N[(N[(N[(x * 0.5 + -1.0), $MachinePrecision] * x + 1.0), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-2, x, 2\right) \cdot 0.5\\
\mathbf{elif}\;x \leq 10^{+215}:\\
\;\;\;\;0 \cdot \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(x, 0.5, -1\right), x, 1\right) \cdot x\\
\end{array}
\end{array}
if x < 1Initial program 60.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites62.6%
Taylor expanded in eps around 0
Applied rewrites62.9%
if 1 < x < 9.99999999999999907e214Initial program 98.1%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites3.1%
Applied rewrites6.1%
Applied rewrites27.4%
Taylor expanded in eps around inf
Applied rewrites54.6%
if 9.99999999999999907e214 < x Initial program 100.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites32.3%
Taylor expanded in x around inf
Applied rewrites32.3%
Taylor expanded in x around 0
Applied rewrites69.2%
(FPCore (x eps) :precision binary64 (if (<= x 1.0) (* (fma -2.0 x 2.0) 0.5) (* 0.0 eps)))
double code(double x, double eps) {
double tmp;
if (x <= 1.0) {
tmp = fma(-2.0, x, 2.0) * 0.5;
} else {
tmp = 0.0 * eps;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= 1.0) tmp = Float64(fma(-2.0, x, 2.0) * 0.5); else tmp = Float64(0.0 * eps); end return tmp end
code[x_, eps_] := If[LessEqual[x, 1.0], N[(N[(-2.0 * x + 2.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(0.0 * eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\mathsf{fma}\left(-2, x, 2\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0 \cdot \varepsilon\\
\end{array}
\end{array}
if x < 1Initial program 60.4%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.4%
Taylor expanded in x around 0
Applied rewrites62.6%
Taylor expanded in eps around 0
Applied rewrites62.9%
if 1 < x Initial program 98.6%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites3.1%
Applied rewrites5.2%
Applied rewrites23.9%
Taylor expanded in eps around inf
Applied rewrites49.4%
(FPCore (x eps) :precision binary64 (if (<= x 550.0) 1.0 (* 0.0 eps)))
double code(double x, double eps) {
double tmp;
if (x <= 550.0) {
tmp = 1.0;
} else {
tmp = 0.0 * eps;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: tmp
if (x <= 550.0d0) then
tmp = 1.0d0
else
tmp = 0.0d0 * eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= 550.0) {
tmp = 1.0;
} else {
tmp = 0.0 * eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= 550.0: tmp = 1.0 else: tmp = 0.0 * eps return tmp
function code(x, eps) tmp = 0.0 if (x <= 550.0) tmp = 1.0; else tmp = Float64(0.0 * eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= 550.0) tmp = 1.0; else tmp = 0.0 * eps; end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, 550.0], 1.0, N[(0.0 * eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 550:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0 \cdot \varepsilon\\
\end{array}
\end{array}
if x < 550Initial program 60.1%
Taylor expanded in x around 0
Applied rewrites62.6%
if 550 < x Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites3.0%
Applied rewrites5.1%
Applied rewrites24.2%
Taylor expanded in eps around inf
Applied rewrites50.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 70.5%
Taylor expanded in x around 0
Applied rewrites47.0%
herbie shell --seed 2024235
(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))