Average Error: 0.2 → 0.2
Time: 2.2s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[\mathsf{fma}\left(\mathsf{fma}\left(-x, 9, x \cdot 9\right), x, \mathsf{fma}\left(x, 6, -9 \cdot {x}^{2}\right)\right)\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
\mathsf{fma}\left(\mathsf{fma}\left(-x, 9, x \cdot 9\right), x, \mathsf{fma}\left(x, 6, -9 \cdot {x}^{2}\right)\right)
double code(double x) {
	return ((double) (((double) (3.0 * ((double) (2.0 - ((double) (x * 3.0)))))) * x));
}
double code(double x) {
	return ((double) fma(((double) fma(((double) -(x)), 9.0, ((double) (x * 9.0)))), x, ((double) fma(x, 6.0, ((double) -(((double) (9.0 * ((double) pow(x, 2.0))))))))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.2
Target0.2
Herbie0.2
\[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 add-cube-cbrt1.1

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

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

    \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(\sqrt[3]{6} \cdot \sqrt[3]{6}, \sqrt[3]{6}, -x \cdot 9\right) + x \cdot \mathsf{fma}\left(-x, 9, x \cdot 9\right)}\]
  8. Simplified1.1

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

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

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

Reproduce

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