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 r1180304 = d1;
        double r1180305 = 10.0;
        double r1180306 = /* ERROR: no posit support in C */;
        double r1180307 = r1180304 * r1180306;
        double r1180308 = d2;
        double r1180309 = r1180304 * r1180308;
        double r1180310 = r1180307 + r1180309;
        double r1180311 = 20.0;
        double r1180312 = /* ERROR: no posit support in C */;
        double r1180313 = r1180304 * r1180312;
        double r1180314 = r1180310 + r1180313;
        return r1180314;
}

double f(double d1, double d2) {
        double r1180315 = d1;
        double r1180316 = 10.0;
        double r1180317 = d2;
        double r1180318 = r1180316 + r1180317;
        double r1180319 = r1180315 * r1180318;
        double r1180320 = 20.0;
        double r1180321 = r1180315 * r1180320;
        double r1180322 = r1180319 + r1180321;
        return r1180322;
}

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 2019132 +o rules:numerics
(FPCore (d1 d2)
  :name "FastMath test2"
  (+.p16 (+.p16 (*.p16 d1 (real->posit16 10)) (*.p16 d1 d2)) (*.p16 d1 (real->posit16 20))))