Average Error: 0.5 → 0.2
Time: 46.1s
Precision: 64
\[\frac{\left(\frac{\left(d1 \cdot \left(3\right)\right)}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot d3\right)}\]
\[\left(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(3\right), d2, 1.0\right)\right), d3, 1.0\right)\right) \cdot d1\]
\frac{\left(\frac{\left(d1 \cdot \left(3\right)\right)}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot d3\right)}
\left(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(3\right), d2, 1.0\right)\right), d3, 1.0\right)\right) \cdot d1
double f(double d1, double d2, double d3) {
        double r3131386 = d1;
        double r3131387 = 3.0;
        double r3131388 = /* ERROR: no posit support in C */;
        double r3131389 = r3131386 * r3131388;
        double r3131390 = d2;
        double r3131391 = r3131386 * r3131390;
        double r3131392 = r3131389 + r3131391;
        double r3131393 = d3;
        double r3131394 = r3131386 * r3131393;
        double r3131395 = r3131392 + r3131394;
        return r3131395;
}

double f(double d1, double d2, double d3) {
        double r3131396 = 3.0;
        double r3131397 = /*Error: no posit support in C */;
        double r3131398 = d2;
        double r3131399 = 1.0;
        double r3131400 = /*Error: no posit support in C */;
        double r3131401 = d3;
        double r3131402 = /*Error: no posit support in C */;
        double r3131403 = /*Error: no posit support in C */;
        double r3131404 = d1;
        double r3131405 = r3131403 * r3131404;
        return r3131405;
}

Error

Bits error versus d1

Bits error versus d2

Bits error versus d3

Derivation

  1. Initial program 0.5

    \[\frac{\left(\frac{\left(d1 \cdot \left(3\right)\right)}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot d3\right)}\]
  2. Simplified0.3

    \[\leadsto \color{blue}{\left(\frac{\left(3\right)}{\left(\frac{d2}{d3}\right)}\right) \cdot d1}\]
  3. Using strategy rm
  4. Applied associate-+r+0.3

    \[\leadsto \color{blue}{\left(\frac{\left(\frac{\left(3\right)}{d2}\right)}{d3}\right)} \cdot d1\]
  5. Using strategy rm
  6. Applied introduce-quire0.3

    \[\leadsto \left(\frac{\left(\frac{\color{blue}{\left(\left(\left(3\right)\right)\right)}}{d2}\right)}{d3}\right) \cdot d1\]
  7. Applied insert-quire-add0.3

    \[\leadsto \left(\frac{\color{blue}{\left(\left(\mathsf{qma}\left(\left(\left(3\right)\right), d2, \left(1.0\right)\right)\right)\right)}}{d3}\right) \cdot d1\]
  8. Applied insert-quire-add0.2

    \[\leadsto \color{blue}{\left(\left(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(\left(3\right)\right), d2, \left(1.0\right)\right)\right), d3, \left(1.0\right)\right)\right)\right)} \cdot d1\]
  9. Final simplification0.2

    \[\leadsto \left(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(3\right), d2, 1.0\right)\right), d3, 1.0\right)\right) \cdot d1\]

Reproduce

herbie shell --seed 2019165 
(FPCore (d1 d2 d3)
  :name "FastMath test3"
  (+.p16 (+.p16 (*.p16 d1 (real->posit16 3)) (*.p16 d1 d2)) (*.p16 d1 d3)))