Average Error: 0.1 → 0.1
Time: 2.1s
Precision: 64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
\[\mathsf{fma}\left({x}^{2}, 9, 3 - 12 \cdot x\right)\]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
\mathsf{fma}\left({x}^{2}, 9, 3 - 12 \cdot x\right)
double f(double x) {
        double r650723 = 3.0;
        double r650724 = x;
        double r650725 = r650724 * r650723;
        double r650726 = r650725 * r650724;
        double r650727 = 4.0;
        double r650728 = r650724 * r650727;
        double r650729 = r650726 - r650728;
        double r650730 = 1.0;
        double r650731 = r650729 + r650730;
        double r650732 = r650723 * r650731;
        return r650732;
}

double f(double x) {
        double r650733 = x;
        double r650734 = 2.0;
        double r650735 = pow(r650733, r650734);
        double r650736 = 9.0;
        double r650737 = 3.0;
        double r650738 = 12.0;
        double r650739 = r650738 * r650733;
        double r650740 = r650737 - r650739;
        double r650741 = fma(r650735, r650736, r650740);
        return r650741;
}

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. Simplified0.1

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

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

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

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

Reproduce

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