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(6 \cdot 1, x, -{x}^{2} \cdot 9\right)\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
\mathsf{fma}\left(6 \cdot 1, x, -{x}^{2} \cdot 9\right)
double code(double x) {
	return ((3.0 * (2.0 - (x * 3.0))) * x);
}
double code(double x) {
	return fma((6.0 * 1.0), x, -(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 *-un-lft-identity0.2

    \[\leadsto 6 \cdot \color{blue}{\left(1 \cdot x\right)} - 9 \cdot {x}^{2}\]
  5. Applied associate-*r*0.2

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

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

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

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

Reproduce

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