Average Error: 0.1 → 0.1
Time: 20.5s
Precision: 64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
\[\mathsf{fma}\left(9, x, -12\right) \cdot x + 3\]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
\mathsf{fma}\left(9, x, -12\right) \cdot x + 3
double f(double x) {
        double r35034534 = 3.0;
        double r35034535 = x;
        double r35034536 = r35034535 * r35034534;
        double r35034537 = r35034536 * r35034535;
        double r35034538 = 4.0;
        double r35034539 = r35034535 * r35034538;
        double r35034540 = r35034537 - r35034539;
        double r35034541 = 1.0;
        double r35034542 = r35034540 + r35034541;
        double r35034543 = r35034534 * r35034542;
        return r35034543;
}

double f(double x) {
        double r35034544 = 9.0;
        double r35034545 = x;
        double r35034546 = 12.0;
        double r35034547 = -r35034546;
        double r35034548 = fma(r35034544, r35034545, r35034547);
        double r35034549 = r35034548 * r35034545;
        double r35034550 = 3.0;
        double r35034551 = r35034549 + r35034550;
        return r35034551;
}

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 add-cube-cbrt0.1

    \[\leadsto \color{blue}{\left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}\right)} \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
  4. Applied associate-*l*0.2

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

    \[\leadsto \left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \color{blue}{\left(\sqrt[3]{3} \cdot \mathsf{fma}\left(x, 3 \cdot x - 4, 1\right)\right)}\]
  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}{x \cdot \left(9 \cdot x - 12\right) + 3}\]
  8. Using strategy rm
  9. Applied fma-neg0.1

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

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

Reproduce

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

  :herbie-target
  (+ 3.0 (- (* (* 9.0 x) x) (* 12.0 x)))

  (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))