Average Error: 0.1 → 0.1
Time: 1.9s
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 r652455 = 3.0;
        double r652456 = x;
        double r652457 = r652456 * r652455;
        double r652458 = r652457 * r652456;
        double r652459 = 4.0;
        double r652460 = r652456 * r652459;
        double r652461 = r652458 - r652460;
        double r652462 = 1.0;
        double r652463 = r652461 + r652462;
        double r652464 = r652455 * r652463;
        return r652464;
}

double f(double x) {
        double r652465 = x;
        double r652466 = 2.0;
        double r652467 = pow(r652465, r652466);
        double r652468 = 9.0;
        double r652469 = 3.0;
        double r652470 = 12.0;
        double r652471 = r652470 * r652465;
        double r652472 = r652469 - r652471;
        double r652473 = fma(r652467, r652468, r652472);
        return r652473;
}

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)))