Average Error: 0.3 → 0.2
Time: 2.0s
Precision: binary64
\[\left(3 \cdot \left(2 - x \cdot 3\right)\right) \cdot x\]
\[x \cdot 6 + x \cdot \left(x \cdot \left(-9\right)\right)\]

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. 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 - x \cdot 9\right)}\]
  4. Using strategy rm
  5. Applied sub-neg0.2

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

    \[\leadsto \color{blue}{x \cdot 6 + x \cdot \left(-x \cdot 9\right)}\]
  7. Simplified0.2

    \[\leadsto x \cdot 6 + \color{blue}{x \cdot \left(x \cdot \left(-9\right)\right)}\]
  8. Final simplification0.2

    \[\leadsto x \cdot 6 + x \cdot \left(x \cdot \left(-9\right)\right)\]

Reproduce

herbie shell --seed 2020182 
(FPCore (x)
  :name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, E"
  :precision binary64

  :herbie-target
  (- (* 6.0 x) (* 9.0 (* x x)))

  (* (* 3.0 (- 2.0 (* x 3.0))) x))