Average Error: 0.2 → 0.1
Time: 2.4s
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 r703981 = 3.0;
        double r703982 = x;
        double r703983 = r703982 * r703981;
        double r703984 = r703983 * r703982;
        double r703985 = 4.0;
        double r703986 = r703982 * r703985;
        double r703987 = r703984 - r703986;
        double r703988 = 1.0;
        double r703989 = r703987 + r703988;
        double r703990 = r703981 * r703989;
        return r703990;
}

double f(double x) {
        double r703991 = x;
        double r703992 = 2.0;
        double r703993 = pow(r703991, r703992);
        double r703994 = 9.0;
        double r703995 = 3.0;
        double r703996 = 12.0;
        double r703997 = r703996 * r703991;
        double r703998 = r703995 - r703997;
        double r703999 = fma(r703993, r703994, r703998);
        return r703999;
}

Error

Bits error versus x

Target

Original0.2
Target0.1
Herbie0.1
\[3 + \left(\left(9 \cdot x\right) \cdot x - 12 \cdot x\right)\]

Derivation

  1. Initial program 0.2

    \[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 2020056 +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)))