Average Error: 0.2 → 0.1
Time: 12.2s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[\mathsf{fma}\left(x, 6, -9 \cdot {x}^{2}\right)\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
\mathsf{fma}\left(x, 6, -9 \cdot {x}^{2}\right)
double f(double x) {
        double r567569 = 3.0;
        double r567570 = 2.0;
        double r567571 = x;
        double r567572 = r567571 * r567569;
        double r567573 = r567570 - r567572;
        double r567574 = r567569 * r567573;
        double r567575 = r567574 * r567571;
        return r567575;
}

double f(double x) {
        double r567576 = x;
        double r567577 = 6.0;
        double r567578 = 9.0;
        double r567579 = 2.0;
        double r567580 = pow(r567576, r567579);
        double r567581 = r567578 * r567580;
        double r567582 = -r567581;
        double r567583 = fma(r567576, r567577, r567582);
        return r567583;
}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 0.2

    \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
  2. Taylor expanded around 0 0.2

    \[\leadsto \color{blue}{6 \cdot x - 9 \cdot {x}^{2}}\]
  3. Simplified0.2

    \[\leadsto \color{blue}{x \cdot \left(6 - 9 \cdot x\right)}\]
  4. Using strategy rm
  5. Applied sub-neg0.2

    \[\leadsto x \cdot \color{blue}{\left(6 + \left(-9 \cdot x\right)\right)}\]
  6. Applied distribute-lft-in0.2

    \[\leadsto \color{blue}{x \cdot 6 + x \cdot \left(-9 \cdot x\right)}\]
  7. Simplified0.2

    \[\leadsto x \cdot 6 + \color{blue}{\left(-9 \cdot {x}^{2}\right)}\]
  8. Using strategy rm
  9. Applied fma-def0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 6, -9 \cdot {x}^{2}\right)}\]
  10. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(x, 6, -9 \cdot {x}^{2}\right)\]

Reproduce

herbie shell --seed 2019323 +o rules:numerics
(FPCore (x)
  :name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, E"
  :precision binary64

  :herbie-target
  (- (* 6 x) (* 9 (* x x)))

  (* (* 3 (- 2 (* x 3))) x))