Average Error: 0.3 → 0.2
Time: 2.7s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[\left(3 \cdot \left(2 - x \cdot 3\right) + 3 \cdot \mathsf{fma}\left(-3, x, 3 \cdot x\right)\right) \cdot x\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
\left(3 \cdot \left(2 - x \cdot 3\right) + 3 \cdot \mathsf{fma}\left(-3, x, 3 \cdot x\right)\right) \cdot x
double f(double x) {
        double r617377 = 3.0;
        double r617378 = 2.0;
        double r617379 = x;
        double r617380 = r617379 * r617377;
        double r617381 = r617378 - r617380;
        double r617382 = r617377 * r617381;
        double r617383 = r617382 * r617379;
        return r617383;
}

double f(double x) {
        double r617384 = 3.0;
        double r617385 = 2.0;
        double r617386 = x;
        double r617387 = r617386 * r617384;
        double r617388 = r617385 - r617387;
        double r617389 = r617384 * r617388;
        double r617390 = -r617384;
        double r617391 = r617384 * r617386;
        double r617392 = fma(r617390, r617386, r617391);
        double r617393 = r617384 * r617392;
        double r617394 = r617389 + r617393;
        double r617395 = r617394 * r617386;
        return r617395;
}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 0.3

    \[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
  2. Using strategy rm
  3. Applied add-sqr-sqrt1.1

    \[\leadsto \left(3 \cdot \left(\color{blue}{\sqrt{2} \cdot \sqrt{2}} - x \cdot 3\right)\right) \cdot x\]
  4. Applied prod-diff1.1

    \[\leadsto \left(3 \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt{2}, \sqrt{2}, -3 \cdot x\right) + \mathsf{fma}\left(-3, x, 3 \cdot x\right)\right)}\right) \cdot x\]
  5. Applied distribute-lft-in1.1

    \[\leadsto \color{blue}{\left(3 \cdot \mathsf{fma}\left(\sqrt{2}, \sqrt{2}, -3 \cdot x\right) + 3 \cdot \mathsf{fma}\left(-3, x, 3 \cdot x\right)\right)} \cdot x\]
  6. Simplified0.2

    \[\leadsto \left(\color{blue}{3 \cdot \left(2 - x \cdot 3\right)} + 3 \cdot \mathsf{fma}\left(-3, x, 3 \cdot x\right)\right) \cdot x\]
  7. Final simplification0.2

    \[\leadsto \left(3 \cdot \left(2 - x \cdot 3\right) + 3 \cdot \mathsf{fma}\left(-3, x, 3 \cdot x\right)\right) \cdot x\]

Reproduce

herbie shell --seed 2020039 +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))