Average Error: 0.3 → 0.3
Time: 8.2s
Precision: 64
Internal Precision: 320
\[\left(d1 \cdot 10 + d1 \cdot d2\right) + d1 \cdot 20\]
\[\left(\left(20 + 10\right) + d2\right) \cdot d1\]

Error

Bits error versus d1

Bits error versus d2

Derivation

  1. Initial program 0.3

    \[\frac{\left(\frac{\left(d1 \cdot \left(real->posit(10)\right)\right)}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot \left(real->posit(20)\right)\right)}\]
  2. Simplified0.3

    \[\leadsto \color{blue}{\left(\frac{\left(real->posit(20)\right)}{\left(\frac{\left(real->posit(10)\right)}{d2}\right)}\right) \cdot d1}\]
  3. Using strategy rm
  4. Applied associate-+r+0.3

    \[\leadsto \color{blue}{\left(\frac{\left(\frac{\left(real->posit(20)\right)}{\left(real->posit(10)\right)}\right)}{d2}\right)} \cdot d1\]
  5. Final simplification0.3

    \[\leadsto \left(\left(20 + 10\right) + d2\right) \cdot d1\]

Reproduce

herbie shell --seed 2019094 +o rules:numerics
(FPCore (d1 d2)
  :name "FastMath test2"
  (+.p16 (+.p16 (*.p16 d1 (real->posit16 10)) (*.p16 d1 d2)) (*.p16 d1 (real->posit16 20))))