Average Error: 0.3 → 0.3
Time: 2.8s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[\frac{\left(6 - 9 \cdot x\right) \cdot \mathsf{fma}\left(x, 9, 6\right)}{\mathsf{fma}\left(x, 9, 6\right)} \cdot x\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
\frac{\left(6 - 9 \cdot x\right) \cdot \mathsf{fma}\left(x, 9, 6\right)}{\mathsf{fma}\left(x, 9, 6\right)} \cdot x
double f(double x) {
        double r648590 = 3.0;
        double r648591 = 2.0;
        double r648592 = x;
        double r648593 = r648592 * r648590;
        double r648594 = r648591 - r648593;
        double r648595 = r648590 * r648594;
        double r648596 = r648595 * r648592;
        return r648596;
}

double f(double x) {
        double r648597 = 6.0;
        double r648598 = 9.0;
        double r648599 = x;
        double r648600 = r648598 * r648599;
        double r648601 = r648597 - r648600;
        double r648602 = fma(r648599, r648598, r648597);
        double r648603 = r648601 * r648602;
        double r648604 = r648603 / r648602;
        double r648605 = r648604 * r648599;
        return r648605;
}

Error

Bits error versus x

Target

Original0.3
Target0.2
Herbie0.3
\[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}{\left(6 - 9 \cdot x\right)} \cdot x\]
  3. Using strategy rm
  4. Applied flip--0.3

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

    \[\leadsto \frac{\color{blue}{\left(6 - 9 \cdot x\right) \cdot \mathsf{fma}\left(x, 9, 6\right)}}{6 + 9 \cdot x} \cdot x\]
  6. Simplified0.3

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

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

Reproduce

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