Average Error: 0.2 → 0.1
Time: 6.5s
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 r12534360 = 3.0;
        double r12534361 = 2.0;
        double r12534362 = x;
        double r12534363 = r12534362 * r12534360;
        double r12534364 = r12534361 - r12534363;
        double r12534365 = r12534360 * r12534364;
        double r12534366 = r12534365 * r12534362;
        return r12534366;
}

double f(double x) {
        double r12534367 = x;
        double r12534368 = 6.0;
        double r12534369 = r12534367 * r12534367;
        double r12534370 = 9.0;
        double r12534371 = r12534369 * r12534370;
        double r12534372 = -r12534371;
        double r12534373 = fma(r12534367, r12534368, r12534372);
        return r12534373;
}

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. Taylor expanded around 0 0.2

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

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

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

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

Reproduce

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