Average Error: 0.3 → 0.3
Time: 8.4s
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 r690686 = d1;
        double r690687 = 10.0;
        double r690688 = /* ERROR: no posit support in C */;
        double r690689 = r690686 * r690688;
        double r690690 = d2;
        double r690691 = r690686 * r690690;
        double r690692 = r690689 + r690691;
        double r690693 = 20.0;
        double r690694 = /* ERROR: no posit support in C */;
        double r690695 = r690686 * r690694;
        double r690696 = r690692 + r690695;
        return r690696;
}

double f(double d1, double d2) {
        double r690697 = d1;
        double r690698 = 10.0;
        double r690699 = d2;
        double r690700 = r690698 + r690699;
        double r690701 = r690697 * r690700;
        double r690702 = 20.0;
        double r690703 = r690697 * r690702;
        double r690704 = r690701 + r690703;
        return r690704;
}

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