
(FPCore (x) :precision binary64 (+ (- (* 6.0 (pow x 5.0)) (* 15.0 (pow x 4.0))) (* 10.0 (pow x 3.0))))
double code(double x) {
return ((6.0 * pow(x, 5.0)) - (15.0 * pow(x, 4.0))) + (10.0 * pow(x, 3.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((6.0d0 * (x ** 5.0d0)) - (15.0d0 * (x ** 4.0d0))) + (10.0d0 * (x ** 3.0d0))
end function
public static double code(double x) {
return ((6.0 * Math.pow(x, 5.0)) - (15.0 * Math.pow(x, 4.0))) + (10.0 * Math.pow(x, 3.0));
}
def code(x): return ((6.0 * math.pow(x, 5.0)) - (15.0 * math.pow(x, 4.0))) + (10.0 * math.pow(x, 3.0))
function code(x) return Float64(Float64(Float64(6.0 * (x ^ 5.0)) - Float64(15.0 * (x ^ 4.0))) + Float64(10.0 * (x ^ 3.0))) end
function tmp = code(x) tmp = ((6.0 * (x ^ 5.0)) - (15.0 * (x ^ 4.0))) + (10.0 * (x ^ 3.0)); end
code[x_] := N[(N[(N[(6.0 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] - N[(15.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(10.0 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(6 \cdot {x}^{5} - 15 \cdot {x}^{4}\right) + 10 \cdot {x}^{3}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (+ (- (* 6.0 (pow x 5.0)) (* 15.0 (pow x 4.0))) (* 10.0 (pow x 3.0))))
double code(double x) {
return ((6.0 * pow(x, 5.0)) - (15.0 * pow(x, 4.0))) + (10.0 * pow(x, 3.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((6.0d0 * (x ** 5.0d0)) - (15.0d0 * (x ** 4.0d0))) + (10.0d0 * (x ** 3.0d0))
end function
public static double code(double x) {
return ((6.0 * Math.pow(x, 5.0)) - (15.0 * Math.pow(x, 4.0))) + (10.0 * Math.pow(x, 3.0));
}
def code(x): return ((6.0 * math.pow(x, 5.0)) - (15.0 * math.pow(x, 4.0))) + (10.0 * math.pow(x, 3.0))
function code(x) return Float64(Float64(Float64(6.0 * (x ^ 5.0)) - Float64(15.0 * (x ^ 4.0))) + Float64(10.0 * (x ^ 3.0))) end
function tmp = code(x) tmp = ((6.0 * (x ^ 5.0)) - (15.0 * (x ^ 4.0))) + (10.0 * (x ^ 3.0)); end
code[x_] := N[(N[(N[(6.0 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] - N[(15.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(10.0 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(6 \cdot {x}^{5} - 15 \cdot {x}^{4}\right) + 10 \cdot {x}^{3}
(FPCore (x) :precision binary64 (fma (* (* (fabs x) x) 10.0) (fabs x) (fma (* (* (* x x) x) -15.0) x (* 6.0 (pow x 5.0)))))
double code(double x) {
return fma(((fabs(x) * x) * 10.0), fabs(x), fma((((x * x) * x) * -15.0), x, (6.0 * pow(x, 5.0))));
}
function code(x) return fma(Float64(Float64(abs(x) * x) * 10.0), abs(x), fma(Float64(Float64(Float64(x * x) * x) * -15.0), x, Float64(6.0 * (x ^ 5.0)))) end
code[x_] := N[(N[(N[(N[Abs[x], $MachinePrecision] * x), $MachinePrecision] * 10.0), $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * -15.0), $MachinePrecision] * x + N[(6.0 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\left(\left|x\right| \cdot x\right) \cdot 10, \left|x\right|, \mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot x\right) \cdot -15, x, 6 \cdot {x}^{5}\right)\right)
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow3N/A
associate-*l*N/A
sqr-abs-revN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-fabs.f6499.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8%
Applied rewrites99.8%
(FPCore (x) :precision binary64 (fma (* (* (fabs x) x) 10.0) (fabs x) (fma -15.0 (* (* (* x x) x) x) (* (pow x 5.0) 6.0))))
double code(double x) {
return fma(((fabs(x) * x) * 10.0), fabs(x), fma(-15.0, (((x * x) * x) * x), (pow(x, 5.0) * 6.0)));
}
function code(x) return fma(Float64(Float64(abs(x) * x) * 10.0), abs(x), fma(-15.0, Float64(Float64(Float64(x * x) * x) * x), Float64((x ^ 5.0) * 6.0))) end
code[x_] := N[(N[(N[(N[Abs[x], $MachinePrecision] * x), $MachinePrecision] * 10.0), $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(-15.0 * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] + N[(N[Power[x, 5.0], $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\left(\left|x\right| \cdot x\right) \cdot 10, \left|x\right|, \mathsf{fma}\left(-15, \left(\left(x \cdot x\right) \cdot x\right) \cdot x, {x}^{5} \cdot 6\right)\right)
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow3N/A
associate-*l*N/A
sqr-abs-revN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-fabs.f6499.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
(FPCore (x) :precision binary64 (* (* (fma (fma x 6.0 -15.0) x 10.0) (* x x)) x))
double code(double x) {
return (fma(fma(x, 6.0, -15.0), x, 10.0) * (x * x)) * x;
}
function code(x) return Float64(Float64(fma(fma(x, 6.0, -15.0), x, 10.0) * Float64(x * x)) * x) end
code[x_] := N[(N[(N[(N[(x * 6.0 + -15.0), $MachinePrecision] * x + 10.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]
\left(\mathsf{fma}\left(\mathsf{fma}\left(x, 6, -15\right), x, 10\right) \cdot \left(x \cdot x\right)\right) \cdot x
Initial program 99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f6498.7%
Applied rewrites98.7%
lift-*.f64N/A
lift-pow.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6498.7%
Applied rewrites98.7%
Taylor expanded in x around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6499.8%
Applied rewrites99.8%
lift-*.f64N/A
lift-pow.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6499.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.8%
lift--.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f6499.8%
Applied rewrites99.8%
(FPCore (x) :precision binary64 (* (* (fma -15.0 x 10.0) (* x x)) x))
double code(double x) {
return (fma(-15.0, x, 10.0) * (x * x)) * x;
}
function code(x) return Float64(Float64(fma(-15.0, x, 10.0) * Float64(x * x)) * x) end
code[x_] := N[(N[(N[(-15.0 * x + 10.0), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]
\left(\mathsf{fma}\left(-15, x, 10\right) \cdot \left(x \cdot x\right)\right) \cdot x
Initial program 99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f6498.7%
Applied rewrites98.7%
lift-*.f64N/A
lift-pow.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6498.7%
Applied rewrites98.7%
(FPCore (x) :precision binary64 (* (* (* (fma -15.0 x 10.0) x) x) x))
double code(double x) {
return ((fma(-15.0, x, 10.0) * x) * x) * x;
}
function code(x) return Float64(Float64(Float64(fma(-15.0, x, 10.0) * x) * x) * x) end
code[x_] := N[(N[(N[(N[(-15.0 * x + 10.0), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
\left(\left(\mathsf{fma}\left(-15, x, 10\right) \cdot x\right) \cdot x\right) \cdot x
Initial program 99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f6498.7%
Applied rewrites98.7%
lift-*.f64N/A
lift-pow.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6498.7%
Applied rewrites98.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.7%
Applied rewrites98.7%
(FPCore (x) :precision binary64 (* (* (* x x) 10.0) x))
double code(double x) {
return ((x * x) * 10.0) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x * x) * 10.0d0) * x
end function
public static double code(double x) {
return ((x * x) * 10.0) * x;
}
def code(x): return ((x * x) * 10.0) * x
function code(x) return Float64(Float64(Float64(x * x) * 10.0) * x) end
function tmp = code(x) tmp = ((x * x) * 10.0) * x; end
code[x_] := N[(N[(N[(x * x), $MachinePrecision] * 10.0), $MachinePrecision] * x), $MachinePrecision]
\left(\left(x \cdot x\right) \cdot 10\right) \cdot x
Initial program 99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f6498.7%
Applied rewrites98.7%
lift-*.f64N/A
lift-pow.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6498.7%
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites97.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6497.6%
Applied rewrites97.6%
(FPCore (x) :precision binary64 (* (* 10.0 x) (* x x)))
double code(double x) {
return (10.0 * x) * (x * x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (10.0d0 * x) * (x * x)
end function
public static double code(double x) {
return (10.0 * x) * (x * x);
}
def code(x): return (10.0 * x) * (x * x)
function code(x) return Float64(Float64(10.0 * x) * Float64(x * x)) end
function tmp = code(x) tmp = (10.0 * x) * (x * x); end
code[x_] := N[(N[(10.0 * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\left(10 \cdot x\right) \cdot \left(x \cdot x\right)
Initial program 99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-pow.f64N/A
lower-+.f64N/A
lower-*.f6498.7%
Applied rewrites98.7%
lift-*.f64N/A
lift-pow.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6498.7%
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites97.6%
herbie shell --seed 1
(FPCore (x)
:name "6*pow(x,5)-15*pow(x,4)+10*pow(x,3)"
:precision binary64
:pre (and (<= 0.0 x) (<= x 1.0))
(+ (- (* 6.0 (pow x 5.0)) (* 15.0 (pow x 4.0))) (* 10.0 (pow x 3.0))))