Average Error: 0.3 → 0.2
Time: 9.4s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[\mathsf{fma}\left(x, 6, -\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot {x}^{2}\right)\right)\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
\mathsf{fma}\left(x, 6, -\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot {x}^{2}\right)\right)
double f(double x) {
        double r576630 = 3.0;
        double r576631 = 2.0;
        double r576632 = x;
        double r576633 = r576632 * r576630;
        double r576634 = r576631 - r576633;
        double r576635 = r576630 * r576634;
        double r576636 = r576635 * r576632;
        return r576636;
}

double f(double x) {
        double r576637 = x;
        double r576638 = 6.0;
        double r576639 = 9.0;
        double r576640 = cbrt(r576639);
        double r576641 = r576640 * r576640;
        double r576642 = 2.0;
        double r576643 = pow(r576637, r576642);
        double r576644 = r576640 * r576643;
        double r576645 = r576641 * r576644;
        double r576646 = -r576645;
        double r576647 = fma(r576637, r576638, r576646);
        return r576647;
}

Error

Bits error versus x

Target

Original0.3
Target0.2
Herbie0.2
\[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}{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 x \cdot 6 + \color{blue}{\left(-9 \cdot {x}^{2}\right)}\]
  8. Using strategy rm
  9. Applied fma-def0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 6, -9 \cdot {x}^{2}\right)}\]
  10. Using strategy rm
  11. Applied add-cube-cbrt0.1

    \[\leadsto \mathsf{fma}\left(x, 6, -\color{blue}{\left(\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \sqrt[3]{9}\right)} \cdot {x}^{2}\right)\]
  12. Applied associate-*l*0.2

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

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

Reproduce

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