Average Error: 0.2 → 0.2
Time: 2.0s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[x \cdot \left(6 - 9 \cdot x\right) + x \cdot \mathsf{fma}\left(-x, 9, x \cdot 9\right)\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
x \cdot \left(6 - 9 \cdot x\right) + x \cdot \mathsf{fma}\left(-x, 9, x \cdot 9\right)
double f(double x) {
        double r561262 = 3.0;
        double r561263 = 2.0;
        double r561264 = x;
        double r561265 = r561264 * r561262;
        double r561266 = r561263 - r561265;
        double r561267 = r561262 * r561266;
        double r561268 = r561267 * r561264;
        return r561268;
}

double f(double x) {
        double r561269 = x;
        double r561270 = 6.0;
        double r561271 = 9.0;
        double r561272 = r561271 * r561269;
        double r561273 = r561270 - r561272;
        double r561274 = r561269 * r561273;
        double r561275 = -r561269;
        double r561276 = r561269 * r561271;
        double r561277 = fma(r561275, r561271, r561276);
        double r561278 = r561269 * r561277;
        double r561279 = r561274 + r561278;
        return r561279;
}

Error

Bits error versus x

Target

Original0.2
Target0.2
Herbie0.2
\[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 add-cube-cbrt1.1

    \[\leadsto x \cdot \left(\color{blue}{\left(\sqrt[3]{6} \cdot \sqrt[3]{6}\right) \cdot \sqrt[3]{6}} - 9 \cdot x\right)\]
  6. Applied prod-diff1.1

    \[\leadsto x \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt[3]{6} \cdot \sqrt[3]{6}, \sqrt[3]{6}, -x \cdot 9\right) + \mathsf{fma}\left(-x, 9, x \cdot 9\right)\right)}\]
  7. Applied distribute-lft-in1.1

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

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

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

Reproduce

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