Average Error: 0.2 → 0.1
Time: 15.8s
Precision: 64
\[\left(3.0 \cdot \left(2.0 - x \cdot 3.0\right)\right) \cdot x\]
\[\mathsf{fma}\left(6.0, x, \left(x \cdot x\right) \cdot -9.0\right)\]
\left(3.0 \cdot \left(2.0 - x \cdot 3.0\right)\right) \cdot x
\mathsf{fma}\left(6.0, x, \left(x \cdot x\right) \cdot -9.0\right)
double f(double x) {
        double r33419799 = 3.0;
        double r33419800 = 2.0;
        double r33419801 = x;
        double r33419802 = r33419801 * r33419799;
        double r33419803 = r33419800 - r33419802;
        double r33419804 = r33419799 * r33419803;
        double r33419805 = r33419804 * r33419801;
        return r33419805;
}

double f(double x) {
        double r33419806 = 6.0;
        double r33419807 = x;
        double r33419808 = r33419807 * r33419807;
        double r33419809 = -9.0;
        double r33419810 = r33419808 * r33419809;
        double r33419811 = fma(r33419806, r33419807, r33419810);
        return r33419811;
}

Error

Bits error versus x

Target

Original0.2
Target0.2
Herbie0.1
\[6.0 \cdot x - 9.0 \cdot \left(x \cdot x\right)\]

Derivation

  1. Initial program 0.2

    \[\left(3.0 \cdot \left(2.0 - x \cdot 3.0\right)\right) \cdot x\]
  2. Taylor expanded around 0 0.2

    \[\leadsto \color{blue}{6.0 \cdot x - 9.0 \cdot {x}^{2}}\]
  3. Simplified0.2

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

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

    \[\leadsto \color{blue}{6.0 \cdot x + \left(-x \cdot 9.0\right) \cdot x}\]
  7. Using strategy rm
  8. Applied fma-def0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(6.0, x, \left(-x \cdot 9.0\right) \cdot x\right)}\]
  9. Taylor expanded around 0 0.1

    \[\leadsto \mathsf{fma}\left(6.0, x, \color{blue}{-9.0 \cdot {x}^{2}}\right)\]
  10. Simplified0.1

    \[\leadsto \mathsf{fma}\left(6.0, x, \color{blue}{\left(x \cdot x\right) \cdot -9.0}\right)\]
  11. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(6.0, x, \left(x \cdot x\right) \cdot -9.0\right)\]

Reproduce

herbie shell --seed 2019164 +o rules:numerics
(FPCore (x)
  :name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, E"

  :herbie-target
  (- (* 6.0 x) (* 9.0 (* x x)))

  (* (* 3.0 (- 2.0 (* x 3.0))) x))