Average Error: 0.2 → 0.2
Time: 15.8s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[x \cdot \left(\mathsf{fma}\left(-x, 9, 9 \cdot x\right) + \left(6 - 9 \cdot x\right)\right)\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
x \cdot \left(\mathsf{fma}\left(-x, 9, 9 \cdot x\right) + \left(6 - 9 \cdot x\right)\right)
double f(double x) {
        double r32702751 = 3.0;
        double r32702752 = 2.0;
        double r32702753 = x;
        double r32702754 = r32702753 * r32702751;
        double r32702755 = r32702752 - r32702754;
        double r32702756 = r32702751 * r32702755;
        double r32702757 = r32702756 * r32702753;
        return r32702757;
}

double f(double x) {
        double r32702758 = x;
        double r32702759 = -r32702758;
        double r32702760 = 9.0;
        double r32702761 = r32702760 * r32702758;
        double r32702762 = fma(r32702759, r32702760, r32702761);
        double r32702763 = 6.0;
        double r32702764 = r32702763 - r32702761;
        double r32702765 = r32702762 + r32702764;
        double r32702766 = r32702758 * r32702765;
        return r32702766;
}

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}{\left(6 - 9 \cdot x\right)} \cdot x\]
  3. Using strategy rm
  4. Applied add-cube-cbrt1.1

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

    \[\leadsto \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)} \cdot x\]
  6. Simplified0.2

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

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

Reproduce

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