Average Error: 0.3 → 0.3
Time: 9.2s
Precision: 64
\[\frac{\left(\frac{\left(d1 \cdot \left(10\right)\right)}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot \left(20\right)\right)}\]
\[d1 \cdot \left(10 + d2\right) + d1 \cdot 20\]
\frac{\left(\frac{\left(d1 \cdot \left(10\right)\right)}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot \left(20\right)\right)}
d1 \cdot \left(10 + d2\right) + d1 \cdot 20
double f(double d1, double d2) {
        double r514207 = d1;
        double r514208 = 10.0;
        double r514209 = /* ERROR: no posit support in C */;
        double r514210 = r514207 * r514209;
        double r514211 = d2;
        double r514212 = r514207 * r514211;
        double r514213 = r514210 + r514212;
        double r514214 = 20.0;
        double r514215 = /* ERROR: no posit support in C */;
        double r514216 = r514207 * r514215;
        double r514217 = r514213 + r514216;
        return r514217;
}

double f(double d1, double d2) {
        double r514218 = d1;
        double r514219 = 10.0;
        double r514220 = d2;
        double r514221 = r514219 + r514220;
        double r514222 = r514218 * r514221;
        double r514223 = 20.0;
        double r514224 = r514218 * r514223;
        double r514225 = r514222 + r514224;
        return r514225;
}

Error

Bits error versus d1

Bits error versus d2

Derivation

  1. Initial program 0.3

    \[\frac{\left(\frac{\left(d1 \cdot \left(10\right)\right)}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot \left(20\right)\right)}\]
  2. Using strategy rm
  3. Applied p16-distribute-lft-out0.3

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

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

Reproduce

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