Average Error: 0.3 → 0.3
Time: 9.8s
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 r1021885 = d1;
        double r1021886 = 10.0;
        double r1021887 = /* ERROR: no posit support in C */;
        double r1021888 = r1021885 * r1021887;
        double r1021889 = d2;
        double r1021890 = r1021885 * r1021889;
        double r1021891 = r1021888 + r1021890;
        double r1021892 = 20.0;
        double r1021893 = /* ERROR: no posit support in C */;
        double r1021894 = r1021885 * r1021893;
        double r1021895 = r1021891 + r1021894;
        return r1021895;
}

double f(double d1, double d2) {
        double r1021896 = d1;
        double r1021897 = 10.0;
        double r1021898 = d2;
        double r1021899 = r1021897 + r1021898;
        double r1021900 = r1021896 * r1021899;
        double r1021901 = 20.0;
        double r1021902 = r1021896 * r1021901;
        double r1021903 = r1021900 + r1021902;
        return r1021903;
}

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