
(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 17 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) (* (* (* (* 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 = (((5.0 * x) * x) * eps) * (x * x);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (eps + x) ** 5.0d0
t_1 = t_0 - (x ** 5.0d0)
if (t_1 <= (-5d-311)) then
tmp = t_0 - (((x * x) * x) * (x * x))
else if (t_1 <= 0.0d0) then
tmp = (((5.0d0 * x) * x) * eps) * (x * x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.pow((eps + x), 5.0);
double t_1 = t_0 - Math.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 = (((5.0 * x) * x) * eps) * (x * x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, eps): t_0 = math.pow((eps + x), 5.0) t_1 = t_0 - math.pow(x, 5.0) tmp = 0 if t_1 <= -5e-311: tmp = t_0 - (((x * x) * x) * (x * x)) elif t_1 <= 0.0: tmp = (((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(5.0 * x) * x) * eps) * Float64(x * x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, eps) t_0 = (eps + x) ^ 5.0; t_1 = t_0 - (x ^ 5.0); tmp = 0.0; if (t_1 <= -5e-311) tmp = t_0 - (((x * x) * x) * (x * x)); elseif (t_1 <= 0.0) tmp = (((5.0 * x) * x) * eps) * (x * x); else tmp = t_1; end tmp_2 = 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[(5.0 * x), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $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(5 \cdot x\right) \cdot x\right) \cdot \varepsilon\right) \cdot \left(x \cdot x\right)\\
\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 eps around 0
distribute-lft1-inN/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
pow-plusN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
cube-multN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
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) (* (* (* (* 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 = (((5.0 * x) * x) * eps) * (x * x);
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (eps + x) ** 5.0d0
t_1 = t_0 - (x ** 5.0d0)
t_2 = t_0 - (((x * x) * x) * (x * x))
if (t_1 <= (-5d-311)) then
tmp = t_2
else if (t_1 <= 0.0d0) then
tmp = (((5.0d0 * x) * x) * eps) * (x * x)
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = Math.pow((eps + x), 5.0);
double t_1 = t_0 - Math.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 = (((5.0 * x) * x) * eps) * (x * x);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, eps): t_0 = math.pow((eps + x), 5.0) t_1 = t_0 - math.pow(x, 5.0) t_2 = t_0 - (((x * x) * x) * (x * x)) tmp = 0 if t_1 <= -5e-311: tmp = t_2 elif t_1 <= 0.0: tmp = (((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(5.0 * x) * x) * eps) * Float64(x * x)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, eps) t_0 = (eps + x) ^ 5.0; t_1 = t_0 - (x ^ 5.0); t_2 = t_0 - (((x * x) * x) * (x * x)); tmp = 0.0; if (t_1 <= -5e-311) tmp = t_2; elseif (t_1 <= 0.0) tmp = (((5.0 * x) * x) * eps) * (x * x); else tmp = t_2; end tmp_2 = 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[(5.0 * x), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $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(5 \cdot x\right) \cdot x\right) \cdot \varepsilon\right) \cdot \left(x \cdot x\right)\\
\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 eps around 0
distribute-lft1-inN/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
pow-plusN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
cube-multN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.9
Applied rewrites99.9%
Applied rewrites99.9%
Final simplification99.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (+ eps x) eps)))
(if (<= x -6.3e-52)
(* (* (* (fma t_0 10.0 (* (* x x) 5.0)) x) eps) x)
(if (<= x 2e-63)
(* (pow eps 5.0) (fma x (/ 5.0 eps) 1.0))
(*
(fma
(fma t_0 (* 10.0 eps) (* (* (* 5.0 x) x) eps))
x
(* (* (* eps eps) 5.0) (* eps eps)))
x)))))
double code(double x, double eps) {
double t_0 = (eps + x) * eps;
double tmp;
if (x <= -6.3e-52) {
tmp = ((fma(t_0, 10.0, ((x * x) * 5.0)) * x) * eps) * x;
} else if (x <= 2e-63) {
tmp = pow(eps, 5.0) * fma(x, (5.0 / eps), 1.0);
} else {
tmp = fma(fma(t_0, (10.0 * eps), (((5.0 * x) * x) * eps)), x, (((eps * eps) * 5.0) * (eps * eps))) * x;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(eps + x) * eps) tmp = 0.0 if (x <= -6.3e-52) tmp = Float64(Float64(Float64(fma(t_0, 10.0, Float64(Float64(x * x) * 5.0)) * x) * eps) * x); elseif (x <= 2e-63) tmp = Float64((eps ^ 5.0) * fma(x, Float64(5.0 / eps), 1.0)); else tmp = Float64(fma(fma(t_0, Float64(10.0 * eps), Float64(Float64(Float64(5.0 * x) * x) * eps)), x, Float64(Float64(Float64(eps * eps) * 5.0) * Float64(eps * eps))) * x); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(eps + x), $MachinePrecision] * eps), $MachinePrecision]}, If[LessEqual[x, -6.3e-52], N[(N[(N[(N[(t$95$0 * 10.0 + N[(N[(x * x), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * eps), $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[(t$95$0 * N[(10.0 * eps), $MachinePrecision] + N[(N[(N[(5.0 * x), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision] * x + N[(N[(N[(eps * eps), $MachinePrecision] * 5.0), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\varepsilon + x\right) \cdot \varepsilon\\
\mathbf{if}\;x \leq -6.3 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(t\_0, 10, \left(x \cdot x\right) \cdot 5\right) \cdot x\right) \cdot \varepsilon\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(t\_0, 10 \cdot \varepsilon, \left(\left(5 \cdot x\right) \cdot x\right) \cdot \varepsilon\right), x, \left(\left(\varepsilon \cdot \varepsilon\right) \cdot 5\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot x\\
\end{array}
\end{array}
if x < -6.3000000000000003e-52Initial program 44.6%
Taylor expanded in eps around 0
Applied rewrites93.4%
Taylor expanded in x around 0
Applied rewrites93.4%
Applied rewrites93.6%
Taylor expanded in eps around 0
Applied rewrites93.8%
if -6.3000000000000003e-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%
Applied rewrites97.1%
Final simplification98.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (+ eps x) eps)))
(if (<= x -6.3e-52)
(* (* (* (fma t_0 10.0 (* (* x x) 5.0)) x) eps) x)
(if (<= x 2e-63)
(* (pow eps 4.0) (fma 5.0 x eps))
(*
(fma
(fma t_0 (* 10.0 eps) (* (* (* 5.0 x) x) eps))
x
(* (* (* eps eps) 5.0) (* eps eps)))
x)))))
double code(double x, double eps) {
double t_0 = (eps + x) * eps;
double tmp;
if (x <= -6.3e-52) {
tmp = ((fma(t_0, 10.0, ((x * x) * 5.0)) * x) * eps) * x;
} else if (x <= 2e-63) {
tmp = pow(eps, 4.0) * fma(5.0, x, eps);
} else {
tmp = fma(fma(t_0, (10.0 * eps), (((5.0 * x) * x) * eps)), x, (((eps * eps) * 5.0) * (eps * eps))) * x;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(eps + x) * eps) tmp = 0.0 if (x <= -6.3e-52) tmp = Float64(Float64(Float64(fma(t_0, 10.0, Float64(Float64(x * x) * 5.0)) * x) * eps) * x); elseif (x <= 2e-63) tmp = Float64((eps ^ 4.0) * fma(5.0, x, eps)); else tmp = Float64(fma(fma(t_0, Float64(10.0 * eps), Float64(Float64(Float64(5.0 * x) * x) * eps)), x, Float64(Float64(Float64(eps * eps) * 5.0) * Float64(eps * eps))) * x); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(eps + x), $MachinePrecision] * eps), $MachinePrecision]}, If[LessEqual[x, -6.3e-52], N[(N[(N[(N[(t$95$0 * 10.0 + N[(N[(x * x), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 2e-63], N[(N[Power[eps, 4.0], $MachinePrecision] * N[(5.0 * x + eps), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$0 * N[(10.0 * eps), $MachinePrecision] + N[(N[(N[(5.0 * x), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision] * x + N[(N[(N[(eps * eps), $MachinePrecision] * 5.0), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\varepsilon + x\right) \cdot \varepsilon\\
\mathbf{if}\;x \leq -6.3 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(t\_0, 10, \left(x \cdot x\right) \cdot 5\right) \cdot x\right) \cdot \varepsilon\right) \cdot x\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-63}:\\
\;\;\;\;{\varepsilon}^{4} \cdot \mathsf{fma}\left(5, x, \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(t\_0, 10 \cdot \varepsilon, \left(\left(5 \cdot x\right) \cdot x\right) \cdot \varepsilon\right), x, \left(\left(\varepsilon \cdot \varepsilon\right) \cdot 5\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot x\\
\end{array}
\end{array}
if x < -6.3000000000000003e-52Initial program 44.6%
Taylor expanded in eps around 0
Applied rewrites93.4%
Taylor expanded in x around 0
Applied rewrites93.4%
Applied rewrites93.6%
Taylor expanded in eps around 0
Applied rewrites93.8%
if -6.3000000000000003e-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
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/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%
Applied rewrites97.1%
Final simplification98.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (+ eps x) eps)))
(if (<= x -2.9e-52)
(* (* (* (fma t_0 10.0 (* (* x x) 5.0)) x) eps) x)
(if (<= x 2e-63)
(pow eps 5.0)
(*
(fma
(fma t_0 (* 10.0 eps) (* (* (* 5.0 x) x) eps))
x
(* (* (* eps eps) 5.0) (* eps eps)))
x)))))
double code(double x, double eps) {
double t_0 = (eps + x) * eps;
double tmp;
if (x <= -2.9e-52) {
tmp = ((fma(t_0, 10.0, ((x * x) * 5.0)) * x) * eps) * x;
} else if (x <= 2e-63) {
tmp = pow(eps, 5.0);
} else {
tmp = fma(fma(t_0, (10.0 * eps), (((5.0 * x) * x) * eps)), x, (((eps * eps) * 5.0) * (eps * eps))) * x;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(eps + x) * eps) tmp = 0.0 if (x <= -2.9e-52) tmp = Float64(Float64(Float64(fma(t_0, 10.0, Float64(Float64(x * x) * 5.0)) * x) * eps) * x); elseif (x <= 2e-63) tmp = eps ^ 5.0; else tmp = Float64(fma(fma(t_0, Float64(10.0 * eps), Float64(Float64(Float64(5.0 * x) * x) * eps)), x, Float64(Float64(Float64(eps * eps) * 5.0) * Float64(eps * eps))) * x); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(eps + x), $MachinePrecision] * eps), $MachinePrecision]}, If[LessEqual[x, -2.9e-52], N[(N[(N[(N[(t$95$0 * 10.0 + N[(N[(x * x), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 2e-63], N[Power[eps, 5.0], $MachinePrecision], N[(N[(N[(t$95$0 * N[(10.0 * eps), $MachinePrecision] + N[(N[(N[(5.0 * x), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision] * x + N[(N[(N[(eps * eps), $MachinePrecision] * 5.0), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\varepsilon + x\right) \cdot \varepsilon\\
\mathbf{if}\;x \leq -2.9 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(t\_0, 10, \left(x \cdot x\right) \cdot 5\right) \cdot x\right) \cdot \varepsilon\right) \cdot x\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-63}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(t\_0, 10 \cdot \varepsilon, \left(\left(5 \cdot x\right) \cdot x\right) \cdot \varepsilon\right), x, \left(\left(\varepsilon \cdot \varepsilon\right) \cdot 5\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot x\\
\end{array}
\end{array}
if x < -2.9000000000000002e-52Initial program 44.6%
Taylor expanded in eps around 0
Applied rewrites93.4%
Taylor expanded in x around 0
Applied rewrites93.4%
Applied rewrites93.6%
Taylor expanded in eps around 0
Applied rewrites93.8%
if -2.9000000000000002e-52 < x < 2.00000000000000013e-63Initial program 100.0%
Taylor expanded in eps around inf
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%
Applied rewrites97.1%
Final simplification98.7%
(FPCore (x eps) :precision binary64 (* (fma (fma (* (+ eps x) eps) (* 10.0 eps) (* (* (* 5.0 x) x) eps)) x (* (* (* eps eps) 5.0) (* eps eps))) x))
double code(double x, double eps) {
return fma(fma(((eps + x) * eps), (10.0 * eps), (((5.0 * x) * x) * eps)), x, (((eps * eps) * 5.0) * (eps * eps))) * x;
}
function code(x, eps) return Float64(fma(fma(Float64(Float64(eps + x) * eps), Float64(10.0 * eps), Float64(Float64(Float64(5.0 * x) * x) * eps)), x, Float64(Float64(Float64(eps * eps) * 5.0) * Float64(eps * eps))) * x) end
code[x_, eps_] := N[(N[(N[(N[(N[(eps + x), $MachinePrecision] * eps), $MachinePrecision] * N[(10.0 * eps), $MachinePrecision] + N[(N[(N[(5.0 * x), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision] * x + N[(N[(N[(eps * eps), $MachinePrecision] * 5.0), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\left(\varepsilon + x\right) \cdot \varepsilon, 10 \cdot \varepsilon, \left(\left(5 \cdot x\right) \cdot x\right) \cdot \varepsilon\right), x, \left(\left(\varepsilon \cdot \varepsilon\right) \cdot 5\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\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.2%
Final simplification86.2%
(FPCore (x eps) :precision binary64 (* (fma (fma (* (* eps x) x) 5.0 (* (* (* (+ eps x) eps) eps) 10.0)) x (* (* (* eps eps) 5.0) (* eps eps))) x))
double code(double x, double eps) {
return fma(fma(((eps * x) * x), 5.0, ((((eps + x) * eps) * eps) * 10.0)), x, (((eps * eps) * 5.0) * (eps * eps))) * x;
}
function code(x, eps) return Float64(fma(fma(Float64(Float64(eps * x) * x), 5.0, Float64(Float64(Float64(Float64(eps + x) * eps) * eps) * 10.0)), x, Float64(Float64(Float64(eps * eps) * 5.0) * Float64(eps * eps))) * x) end
code[x_, eps_] := N[(N[(N[(N[(N[(eps * x), $MachinePrecision] * x), $MachinePrecision] * 5.0 + N[(N[(N[(N[(eps + x), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision] * 10.0), $MachinePrecision]), $MachinePrecision] * x + N[(N[(N[(eps * eps), $MachinePrecision] * 5.0), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\left(\varepsilon \cdot x\right) \cdot x, 5, \left(\left(\left(\varepsilon + x\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot 10\right), x, \left(\left(\varepsilon \cdot \varepsilon\right) \cdot 5\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\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.2%
Applied rewrites86.1%
Final simplification86.1%
(FPCore (x eps) :precision binary64 (* (fma (* (fma 5.0 x (* 10.0 eps)) (* x x)) x (* (* (fma 5.0 eps (* 10.0 x)) x) (* eps eps))) eps))
double code(double x, double eps) {
return fma((fma(5.0, x, (10.0 * eps)) * (x * x)), x, ((fma(5.0, eps, (10.0 * x)) * x) * (eps * eps))) * eps;
}
function code(x, eps) return Float64(fma(Float64(fma(5.0, x, Float64(10.0 * eps)) * Float64(x * x)), x, Float64(Float64(fma(5.0, eps, Float64(10.0 * x)) * x) * Float64(eps * eps))) * eps) end
code[x_, eps_] := N[(N[(N[(N[(5.0 * x + N[(10.0 * eps), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x + N[(N[(N[(5.0 * eps + N[(10.0 * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(5, x, 10 \cdot \varepsilon\right) \cdot \left(x \cdot x\right), x, \left(\mathsf{fma}\left(5, \varepsilon, 10 \cdot x\right) \cdot x\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \varepsilon
\end{array}
Initial program 85.2%
Taylor expanded in eps around 0
Applied rewrites86.2%
Taylor expanded in eps around 0
Applied rewrites86.1%
Final simplification86.1%
(FPCore (x eps)
:precision binary64
(*
(*
(fma
(* eps eps)
(fma 10.0 x (* 5.0 eps))
(* (* (fma 10.0 eps (* 5.0 x)) x) x))
x)
eps))
double code(double x, double eps) {
return (fma((eps * eps), fma(10.0, x, (5.0 * eps)), ((fma(10.0, eps, (5.0 * x)) * x) * x)) * x) * eps;
}
function code(x, eps) return Float64(Float64(fma(Float64(eps * eps), fma(10.0, x, Float64(5.0 * eps)), Float64(Float64(fma(10.0, eps, Float64(5.0 * x)) * x) * x)) * x) * eps) end
code[x_, eps_] := N[(N[(N[(N[(eps * eps), $MachinePrecision] * N[(10.0 * x + N[(5.0 * eps), $MachinePrecision]), $MachinePrecision] + 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(\varepsilon \cdot \varepsilon, \mathsf{fma}\left(10, x, 5 \cdot \varepsilon\right), \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) (* x x) (* (* (* (* x x) eps) 10.0) (+ eps x))) eps))
double code(double x, double eps) {
return fma(((5.0 * x) * x), (x * x), ((((x * x) * eps) * 10.0) * (eps + x))) * eps;
}
function code(x, eps) return Float64(fma(Float64(Float64(5.0 * x) * x), Float64(x * x), Float64(Float64(Float64(Float64(x * x) * eps) * 10.0) * Float64(eps + x))) * eps) end
code[x_, eps_] := N[(N[(N[(N[(5.0 * x), $MachinePrecision] * x), $MachinePrecision] * N[(x * x), $MachinePrecision] + N[(N[(N[(N[(x * x), $MachinePrecision] * eps), $MachinePrecision] * 10.0), $MachinePrecision] * N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(5 \cdot x\right) \cdot x, x \cdot x, \left(\left(\left(x \cdot x\right) \cdot \varepsilon\right) \cdot 10\right) \cdot \left(\varepsilon + x\right)\right) \cdot \varepsilon
\end{array}
Initial program 85.2%
Taylor expanded in eps around 0
Applied rewrites86.2%
Taylor expanded in eps around 0
Applied rewrites86.1%
(FPCore (x eps) :precision binary64 (* (* (* (fma (* (+ eps x) eps) 10.0 (* (* x x) 5.0)) x) eps) x))
double code(double x, double eps) {
return ((fma(((eps + x) * eps), 10.0, ((x * x) * 5.0)) * x) * eps) * x;
}
function code(x, eps) return Float64(Float64(Float64(fma(Float64(Float64(eps + x) * eps), 10.0, Float64(Float64(x * x) * 5.0)) * x) * eps) * x) end
code[x_, eps_] := N[(N[(N[(N[(N[(N[(eps + x), $MachinePrecision] * eps), $MachinePrecision] * 10.0 + N[(N[(x * x), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\mathsf{fma}\left(\left(\varepsilon + x\right) \cdot \varepsilon, 10, \left(x \cdot x\right) \cdot 5\right) \cdot x\right) \cdot \varepsilon\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.2%
Taylor expanded in eps 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(fma(10.0, eps, Float64(5.0 * x)) * x) * eps) * Float64(x * x)) end
code[x_, eps_] := N[(N[(N[(N[(10.0 * eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot x\right) \cdot \varepsilon\right) \cdot \left(x \cdot x\right)
\end{array}
Initial program 85.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
associate-+r+N/A
distribute-rgt-outN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f64N/A
lower-pow.f6486.0
Applied rewrites86.0%
Applied rewrites85.9%
Taylor expanded in eps around 0
Applied rewrites86.0%
Final simplification86.0%
(FPCore (x eps) :precision binary64 (* (* (* (* (fma 10.0 eps (* 5.0 x)) x) x) eps) x))
double code(double x, double eps) {
return (((fma(10.0, eps, (5.0 * x)) * x) * x) * eps) * x;
}
function code(x, eps) return Float64(Float64(Float64(Float64(fma(10.0, eps, Float64(5.0 * x)) * x) * x) * eps) * x) end
code[x_, eps_] := N[(N[(N[(N[(N[(10.0 * eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot x\right) \cdot x\right) \cdot \varepsilon\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.2%
Taylor expanded in eps around 0
Applied rewrites86.0%
Final simplification86.0%
(FPCore (x eps) :precision binary64 (* (* (* (* 5.0 x) x) eps) (* x x)))
double code(double x, double eps) {
return (((5.0 * x) * x) * eps) * (x * x);
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = (((5.0d0 * x) * x) * eps) * (x * x)
end function
public static double code(double x, double eps) {
return (((5.0 * x) * x) * eps) * (x * x);
}
def code(x, eps): return (((5.0 * x) * x) * eps) * (x * x)
function code(x, eps) return Float64(Float64(Float64(Float64(5.0 * x) * x) * eps) * Float64(x * x)) end
function tmp = code(x, eps) tmp = (((5.0 * x) * x) * eps) * (x * x); end
code[x_, eps_] := N[(N[(N[(N[(5.0 * x), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(5 \cdot x\right) \cdot x\right) \cdot \varepsilon\right) \cdot \left(x \cdot x\right)
\end{array}
Initial program 85.2%
Taylor expanded in eps around 0
Applied rewrites86.2%
Taylor expanded in eps around 0
distribute-lft1-inN/A
metadata-evalN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
metadata-evalN/A
pow-plusN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
cube-multN/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.6
Applied rewrites85.6%
Applied rewrites85.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(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 eps around 0
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 eps around 0
Applied rewrites85.7%
(FPCore (x eps) :precision binary64 (* (* (* (* (* 5.0 eps) x) x) x) x))
double code(double x, double eps) {
return ((((5.0 * eps) * x) * x) * x) * x;
}
real(8) function code(x, eps)
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((((5.0d0 * eps) * x) * x) * x) * x
end function
public static double code(double x, double eps) {
return ((((5.0 * eps) * x) * x) * x) * x;
}
def code(x, eps): return ((((5.0 * eps) * x) * x) * x) * x
function code(x, eps) return Float64(Float64(Float64(Float64(Float64(5.0 * eps) * x) * x) * x) * x) end
function tmp = code(x, eps) tmp = ((((5.0 * eps) * x) * x) * x) * x; end
code[x_, eps_] := N[(N[(N[(N[(N[(5.0 * eps), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(5 \cdot \varepsilon\right) \cdot x\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 x around 0
Applied rewrites86.1%
Applied rewrites86.2%
Taylor expanded in eps around 0
Applied rewrites85.6%
Final simplification85.6%
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)))