Average Error: 0.2 → 0.1
Time: 13.8s
Precision: 64
\[\left(3.0 \cdot \left(2.0 - x \cdot 3.0\right)\right) \cdot x\]
\[\mathsf{fma}\left(x, 6.0, -\left(x \cdot x\right) \cdot 9.0\right)\]
\left(3.0 \cdot \left(2.0 - x \cdot 3.0\right)\right) \cdot x
\mathsf{fma}\left(x, 6.0, -\left(x \cdot x\right) \cdot 9.0\right)
double f(double x) {
        double r28360940 = 3.0;
        double r28360941 = 2.0;
        double r28360942 = x;
        double r28360943 = r28360942 * r28360940;
        double r28360944 = r28360941 - r28360943;
        double r28360945 = r28360940 * r28360944;
        double r28360946 = r28360945 * r28360942;
        return r28360946;
}

double f(double x) {
        double r28360947 = x;
        double r28360948 = 6.0;
        double r28360949 = r28360947 * r28360947;
        double r28360950 = 9.0;
        double r28360951 = r28360949 * r28360950;
        double r28360952 = -r28360951;
        double r28360953 = fma(r28360947, r28360948, r28360952);
        return r28360953;
}

Error

Bits error versus x

Target

Original0.2
Target0.2
Herbie0.1
\[6.0 \cdot x - 9.0 \cdot \left(x \cdot x\right)\]

Derivation

  1. Initial program 0.2

    \[\left(3.0 \cdot \left(2.0 - x \cdot 3.0\right)\right) \cdot x\]
  2. Using strategy rm
  3. Applied flip--0.3

    \[\leadsto \left(3.0 \cdot \color{blue}{\frac{2.0 \cdot 2.0 - \left(x \cdot 3.0\right) \cdot \left(x \cdot 3.0\right)}{2.0 + x \cdot 3.0}}\right) \cdot x\]
  4. Applied associate-*r/0.3

    \[\leadsto \color{blue}{\frac{3.0 \cdot \left(2.0 \cdot 2.0 - \left(x \cdot 3.0\right) \cdot \left(x \cdot 3.0\right)\right)}{2.0 + x \cdot 3.0}} \cdot x\]
  5. Taylor expanded around 0 0.2

    \[\leadsto \color{blue}{6.0 \cdot x - 9.0 \cdot {x}^{2}}\]
  6. Simplified0.2

    \[\leadsto \color{blue}{x \cdot 6.0 - \left(x \cdot x\right) \cdot 9.0}\]
  7. Using strategy rm
  8. Applied fma-neg0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 6.0, -\left(x \cdot x\right) \cdot 9.0\right)}\]
  9. Final simplification0.1

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

Reproduce

herbie shell --seed 2019158 +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))