Average Error: 0.5 → 0.2
Time: 26.4s
Precision: 64
\[\frac{\left(\frac{\left(d1 \cdot \left(3\right)\right)}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot d3\right)}\]
\[\left(\left(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(\left(3\right)\right), d3, \left(1.0\right)\right)\right), d2, \left(1.0\right)\right)\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(\left(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(\left(3\right)\right), d3, \left(1.0\right)\right)\right), d2, \left(1.0\right)\right)\right)\right) \cdot d1
double f(double d1, double d2, double d3) {
        double r2920715 = d1;
        double r2920716 = 3.0;
        double r2920717 = /* ERROR: no posit support in C */;
        double r2920718 = r2920715 * r2920717;
        double r2920719 = d2;
        double r2920720 = r2920715 * r2920719;
        double r2920721 = r2920718 + r2920720;
        double r2920722 = d3;
        double r2920723 = r2920715 * r2920722;
        double r2920724 = r2920721 + r2920723;
        return r2920724;
}

double f(double d1, double d2, double d3) {
        double r2920725 = 3.0;
        double r2920726 = /* ERROR: no posit support in C */;
        double r2920727 = /*Error: no posit support in C */;
        double r2920728 = d3;
        double r2920729 = 1.0;
        double r2920730 = /* ERROR: no posit support in C */;
        double r2920731 = /*Error: no posit support in C */;
        double r2920732 = d2;
        double r2920733 = /*Error: no posit support in C */;
        double r2920734 = /*Error: no posit support in C */;
        double r2920735 = d1;
        double r2920736 = r2920734 * r2920735;
        return r2920736;
}

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(\frac{\left(3\right)}{d3}\right)}{d2}\right) \cdot d1}\]
  3. Using strategy rm
  4. Applied introduce-quire0.3

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

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

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

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

Reproduce

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