Average Error: 0.2 → 0.2
Time: 9.5s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[\mathsf{fma}\left(-9, x, 6\right) \cdot x\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
\mathsf{fma}\left(-9, x, 6\right) \cdot x
double f(double x) {
        double r518994 = 3.0;
        double r518995 = 2.0;
        double r518996 = x;
        double r518997 = r518996 * r518994;
        double r518998 = r518995 - r518997;
        double r518999 = r518994 * r518998;
        double r519000 = r518999 * r518996;
        return r519000;
}

double f(double x) {
        double r519001 = 9.0;
        double r519002 = -r519001;
        double r519003 = x;
        double r519004 = 6.0;
        double r519005 = fma(r519002, r519003, r519004);
        double r519006 = r519005 * r519003;
        return r519006;
}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 0.2

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

    \[\leadsto \color{blue}{\left(6 - 9 \cdot x\right)} \cdot x\]
  3. Simplified0.2

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

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

Reproduce

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

  :herbie-target
  (- (* 6.0 x) (* 9.0 (* x x)))

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