Average Error: 0.2 → 0.1
Time: 2.6s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[\mathsf{fma}\left(x, 6, -{x}^{2} \cdot 9\right)\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
\mathsf{fma}\left(x, 6, -{x}^{2} \cdot 9\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(x, 6.0, ((double) -(((double) (((double) pow(x, 2.0)) * 9.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.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. Using strategy rm
  4. Applied *-commutative0.2

    \[\leadsto \color{blue}{x \cdot 6} - 9 \cdot {x}^{2}\]
  5. Applied fma-neg0.1

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

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

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

Reproduce

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