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 r630267 = 3.0;
        double r630268 = x;
        double r630269 = r630268 * r630267;
        double r630270 = r630269 * r630268;
        double r630271 = 4.0;
        double r630272 = r630268 * r630271;
        double r630273 = r630270 - r630272;
        double r630274 = 1.0;
        double r630275 = r630273 + r630274;
        double r630276 = r630267 * r630275;
        return r630276;
}

double f(double x) {
        double r630277 = x;
        double r630278 = 2.0;
        double r630279 = pow(r630277, r630278);
        double r630280 = 9.0;
        double r630281 = 3.0;
        double r630282 = 12.0;
        double r630283 = r630282 * r630277;
        double r630284 = r630281 - r630283;
        double r630285 = fma(r630279, r630280, r630284);
        return r630285;
}

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