Average Error: 0.2 → 0.1
Time: 9.7s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[\mathsf{fma}\left(x, 6, \left(9 \cdot x\right) \cdot \left(-x\right)\right)\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
\mathsf{fma}\left(x, 6, \left(9 \cdot x\right) \cdot \left(-x\right)\right)
double f(double x) {
        double r650194 = 3.0;
        double r650195 = 2.0;
        double r650196 = x;
        double r650197 = r650196 * r650194;
        double r650198 = r650195 - r650197;
        double r650199 = r650194 * r650198;
        double r650200 = r650199 * r650196;
        return r650200;
}

double f(double x) {
        double r650201 = x;
        double r650202 = 6.0;
        double r650203 = 9.0;
        double r650204 = r650203 * r650201;
        double r650205 = -r650201;
        double r650206 = r650204 * r650205;
        double r650207 = fma(r650201, r650202, r650206);
        return r650207;
}

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.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 6, \left(x \cdot x\right) \cdot \left(-9\right)\right)}\]
  4. Using strategy rm
  5. Applied pow10.1

    \[\leadsto \mathsf{fma}\left(x, 6, \left(x \cdot x\right) \cdot \color{blue}{{\left(-9\right)}^{1}}\right)\]
  6. Applied pow10.1

    \[\leadsto \mathsf{fma}\left(x, 6, \left(x \cdot \color{blue}{{x}^{1}}\right) \cdot {\left(-9\right)}^{1}\right)\]
  7. Applied pow10.1

    \[\leadsto \mathsf{fma}\left(x, 6, \left(\color{blue}{{x}^{1}} \cdot {x}^{1}\right) \cdot {\left(-9\right)}^{1}\right)\]
  8. Applied pow-prod-down0.1

    \[\leadsto \mathsf{fma}\left(x, 6, \color{blue}{{\left(x \cdot x\right)}^{1}} \cdot {\left(-9\right)}^{1}\right)\]
  9. Applied pow-prod-down0.1

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

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

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

Reproduce

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

  :herbie-target
  (- (* 6.0 x) (* 9.0 (* x x)))

  (* (* 3.0 (- 2.0 (* x 3.0))) x))