Average Error: 0.2 → 0.1
Time: 11.6s
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 r447784 = 3.0;
        double r447785 = 2.0;
        double r447786 = x;
        double r447787 = r447786 * r447784;
        double r447788 = r447785 - r447787;
        double r447789 = r447784 * r447788;
        double r447790 = r447789 * r447786;
        return r447790;
}

double f(double x) {
        double r447791 = 6.0;
        double r447792 = x;
        double r447793 = 9.0;
        double r447794 = 2.0;
        double r447795 = pow(r447792, r447794);
        double r447796 = r447793 * r447795;
        double r447797 = -r447796;
        double r447798 = fma(r447791, r447792, r447797);
        return r447798;
}

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