Average Error: 0.2 → 0.1
Time: 10.1s
Precision: 64
\[\left(x \cdot x\right) \cdot \left(3 - x \cdot 2\right)\]
\[\mathsf{fma}\left(3, {x}^{2}, \left(-{x}^{3}\right) \cdot 2\right)\]
\left(x \cdot x\right) \cdot \left(3 - x \cdot 2\right)
\mathsf{fma}\left(3, {x}^{2}, \left(-{x}^{3}\right) \cdot 2\right)
double f(double x) {
        double r594670 = x;
        double r594671 = r594670 * r594670;
        double r594672 = 3.0;
        double r594673 = 2.0;
        double r594674 = r594670 * r594673;
        double r594675 = r594672 - r594674;
        double r594676 = r594671 * r594675;
        return r594676;
}

double f(double x) {
        double r594677 = 3.0;
        double r594678 = x;
        double r594679 = 2.0;
        double r594680 = pow(r594678, r594679);
        double r594681 = 3.0;
        double r594682 = pow(r594678, r594681);
        double r594683 = -r594682;
        double r594684 = 2.0;
        double r594685 = r594683 * r594684;
        double r594686 = fma(r594677, r594680, r594685);
        return r594686;
}

Error

Bits error versus x

Target

Original0.2
Target0.2
Herbie0.1
\[x \cdot \left(x \cdot \left(3 - x \cdot 2\right)\right)\]

Derivation

  1. Initial program 0.2

    \[\left(x \cdot x\right) \cdot \left(3 - x \cdot 2\right)\]
  2. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{3 \cdot {x}^{2} - 2 \cdot {x}^{3}}\]
  3. Using strategy rm
  4. Applied fma-neg0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(3, {x}^{2}, -2 \cdot {x}^{3}\right)}\]
  5. Simplified0.1

    \[\leadsto \mathsf{fma}\left(3, {x}^{2}, \color{blue}{\left(-{x}^{3}\right) \cdot 2}\right)\]
  6. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(3, {x}^{2}, \left(-{x}^{3}\right) \cdot 2\right)\]

Reproduce

herbie shell --seed 2019212 +o rules:numerics
(FPCore (x)
  :name "Data.Spline.Key:interpolateKeys from smoothie-0.4.0.2"
  :precision binary64

  :herbie-target
  (* x (* x (- 3 (* x 2))))

  (* (* x x) (- 3 (* x 2))))