Average Error: 0.3 → 0.1
Time: 9.5s
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 r443750 = 3.0;
        double r443751 = 2.0;
        double r443752 = x;
        double r443753 = r443752 * r443750;
        double r443754 = r443751 - r443753;
        double r443755 = r443750 * r443754;
        double r443756 = r443755 * r443752;
        return r443756;
}

double f(double x) {
        double r443757 = 6.0;
        double r443758 = x;
        double r443759 = 9.0;
        double r443760 = 2.0;
        double r443761 = pow(r443758, r443760);
        double r443762 = r443759 * r443761;
        double r443763 = -r443762;
        double r443764 = fma(r443757, r443758, r443763);
        return r443764;
}

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