Average Error: 0.3 → 0.3
Time: 9.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 r3677010 = d1;
        double r3677011 = 10.0;
        double r3677012 = /* ERROR: no posit support in C */;
        double r3677013 = r3677010 * r3677012;
        double r3677014 = d2;
        double r3677015 = r3677010 * r3677014;
        double r3677016 = r3677013 + r3677015;
        double r3677017 = 20.0;
        double r3677018 = /* ERROR: no posit support in C */;
        double r3677019 = r3677010 * r3677018;
        double r3677020 = r3677016 + r3677019;
        return r3677020;
}

double f(double d1, double d2) {
        double r3677021 = d1;
        double r3677022 = 10.0;
        double r3677023 = d2;
        double r3677024 = r3677022 + r3677023;
        double r3677025 = r3677021 * r3677024;
        double r3677026 = 20.0;
        double r3677027 = r3677021 * r3677026;
        double r3677028 = r3677025 + r3677027;
        return r3677028;
}

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