Average Error: 0.2 → 0.1
Time: 11.9s
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 r873768 = 3.0;
        double r873769 = 2.0;
        double r873770 = x;
        double r873771 = r873770 * r873768;
        double r873772 = r873769 - r873771;
        double r873773 = r873768 * r873772;
        double r873774 = r873773 * r873770;
        return r873774;
}

double f(double x) {
        double r873775 = 6.0;
        double r873776 = x;
        double r873777 = 9.0;
        double r873778 = 2.0;
        double r873779 = pow(r873776, r873778);
        double r873780 = r873777 * r873779;
        double r873781 = -r873780;
        double r873782 = fma(r873775, r873776, r873781);
        return r873782;
}

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. Simplified0.2

    \[\leadsto \color{blue}{x \cdot \left(6 - 9 \cdot x\right)}\]
  4. Using strategy rm
  5. Applied sub-neg0.2

    \[\leadsto x \cdot \color{blue}{\left(6 + \left(-9 \cdot x\right)\right)}\]
  6. Applied distribute-lft-in0.2

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

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

    \[\leadsto 6 \cdot x + \color{blue}{\left(-9 \cdot {x}^{2}\right)}\]
  9. Using strategy rm
  10. Applied fma-def0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(6, x, -9 \cdot {x}^{2}\right)}\]
  11. Final simplification0.1

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

Reproduce

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