Average Error: 0.1 → 0.1
Time: 10.4s
Precision: 64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
\[\mathsf{fma}\left(9, {x}^{2}, 3\right) - 12 \cdot x\]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
\mathsf{fma}\left(9, {x}^{2}, 3\right) - 12 \cdot x
double f(double x) {
        double r722687 = 3.0;
        double r722688 = x;
        double r722689 = r722688 * r722687;
        double r722690 = r722689 * r722688;
        double r722691 = 4.0;
        double r722692 = r722688 * r722691;
        double r722693 = r722690 - r722692;
        double r722694 = 1.0;
        double r722695 = r722693 + r722694;
        double r722696 = r722687 * r722695;
        return r722696;
}

double f(double x) {
        double r722697 = 9.0;
        double r722698 = x;
        double r722699 = 2.0;
        double r722700 = pow(r722698, r722699);
        double r722701 = 3.0;
        double r722702 = fma(r722697, r722700, r722701);
        double r722703 = 12.0;
        double r722704 = r722703 * r722698;
        double r722705 = r722702 - r722704;
        return r722705;
}

Error

Bits error versus x

Target

Original0.1
Target0.1
Herbie0.1
\[3 + \left(\left(9 \cdot x\right) \cdot x - 12 \cdot x\right)\]

Derivation

  1. Initial program 0.1

    \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
  2. Using strategy rm
  3. Applied distribute-lft-in0.1

    \[\leadsto \color{blue}{3 \cdot \left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 3 \cdot 1}\]
  4. Simplified0.1

    \[\leadsto \color{blue}{3 \cdot \left(x \cdot \left(x \cdot 3 - 4\right)\right)} + 3 \cdot 1\]
  5. Simplified0.1

    \[\leadsto 3 \cdot \left(x \cdot \left(x \cdot 3 - 4\right)\right) + \color{blue}{1 \cdot 3}\]
  6. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{\left(9 \cdot {x}^{2} + 3\right) - 12 \cdot x}\]
  7. Simplified0.1

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

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

Reproduce

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

  :herbie-target
  (+ 3 (- (* (* 9 x) x) (* 12 x)))

  (* 3 (+ (- (* (* x 3) x) (* x 4)) 1)))