Average Error: 0.2 → 0.1
Time: 12.0s
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 r591426 = x;
        double r591427 = r591426 * r591426;
        double r591428 = 3.0;
        double r591429 = 2.0;
        double r591430 = r591426 * r591429;
        double r591431 = r591428 - r591430;
        double r591432 = r591427 * r591431;
        return r591432;
}

double f(double x) {
        double r591433 = x;
        double r591434 = 3.0;
        double r591435 = r591433 * r591434;
        double r591436 = 3.0;
        double r591437 = pow(r591433, r591436);
        double r591438 = 2.0;
        double r591439 = -r591438;
        double r591440 = r591437 * r591439;
        double r591441 = fma(r591433, r591435, r591440);
        return r591441;
}

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 2019179 +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))))