Average Error: 0.2 → 0
Time: 3.6s
Precision: 64
\[d \cdot 10 + d \cdot 20\]
\[d \cdot \left(20 + 10\right)\]
double f(double d) {
        double r1616832 = d;
        double r1616833 = 10.0;
        double r1616834 = r1616832 * r1616833;
        double r1616835 = 20.0;
        double r1616836 = r1616832 * r1616835;
        double r1616837 = r1616834 + r1616836;
        return r1616837;
}

double f(double d) {
        double r1616838 = d;
        double r1616839 = 20.0;
        double r1616840 = 10.0;
        double r1616841 = r1616839 + r1616840;
        double r1616842 = r1616838 * r1616841;
        return r1616842;
}

d \cdot 10 + d \cdot 20
d \cdot \left(20 + 10\right)

Error

Bits error versus d

Derivation

  1. Initial program 0.2

    \[\frac{\left(d \cdot \left(10\right)\right)}{\left(d \cdot \left(20\right)\right)}\]
  2. Simplified0

    \[\leadsto \color{blue}{d \cdot \left(\frac{\left(20\right)}{\left(10\right)}\right)}\]
  3. Final simplification0

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

Reproduce

herbie shell --seed 2019101 +o rules:numerics
(FPCore (d)
  :name "FastMath test1"
  (+.p16 (*.p16 d (real->posit16 10)) (*.p16 d (real->posit16 20))))