Average Error: 0.3 → 0.1
Time: 23.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)}\]
\[\left(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(\left(d1 \cdot 10\right)\right), d1, d2\right)\right), d1, 20\right)\right)\]
\frac{\left(\frac{\left(d1 \cdot \left(10\right)\right)}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot \left(20\right)\right)}
\left(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(\left(d1 \cdot 10\right)\right), d1, d2\right)\right), d1, 20\right)\right)
double f(double d1, double d2) {
        double r3979176 = d1;
        double r3979177 = 10.0;
        double r3979178 = /* ERROR: no posit support in C */;
        double r3979179 = r3979176 * r3979178;
        double r3979180 = d2;
        double r3979181 = r3979176 * r3979180;
        double r3979182 = r3979179 + r3979181;
        double r3979183 = 20.0;
        double r3979184 = /* ERROR: no posit support in C */;
        double r3979185 = r3979176 * r3979184;
        double r3979186 = r3979182 + r3979185;
        return r3979186;
}

double f(double d1, double d2) {
        double r3979187 = d1;
        double r3979188 = 10.0;
        double r3979189 = r3979187 * r3979188;
        double r3979190 = /*Error: no posit support in C */;
        double r3979191 = d2;
        double r3979192 = /*Error: no posit support in C */;
        double r3979193 = 20.0;
        double r3979194 = /*Error: no posit support in C */;
        double r3979195 = /*Error: no posit support in C */;
        return r3979195;
}

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 introduce-quire0.3

    \[\leadsto \frac{\left(\frac{\color{blue}{\left(\left(\left(d1 \cdot \left(10\right)\right)\right)\right)}}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot \left(20\right)\right)}\]
  4. Applied insert-quire-fdp-add0.3

    \[\leadsto \frac{\color{blue}{\left(\left(\mathsf{qma}\left(\left(\left(d1 \cdot \left(10\right)\right)\right), d1, d2\right)\right)\right)}}{\left(d1 \cdot \left(20\right)\right)}\]
  5. Applied insert-quire-fdp-add0.1

    \[\leadsto \color{blue}{\left(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(\left(d1 \cdot \left(10\right)\right)\right), d1, d2\right)\right), d1, \left(20\right)\right)\right)}\]
  6. Final simplification0.1

    \[\leadsto \left(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(\left(d1 \cdot 10\right)\right), d1, d2\right)\right), d1, 20\right)\right)\]

Reproduce

herbie shell --seed 2019163 +o rules:numerics
(FPCore (d1 d2)
  :name "FastMath test2"
  (+.p16 (+.p16 (*.p16 d1 (real->posit16 10)) (*.p16 d1 d2)) (*.p16 d1 (real->posit16 20))))