Average Error: 0.1 → 0.1
Time: 17.1s
Precision: 64
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)\]
\[\mathsf{fma}\left(x, \mathsf{fma}\left(x, 9, -12\right), 3\right)\]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
\mathsf{fma}\left(x, \mathsf{fma}\left(x, 9, -12\right), 3\right)
double f(double x) {
        double r531131 = 3.0;
        double r531132 = x;
        double r531133 = r531132 * r531131;
        double r531134 = r531133 * r531132;
        double r531135 = 4.0;
        double r531136 = r531132 * r531135;
        double r531137 = r531134 - r531136;
        double r531138 = 1.0;
        double r531139 = r531137 + r531138;
        double r531140 = r531131 * r531139;
        return r531140;
}

double f(double x) {
        double r531141 = x;
        double r531142 = 9.0;
        double r531143 = 12.0;
        double r531144 = -r531143;
        double r531145 = fma(r531141, r531142, r531144);
        double r531146 = 3.0;
        double r531147 = fma(r531141, r531145, r531146);
        return r531147;
}

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}{3 \cdot \mathsf{fma}\left(x, x \cdot 3 - 4, 1\right)}\]
  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, \mathsf{fma}\left(x, 9, -12\right), 3\right)}\]
  5. Final simplification0.1

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

Reproduce

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