Average Error: 0.1 → 0.1
Time: 7.3s
Precision: 64
\[3.0 \cdot \left(\left(\left(x \cdot 3.0\right) \cdot x - x \cdot 4.0\right) + 1.0\right)\]
\[\mathsf{fma}\left(-\sqrt[3]{12.0}, \sqrt[3]{12.0} \cdot \sqrt[3]{12.0}, \left(\sqrt[3]{12.0} \cdot \sqrt[3]{12.0}\right) \cdot \sqrt[3]{12.0}\right) \cdot x + \mathsf{fma}\left(9.0 \cdot x - 12.0, x, 3.0\right)\]
3.0 \cdot \left(\left(\left(x \cdot 3.0\right) \cdot x - x \cdot 4.0\right) + 1.0\right)
\mathsf{fma}\left(-\sqrt[3]{12.0}, \sqrt[3]{12.0} \cdot \sqrt[3]{12.0}, \left(\sqrt[3]{12.0} \cdot \sqrt[3]{12.0}\right) \cdot \sqrt[3]{12.0}\right) \cdot x + \mathsf{fma}\left(9.0 \cdot x - 12.0, x, 3.0\right)
double f(double x) {
        double r12182615 = 3.0;
        double r12182616 = x;
        double r12182617 = r12182616 * r12182615;
        double r12182618 = r12182617 * r12182616;
        double r12182619 = 4.0;
        double r12182620 = r12182616 * r12182619;
        double r12182621 = r12182618 - r12182620;
        double r12182622 = 1.0;
        double r12182623 = r12182621 + r12182622;
        double r12182624 = r12182615 * r12182623;
        return r12182624;
}

double f(double x) {
        double r12182625 = 12.0;
        double r12182626 = cbrt(r12182625);
        double r12182627 = -r12182626;
        double r12182628 = r12182626 * r12182626;
        double r12182629 = r12182628 * r12182626;
        double r12182630 = fma(r12182627, r12182628, r12182629);
        double r12182631 = x;
        double r12182632 = r12182630 * r12182631;
        double r12182633 = 9.0;
        double r12182634 = r12182633 * r12182631;
        double r12182635 = r12182634 - r12182625;
        double r12182636 = 3.0;
        double r12182637 = fma(r12182635, r12182631, r12182636);
        double r12182638 = r12182632 + r12182637;
        return r12182638;
}

Error

Bits error versus x

Target

Original0.1
Target0.1
Herbie0.1
\[3.0 + \left(\left(9.0 \cdot x\right) \cdot x - 12.0 \cdot x\right)\]

Derivation

  1. Initial program 0.1

    \[3.0 \cdot \left(\left(\left(x \cdot 3.0\right) \cdot x - x \cdot 4.0\right) + 1.0\right)\]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x \cdot 3.0 - 4.0, 1.0\right) \cdot 3.0}\]
  3. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{\left(9.0 \cdot {x}^{2} + 3.0\right) - 12.0 \cdot x}\]
  4. Simplified0.1

    \[\leadsto \color{blue}{3.0 + x \cdot \left(x \cdot 9.0 - 12.0\right)}\]
  5. Using strategy rm
  6. Applied add-cube-cbrt0.1

    \[\leadsto 3.0 + x \cdot \left(x \cdot 9.0 - \color{blue}{\left(\sqrt[3]{12.0} \cdot \sqrt[3]{12.0}\right) \cdot \sqrt[3]{12.0}}\right)\]
  7. Applied prod-diff0.1

    \[\leadsto 3.0 + x \cdot \color{blue}{\left(\mathsf{fma}\left(x, 9.0, -\sqrt[3]{12.0} \cdot \left(\sqrt[3]{12.0} \cdot \sqrt[3]{12.0}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{12.0}, \sqrt[3]{12.0} \cdot \sqrt[3]{12.0}, \sqrt[3]{12.0} \cdot \left(\sqrt[3]{12.0} \cdot \sqrt[3]{12.0}\right)\right)\right)}\]
  8. Applied distribute-lft-in0.1

    \[\leadsto 3.0 + \color{blue}{\left(x \cdot \mathsf{fma}\left(x, 9.0, -\sqrt[3]{12.0} \cdot \left(\sqrt[3]{12.0} \cdot \sqrt[3]{12.0}\right)\right) + x \cdot \mathsf{fma}\left(-\sqrt[3]{12.0}, \sqrt[3]{12.0} \cdot \sqrt[3]{12.0}, \sqrt[3]{12.0} \cdot \left(\sqrt[3]{12.0} \cdot \sqrt[3]{12.0}\right)\right)\right)}\]
  9. Applied associate-+r+0.1

    \[\leadsto \color{blue}{\left(3.0 + x \cdot \mathsf{fma}\left(x, 9.0, -\sqrt[3]{12.0} \cdot \left(\sqrt[3]{12.0} \cdot \sqrt[3]{12.0}\right)\right)\right) + x \cdot \mathsf{fma}\left(-\sqrt[3]{12.0}, \sqrt[3]{12.0} \cdot \sqrt[3]{12.0}, \sqrt[3]{12.0} \cdot \left(\sqrt[3]{12.0} \cdot \sqrt[3]{12.0}\right)\right)}\]
  10. Simplified0.1

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

    \[\leadsto \mathsf{fma}\left(-\sqrt[3]{12.0}, \sqrt[3]{12.0} \cdot \sqrt[3]{12.0}, \left(\sqrt[3]{12.0} \cdot \sqrt[3]{12.0}\right) \cdot \sqrt[3]{12.0}\right) \cdot x + \mathsf{fma}\left(9.0 \cdot x - 12.0, x, 3.0\right)\]

Reproduce

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