Average Error: 0.3 → 0.2
Time: 2.2s
Precision: 64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[\left(x \cdot 6 + -9 \cdot {x}^{2}\right) + x \cdot \mathsf{fma}\left(-x, 9, x \cdot 9\right)\]
\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x
\left(x \cdot 6 + -9 \cdot {x}^{2}\right) + x \cdot \mathsf{fma}\left(-x, 9, x \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) (((double) (((double) (x * 6.0)) + ((double) (-9.0 * ((double) pow(x, 2.0)))))) + ((double) (x * ((double) fma(((double) -(x)), 9.0, ((double) (x * 9.0))))))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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. 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-sqr-sqrt0.7

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

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

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

    \[\leadsto \color{blue}{x \cdot \left(6 - 9 \cdot x\right)} + x \cdot \mathsf{fma}\left(-x, 9, x \cdot 9\right)\]
  9. Using strategy rm
  10. Applied sub-neg0.2

    \[\leadsto x \cdot \color{blue}{\left(6 + \left(-9 \cdot x\right)\right)} + x \cdot \mathsf{fma}\left(-x, 9, x \cdot 9\right)\]
  11. Applied distribute-lft-in0.2

    \[\leadsto \color{blue}{\left(x \cdot 6 + x \cdot \left(-9 \cdot x\right)\right)} + x \cdot \mathsf{fma}\left(-x, 9, x \cdot 9\right)\]
  12. Taylor expanded around 0 0.2

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

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

Reproduce

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