
(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
double code(double x, double eps) {
return pow((x + eps), 5.0) - pow(x, 5.0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
end function
public static double code(double x, double eps) {
return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
def code(x, eps): return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
function code(x, eps) return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) end
function tmp = code(x, eps) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
double code(double x, double eps) {
return pow((x + eps), 5.0) - pow(x, 5.0);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
end function
public static double code(double x, double eps) {
return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
def code(x, eps): return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
function code(x, eps) return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) end
function tmp = code(x, eps) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (pow (+ eps x) 5.0)) (t_1 (- t_0 (pow x 5.0))))
(if (<= t_1 -5e-311)
(- t_0 (* (* (* x x) x) (* x x)))
(if (<= t_1 0.0)
(* (* (* (* (fma 10.0 eps (* 5.0 x)) x) eps) x) x)
t_1))))
double code(double x, double eps) {
double t_0 = pow((eps + x), 5.0);
double t_1 = t_0 - pow(x, 5.0);
double tmp;
if (t_1 <= -5e-311) {
tmp = t_0 - (((x * x) * x) * (x * x));
} else if (t_1 <= 0.0) {
tmp = (((fma(10.0, eps, (5.0 * x)) * x) * eps) * x) * x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, eps) t_0 = Float64(eps + x) ^ 5.0 t_1 = Float64(t_0 - (x ^ 5.0)) tmp = 0.0 if (t_1 <= -5e-311) tmp = Float64(t_0 - Float64(Float64(Float64(x * x) * x) * Float64(x * x))); elseif (t_1 <= 0.0) tmp = Float64(Float64(Float64(Float64(fma(10.0, eps, Float64(5.0 * x)) * x) * eps) * x) * x); else tmp = t_1; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[(eps + x), $MachinePrecision], 5.0], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-311], N[(t$95$0 - N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(N[(N[(N[(10.0 * eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\varepsilon + x\right)}^{5}\\
t_1 := t\_0 - {x}^{5}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-311}:\\
\;\;\;\;t\_0 - \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\left(\left(\left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot x\right) \cdot \varepsilon\right) \cdot x\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -5.00000000000023e-311Initial program 96.4%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
pow2N/A
lower-*.f64N/A
unpow3N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6496.4
Applied rewrites96.4%
if -5.00000000000023e-311 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 0.0Initial program 83.0%
Taylor expanded in eps around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in eps around 0
Applied rewrites99.9%
if 0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) Initial program 97.3%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (pow (+ eps x) 5.0))
(t_1 (- t_0 (pow x 5.0)))
(t_2 (- t_0 (* (* (* x x) x) (* x x)))))
(if (<= t_1 -5e-311)
t_2
(if (<= t_1 0.0)
(* (* (* (* (fma 10.0 eps (* 5.0 x)) x) eps) x) x)
t_2))))
double code(double x, double eps) {
double t_0 = pow((eps + x), 5.0);
double t_1 = t_0 - pow(x, 5.0);
double t_2 = t_0 - (((x * x) * x) * (x * x));
double tmp;
if (t_1 <= -5e-311) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = (((fma(10.0, eps, (5.0 * x)) * x) * eps) * x) * x;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, eps) t_0 = Float64(eps + x) ^ 5.0 t_1 = Float64(t_0 - (x ^ 5.0)) t_2 = Float64(t_0 - Float64(Float64(Float64(x * x) * x) * Float64(x * x))) tmp = 0.0 if (t_1 <= -5e-311) tmp = t_2; elseif (t_1 <= 0.0) tmp = Float64(Float64(Float64(Float64(fma(10.0, eps, Float64(5.0 * x)) * x) * eps) * x) * x); else tmp = t_2; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[(eps + x), $MachinePrecision], 5.0], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-311], t$95$2, If[LessEqual[t$95$1, 0.0], N[(N[(N[(N[(N[(10.0 * eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\varepsilon + x\right)}^{5}\\
t_1 := t\_0 - {x}^{5}\\
t_2 := t\_0 - \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-311}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\left(\left(\left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot x\right) \cdot \varepsilon\right) \cdot x\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -5.00000000000023e-311 or 0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) Initial program 96.9%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
pow2N/A
lower-*.f64N/A
unpow3N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6496.9
Applied rewrites96.9%
if -5.00000000000023e-311 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 0.0Initial program 83.0%
Taylor expanded in eps around 0
Applied rewrites99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
Taylor expanded in eps around 0
Applied rewrites99.9%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(if (<= x -3.1e-52)
(* (* (* (fma (* 5.0 x) x (* (* 10.0 (+ eps x)) eps)) eps) x) x)
(if (<= x 2e-63)
(* (pow eps 5.0) (fma x (/ 5.0 eps) 1.0))
(*
(fma
(* (fma 10.0 eps (* 5.0 x)) (* x x))
x
(* (* eps eps) (* (fma 10.0 x (* 5.0 eps)) x)))
eps))))
double code(double x, double eps) {
double tmp;
if (x <= -3.1e-52) {
tmp = ((fma((5.0 * x), x, ((10.0 * (eps + x)) * eps)) * eps) * x) * x;
} else if (x <= 2e-63) {
tmp = pow(eps, 5.0) * fma(x, (5.0 / eps), 1.0);
} else {
tmp = fma((fma(10.0, eps, (5.0 * x)) * (x * x)), x, ((eps * eps) * (fma(10.0, x, (5.0 * eps)) * x))) * eps;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -3.1e-52) tmp = Float64(Float64(Float64(fma(Float64(5.0 * x), x, Float64(Float64(10.0 * Float64(eps + x)) * eps)) * eps) * x) * x); elseif (x <= 2e-63) tmp = Float64((eps ^ 5.0) * fma(x, Float64(5.0 / eps), 1.0)); else tmp = Float64(fma(Float64(fma(10.0, eps, Float64(5.0 * x)) * Float64(x * x)), x, Float64(Float64(eps * eps) * Float64(fma(10.0, x, Float64(5.0 * eps)) * x))) * eps); end return tmp end
code[x_, eps_] := If[LessEqual[x, -3.1e-52], N[(N[(N[(N[(N[(5.0 * x), $MachinePrecision] * x + N[(N[(10.0 * N[(eps + x), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 2e-63], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(x * N[(5.0 / eps), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(10.0 * eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + N[(N[(eps * eps), $MachinePrecision] * N[(N[(10.0 * x + N[(5.0 * eps), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(5 \cdot x, x, \left(10 \cdot \left(\varepsilon + x\right)\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot x\right) \cdot x\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-63}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \mathsf{fma}\left(x, \frac{5}{\varepsilon}, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot \left(x \cdot x\right), x, \left(\varepsilon \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(10, x, 5 \cdot \varepsilon\right) \cdot x\right)\right) \cdot \varepsilon\\
\end{array}
\end{array}
if x < -3.0999999999999999e-52Initial program 44.6%
Taylor expanded in eps around 0
Applied rewrites93.4%
Taylor expanded in eps around 0
Applied rewrites93.6%
Taylor expanded in x around 0
Applied rewrites93.8%
if -3.0999999999999999e-52 < x < 2.00000000000000013e-63Initial program 100.0%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f6499.9
Applied rewrites99.9%
Applied rewrites99.9%
if 2.00000000000000013e-63 < x Initial program 41.4%
Taylor expanded in eps around 0
Applied rewrites97.2%
Taylor expanded in x around 0
Applied rewrites96.9%
Taylor expanded in eps around 0
Applied rewrites97.0%
Final simplification98.8%
(FPCore (x eps)
:precision binary64
(if (<= x -3.1e-52)
(* (* (* (fma (* 5.0 x) x (* (* 10.0 (+ eps x)) eps)) eps) x) x)
(if (<= x 2e-63)
(* (pow eps 4.0) (fma x 5.0 eps))
(*
(fma
(* (fma 10.0 eps (* 5.0 x)) (* x x))
x
(* (* eps eps) (* (fma 10.0 x (* 5.0 eps)) x)))
eps))))
double code(double x, double eps) {
double tmp;
if (x <= -3.1e-52) {
tmp = ((fma((5.0 * x), x, ((10.0 * (eps + x)) * eps)) * eps) * x) * x;
} else if (x <= 2e-63) {
tmp = pow(eps, 4.0) * fma(x, 5.0, eps);
} else {
tmp = fma((fma(10.0, eps, (5.0 * x)) * (x * x)), x, ((eps * eps) * (fma(10.0, x, (5.0 * eps)) * x))) * eps;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -3.1e-52) tmp = Float64(Float64(Float64(fma(Float64(5.0 * x), x, Float64(Float64(10.0 * Float64(eps + x)) * eps)) * eps) * x) * x); elseif (x <= 2e-63) tmp = Float64((eps ^ 4.0) * fma(x, 5.0, eps)); else tmp = Float64(fma(Float64(fma(10.0, eps, Float64(5.0 * x)) * Float64(x * x)), x, Float64(Float64(eps * eps) * Float64(fma(10.0, x, Float64(5.0 * eps)) * x))) * eps); end return tmp end
code[x_, eps_] := If[LessEqual[x, -3.1e-52], N[(N[(N[(N[(N[(5.0 * x), $MachinePrecision] * x + N[(N[(10.0 * N[(eps + x), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 2e-63], N[(N[Power[eps, 4.0], $MachinePrecision] * N[(x * 5.0 + eps), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(10.0 * eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + N[(N[(eps * eps), $MachinePrecision] * N[(N[(10.0 * x + N[(5.0 * eps), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(5 \cdot x, x, \left(10 \cdot \left(\varepsilon + x\right)\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot x\right) \cdot x\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-63}:\\
\;\;\;\;{\varepsilon}^{4} \cdot \mathsf{fma}\left(x, 5, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot \left(x \cdot x\right), x, \left(\varepsilon \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(10, x, 5 \cdot \varepsilon\right) \cdot x\right)\right) \cdot \varepsilon\\
\end{array}
\end{array}
if x < -3.0999999999999999e-52Initial program 44.6%
Taylor expanded in eps around 0
Applied rewrites93.4%
Taylor expanded in eps around 0
Applied rewrites93.6%
Taylor expanded in x around 0
Applied rewrites93.8%
if -3.0999999999999999e-52 < x < 2.00000000000000013e-63Initial program 100.0%
Taylor expanded in eps around 0
Applied rewrites82.9%
Taylor expanded in x around 0
distribute-lft1-inN/A
metadata-evalN/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
pow-plusN/A
distribute-lft-inN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-pow.f6499.9
Applied rewrites99.9%
if 2.00000000000000013e-63 < x Initial program 41.4%
Taylor expanded in eps around 0
Applied rewrites97.2%
Taylor expanded in x around 0
Applied rewrites96.9%
Taylor expanded in eps around 0
Applied rewrites97.0%
Final simplification98.8%
(FPCore (x eps)
:precision binary64
(if (<= x -3.1e-52)
(* (* (* (fma (* 5.0 x) x (* (* 10.0 (+ eps x)) eps)) eps) x) x)
(if (<= x 2e-63)
(pow eps 5.0)
(*
(fma
(* (fma 10.0 eps (* 5.0 x)) (* x x))
x
(* (* eps eps) (* (fma 10.0 x (* 5.0 eps)) x)))
eps))))
double code(double x, double eps) {
double tmp;
if (x <= -3.1e-52) {
tmp = ((fma((5.0 * x), x, ((10.0 * (eps + x)) * eps)) * eps) * x) * x;
} else if (x <= 2e-63) {
tmp = pow(eps, 5.0);
} else {
tmp = fma((fma(10.0, eps, (5.0 * x)) * (x * x)), x, ((eps * eps) * (fma(10.0, x, (5.0 * eps)) * x))) * eps;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -3.1e-52) tmp = Float64(Float64(Float64(fma(Float64(5.0 * x), x, Float64(Float64(10.0 * Float64(eps + x)) * eps)) * eps) * x) * x); elseif (x <= 2e-63) tmp = eps ^ 5.0; else tmp = Float64(fma(Float64(fma(10.0, eps, Float64(5.0 * x)) * Float64(x * x)), x, Float64(Float64(eps * eps) * Float64(fma(10.0, x, Float64(5.0 * eps)) * x))) * eps); end return tmp end
code[x_, eps_] := If[LessEqual[x, -3.1e-52], N[(N[(N[(N[(N[(5.0 * x), $MachinePrecision] * x + N[(N[(10.0 * N[(eps + x), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 2e-63], N[Power[eps, 5.0], $MachinePrecision], N[(N[(N[(N[(10.0 * eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + N[(N[(eps * eps), $MachinePrecision] * N[(N[(10.0 * x + N[(5.0 * eps), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(5 \cdot x, x, \left(10 \cdot \left(\varepsilon + x\right)\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot x\right) \cdot x\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-63}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot \left(x \cdot x\right), x, \left(\varepsilon \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(10, x, 5 \cdot \varepsilon\right) \cdot x\right)\right) \cdot \varepsilon\\
\end{array}
\end{array}
if x < -3.0999999999999999e-52Initial program 44.6%
Taylor expanded in eps around 0
Applied rewrites93.4%
Taylor expanded in eps around 0
Applied rewrites93.6%
Taylor expanded in x around 0
Applied rewrites93.8%
if -3.0999999999999999e-52 < x < 2.00000000000000013e-63Initial program 100.0%
Taylor expanded in x around 0
lower-pow.f6499.7
Applied rewrites99.7%
if 2.00000000000000013e-63 < x Initial program 41.4%
Taylor expanded in eps around 0
Applied rewrites97.2%
Taylor expanded in x around 0
Applied rewrites96.9%
Taylor expanded in eps around 0
Applied rewrites97.0%
Final simplification98.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (* x x) x)))
(*
(fma
(fma (fma (* x x) 10.0 (* (* 5.0 x) eps)) eps (* 10.0 t_0))
eps
(* (* t_0 x) 5.0))
eps)))
double code(double x, double eps) {
double t_0 = (x * x) * x;
return fma(fma(fma((x * x), 10.0, ((5.0 * x) * eps)), eps, (10.0 * t_0)), eps, ((t_0 * x) * 5.0)) * eps;
}
function code(x, eps) t_0 = Float64(Float64(x * x) * x) return Float64(fma(fma(fma(Float64(x * x), 10.0, Float64(Float64(5.0 * x) * eps)), eps, Float64(10.0 * t_0)), eps, Float64(Float64(t_0 * x) * 5.0)) * eps) end
code[x_, eps_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, N[(N[(N[(N[(N[(x * x), $MachinePrecision] * 10.0 + N[(N[(5.0 * x), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision] * eps + N[(10.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * eps + N[(N[(t$95$0 * x), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot x\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 10, \left(5 \cdot x\right) \cdot \varepsilon\right), \varepsilon, 10 \cdot t\_0\right), \varepsilon, \left(t\_0 \cdot x\right) \cdot 5\right) \cdot \varepsilon
\end{array}
\end{array}
Initial program 85.2%
Taylor expanded in eps around 0
Applied rewrites86.2%
Applied rewrites86.1%
Final simplification86.1%
(FPCore (x eps)
:precision binary64
(*
(*
(fma
(* (fma 10.0 x (* 5.0 eps)) eps)
eps
(* (* (fma 10.0 eps (* 5.0 x)) x) x))
x)
eps))
double code(double x, double eps) {
return (fma((fma(10.0, x, (5.0 * eps)) * eps), eps, ((fma(10.0, eps, (5.0 * x)) * x) * x)) * x) * eps;
}
function code(x, eps) return Float64(Float64(fma(Float64(fma(10.0, x, Float64(5.0 * eps)) * eps), eps, Float64(Float64(fma(10.0, eps, Float64(5.0 * x)) * x) * x)) * x) * eps) end
code[x_, eps_] := N[(N[(N[(N[(N[(10.0 * x + N[(5.0 * eps), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] * eps + N[(N[(N[(10.0 * eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision]
\begin{array}{l}
\\
\left(\mathsf{fma}\left(\mathsf{fma}\left(10, x, 5 \cdot \varepsilon\right) \cdot \varepsilon, \varepsilon, \left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot x\right) \cdot x\right) \cdot x\right) \cdot \varepsilon
\end{array}
Initial program 85.2%
Taylor expanded in eps around 0
Applied rewrites86.2%
Applied rewrites86.1%
Taylor expanded in x around 0
Applied rewrites86.1%
Final simplification86.1%
(FPCore (x eps) :precision binary64 (* (* (* (fma (* 5.0 x) x (* (* 10.0 (+ eps x)) eps)) eps) x) x))
double code(double x, double eps) {
return ((fma((5.0 * x), x, ((10.0 * (eps + x)) * eps)) * eps) * x) * x;
}
function code(x, eps) return Float64(Float64(Float64(fma(Float64(5.0 * x), x, Float64(Float64(10.0 * Float64(eps + x)) * eps)) * eps) * x) * x) end
code[x_, eps_] := N[(N[(N[(N[(N[(5.0 * x), $MachinePrecision] * x + N[(N[(10.0 * N[(eps + x), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\mathsf{fma}\left(5 \cdot x, x, \left(10 \cdot \left(\varepsilon + x\right)\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot x\right) \cdot x
\end{array}
Initial program 85.2%
Taylor expanded in eps around 0
Applied rewrites86.2%
Taylor expanded in eps around 0
Applied rewrites86.1%
Taylor expanded in x around 0
Applied rewrites86.1%
Final simplification86.1%
(FPCore (x eps) :precision binary64 (* (* (* (* (fma 10.0 eps (* 5.0 x)) x) eps) x) x))
double code(double x, double eps) {
return (((fma(10.0, eps, (5.0 * x)) * x) * eps) * x) * x;
}
function code(x, eps) return Float64(Float64(Float64(Float64(fma(10.0, eps, Float64(5.0 * x)) * x) * eps) * x) * x) end
code[x_, eps_] := N[(N[(N[(N[(N[(10.0 * eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot x\right) \cdot \varepsilon\right) \cdot x\right) \cdot x
\end{array}
Initial program 85.2%
Taylor expanded in eps around 0
Applied rewrites86.2%
Taylor expanded in x around 0
Applied rewrites86.1%
Taylor expanded in eps around 0
Applied rewrites86.0%
Final simplification86.0%
(FPCore (x eps) :precision binary64 (* (* (* (* (fma 10.0 eps (* 5.0 x)) eps) x) x) x))
double code(double x, double eps) {
return (((fma(10.0, eps, (5.0 * x)) * eps) * x) * x) * x;
}
function code(x, eps) return Float64(Float64(Float64(Float64(fma(10.0, eps, Float64(5.0 * x)) * eps) * x) * x) * x) end
code[x_, eps_] := N[(N[(N[(N[(N[(10.0 * eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot \varepsilon\right) \cdot x\right) \cdot x\right) \cdot x
\end{array}
Initial program 85.2%
Taylor expanded in eps around 0
Applied rewrites86.2%
Taylor expanded in eps around 0
Applied rewrites85.9%
Final simplification85.9%
(FPCore (x eps) :precision binary64 (* (* (* 5.0 x) (* (* x x) x)) eps))
double code(double x, double eps) {
return ((5.0 * x) * ((x * x) * x)) * eps;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((5.0d0 * x) * ((x * x) * x)) * eps
end function
public static double code(double x, double eps) {
return ((5.0 * x) * ((x * x) * x)) * eps;
}
def code(x, eps): return ((5.0 * x) * ((x * x) * x)) * eps
function code(x, eps) return Float64(Float64(Float64(5.0 * x) * Float64(Float64(x * x) * x)) * eps) end
function tmp = code(x, eps) tmp = ((5.0 * x) * ((x * x) * x)) * eps; end
code[x_, eps_] := N[(N[(N[(5.0 * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(5 \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right) \cdot \varepsilon
\end{array}
Initial program 85.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites86.0%
Taylor expanded in x around inf
Applied rewrites85.7%
Applied rewrites85.7%
Final simplification85.7%
(FPCore (x eps) :precision binary64 (* (* (* (* 5.0 x) x) (* x x)) eps))
double code(double x, double eps) {
return (((5.0 * x) * x) * (x * x)) * eps;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((5.0d0 * x) * x) * (x * x)) * eps
end function
public static double code(double x, double eps) {
return (((5.0 * x) * x) * (x * x)) * eps;
}
def code(x, eps): return (((5.0 * x) * x) * (x * x)) * eps
function code(x, eps) return Float64(Float64(Float64(Float64(5.0 * x) * x) * Float64(x * x)) * eps) end
function tmp = code(x, eps) tmp = (((5.0 * x) * x) * (x * x)) * eps; end
code[x_, eps_] := N[(N[(N[(N[(5.0 * x), $MachinePrecision] * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(5 \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \varepsilon
\end{array}
Initial program 85.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites86.0%
Taylor expanded in x around inf
Applied rewrites85.7%
Final simplification85.7%
(FPCore (x eps) :precision binary64 (* (* (* (* (* x x) eps) x) 5.0) x))
double code(double x, double eps) {
return ((((x * x) * eps) * x) * 5.0) * x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((((x * x) * eps) * x) * 5.0d0) * x
end function
public static double code(double x, double eps) {
return ((((x * x) * eps) * x) * 5.0) * x;
}
def code(x, eps): return ((((x * x) * eps) * x) * 5.0) * x
function code(x, eps) return Float64(Float64(Float64(Float64(Float64(x * x) * eps) * x) * 5.0) * x) end
function tmp = code(x, eps) tmp = ((((x * x) * eps) * x) * 5.0) * x; end
code[x_, eps_] := N[(N[(N[(N[(N[(x * x), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision] * 5.0), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x \cdot x\right) \cdot \varepsilon\right) \cdot x\right) \cdot 5\right) \cdot x
\end{array}
Initial program 85.2%
Taylor expanded in eps around 0
Applied rewrites86.2%
Taylor expanded in x around 0
Applied rewrites86.1%
Applied rewrites86.1%
Taylor expanded in x around inf
Applied rewrites85.6%
(FPCore (x eps) :precision binary64 (* (* (* (* (* 10.0 eps) eps) eps) x) x))
double code(double x, double eps) {
return ((((10.0 * eps) * eps) * eps) * x) * x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((((10.0d0 * eps) * eps) * eps) * x) * x
end function
public static double code(double x, double eps) {
return ((((10.0 * eps) * eps) * eps) * x) * x;
}
def code(x, eps): return ((((10.0 * eps) * eps) * eps) * x) * x
function code(x, eps) return Float64(Float64(Float64(Float64(Float64(10.0 * eps) * eps) * eps) * x) * x) end
function tmp = code(x, eps) tmp = ((((10.0 * eps) * eps) * eps) * x) * x; end
code[x_, eps_] := N[(N[(N[(N[(N[(10.0 * eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(10 \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot x\right) \cdot x
\end{array}
Initial program 85.2%
Taylor expanded in eps around 0
Applied rewrites86.2%
Taylor expanded in eps around 0
Applied rewrites86.1%
Taylor expanded in x around 0
Applied rewrites71.0%
Taylor expanded in x around 0
Applied rewrites71.0%
herbie shell --seed 2024235
(FPCore (x eps)
:name "ENA, Section 1.4, Exercise 4b, n=5"
:precision binary64
:pre (and (and (<= -1000000000.0 x) (<= x 1000000000.0)) (and (<= -1.0 eps) (<= eps 1.0)))
(- (pow (+ x eps) 5.0) (pow x 5.0)))