Average Error: 0.2 → 0
Time: 3.4s
Precision: 64
\[d \cdot 10 + d \cdot 20\]
\[d \cdot \left(20 + 10\right)\]
double f(double d) {
        double r2301581 = d;
        double r2301582 = 10.0;
        double r2301583 = r2301581 * r2301582;
        double r2301584 = 20.0;
        double r2301585 = r2301581 * r2301584;
        double r2301586 = r2301583 + r2301585;
        return r2301586;
}

double f(double d) {
        double r2301587 = d;
        double r2301588 = 20.0;
        double r2301589 = 10.0;
        double r2301590 = r2301588 + r2301589;
        double r2301591 = r2301587 * r2301590;
        return r2301591;
}

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 2019102 +o rules:numerics
(FPCore (d)
  :name "FastMath test1"
  (+.p16 (*.p16 d (real->posit16 10)) (*.p16 d (real->posit16 20))))