Average Error: 0.3 → 0.1
Time: 11.7s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[\mathsf{fma}\left(6, x, -9 \cdot {x}^{2}\right)\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
\mathsf{fma}\left(6, x, -9 \cdot {x}^{2}\right)
double f(double x) {
        double r542501 = 3.0;
        double r542502 = 2.0;
        double r542503 = x;
        double r542504 = r542503 * r542501;
        double r542505 = r542502 - r542504;
        double r542506 = r542501 * r542505;
        double r542507 = r542506 * r542503;
        return r542507;
}

double f(double x) {
        double r542508 = 6.0;
        double r542509 = x;
        double r542510 = 9.0;
        double r542511 = 2.0;
        double r542512 = pow(r542509, r542511);
        double r542513 = r542510 * r542512;
        double r542514 = -r542513;
        double r542515 = fma(r542508, r542509, r542514);
        return r542515;
}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 0.3

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

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

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

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

Reproduce

herbie shell --seed 2019209 +o rules:numerics
(FPCore (x)
  :name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, E"
  :precision binary64

  :herbie-target
  (- (* 6 x) (* 9 (* x x)))

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