Average Error: 0.2 → 0.1
Time: 11.7s
Precision: 64
\[\left(x \cdot x\right) \cdot \left(3 - x \cdot 2\right)\]
\[\mathsf{fma}\left(x, x \cdot 3, {x}^{3} \cdot \left(-2\right)\right)\]
\left(x \cdot x\right) \cdot \left(3 - x \cdot 2\right)
\mathsf{fma}\left(x, x \cdot 3, {x}^{3} \cdot \left(-2\right)\right)
double f(double x) {
        double r1168760 = x;
        double r1168761 = r1168760 * r1168760;
        double r1168762 = 3.0;
        double r1168763 = 2.0;
        double r1168764 = r1168760 * r1168763;
        double r1168765 = r1168762 - r1168764;
        double r1168766 = r1168761 * r1168765;
        return r1168766;
}

double f(double x) {
        double r1168767 = x;
        double r1168768 = 3.0;
        double r1168769 = r1168767 * r1168768;
        double r1168770 = 3.0;
        double r1168771 = pow(r1168767, r1168770);
        double r1168772 = 2.0;
        double r1168773 = -r1168772;
        double r1168774 = r1168771 * r1168773;
        double r1168775 = fma(r1168767, r1168769, r1168774);
        return r1168775;
}

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. Simplified0.1

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

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

Reproduce

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

  :herbie-target
  (* x (* x (- 3.0 (* x 2.0))))

  (* (* x x) (- 3.0 (* x 2.0))))