Average Error: 0.3 → 0.3
Time: 11.1s
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 r4230850 = d1;
        double r4230851 = 10.0;
        double r4230852 = /* ERROR: no posit support in C */;
        double r4230853 = r4230850 * r4230852;
        double r4230854 = d2;
        double r4230855 = r4230850 * r4230854;
        double r4230856 = r4230853 + r4230855;
        double r4230857 = 20.0;
        double r4230858 = /* ERROR: no posit support in C */;
        double r4230859 = r4230850 * r4230858;
        double r4230860 = r4230856 + r4230859;
        return r4230860;
}

double f(double d1, double d2) {
        double r4230861 = d1;
        double r4230862 = 10.0;
        double r4230863 = d2;
        double r4230864 = r4230862 + r4230863;
        double r4230865 = r4230861 * r4230864;
        double r4230866 = 20.0;
        double r4230867 = r4230861 * r4230866;
        double r4230868 = r4230865 + r4230867;
        return r4230868;
}

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