Average Error: 0.1 → 0.1
Time: 11.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 r607955 = 3.0;
        double r607956 = x;
        double r607957 = r607956 * r607955;
        double r607958 = r607957 * r607956;
        double r607959 = 4.0;
        double r607960 = r607956 * r607959;
        double r607961 = r607958 - r607960;
        double r607962 = 1.0;
        double r607963 = r607961 + r607962;
        double r607964 = r607955 * r607963;
        return r607964;
}

double f(double x) {
        double r607965 = x;
        double r607966 = 9.0;
        double r607967 = 12.0;
        double r607968 = -r607967;
        double r607969 = fma(r607965, r607966, r607968);
        double r607970 = 3.0;
        double r607971 = fma(r607965, r607969, r607970);
        return r607971;
}

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