Average Error: 0.2 → 0.2
Time: 2.9s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[x \cdot \left(6 - x \cdot 9\right) + x \cdot \mathsf{fma}\left(-9, x, 9 \cdot x\right)\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
x \cdot \left(6 - x \cdot 9\right) + x \cdot \mathsf{fma}\left(-9, x, 9 \cdot x\right)
double f(double x) {
        double r693000 = 3.0;
        double r693001 = 2.0;
        double r693002 = x;
        double r693003 = r693002 * r693000;
        double r693004 = r693001 - r693003;
        double r693005 = r693000 * r693004;
        double r693006 = r693005 * r693002;
        return r693006;
}

double f(double x) {
        double r693007 = x;
        double r693008 = 6.0;
        double r693009 = 9.0;
        double r693010 = r693007 * r693009;
        double r693011 = r693008 - r693010;
        double r693012 = r693007 * r693011;
        double r693013 = -r693009;
        double r693014 = r693009 * r693007;
        double r693015 = fma(r693013, r693007, r693014);
        double r693016 = r693007 * r693015;
        double r693017 = r693012 + r693016;
        return r693017;
}

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. Using strategy rm
  3. Applied associate-*l*0.2

    \[\leadsto \color{blue}{3 \cdot \left(\left(2 - x \cdot 3\right) \cdot x\right)}\]
  4. Taylor expanded around 0 0.2

    \[\leadsto \color{blue}{6 \cdot x - 9 \cdot {x}^{2}}\]
  5. Simplified0.2

    \[\leadsto \color{blue}{x \cdot \left(6 - x \cdot 9\right)}\]
  6. Using strategy rm
  7. Applied add-sqr-sqrt0.7

    \[\leadsto x \cdot \left(\color{blue}{\sqrt{6} \cdot \sqrt{6}} - x \cdot 9\right)\]
  8. Applied prod-diff0.7

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

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

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

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

Reproduce

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