Average Error: 0.2 → 0.1
Time: 9.8s
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 r412753 = 3.0;
        double r412754 = 2.0;
        double r412755 = x;
        double r412756 = r412755 * r412753;
        double r412757 = r412754 - r412756;
        double r412758 = r412753 * r412757;
        double r412759 = r412758 * r412755;
        return r412759;
}

double f(double x) {
        double r412760 = 6.0;
        double r412761 = x;
        double r412762 = 9.0;
        double r412763 = 2.0;
        double r412764 = pow(r412761, r412763);
        double r412765 = r412762 * r412764;
        double r412766 = -r412765;
        double r412767 = fma(r412760, r412761, r412766);
        return r412767;
}

Error

Bits error versus x

Target

Original0.2
Target0.2
Herbie0.1
\[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}{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 2019212 +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))