Average Error: 0.5 → 0.2
Time: 24.3s
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), d3, 1.0\right)\right), d2, 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), d3, 1.0\right)\right), d2, 1.0\right)\right) \cdot d1
double f(double d1, double d2, double d3) {
        double r1284039 = d1;
        double r1284040 = 3.0;
        double r1284041 = /* ERROR: no posit support in C */;
        double r1284042 = r1284039 * r1284041;
        double r1284043 = d2;
        double r1284044 = r1284039 * r1284043;
        double r1284045 = r1284042 + r1284044;
        double r1284046 = d3;
        double r1284047 = r1284039 * r1284046;
        double r1284048 = r1284045 + r1284047;
        return r1284048;
}

double f(double d1, double d2, double d3) {
        double r1284049 = 3.0;
        double r1284050 = /*Error: no posit support in C */;
        double r1284051 = d3;
        double r1284052 = 1.0;
        double r1284053 = /*Error: no posit support in C */;
        double r1284054 = d2;
        double r1284055 = /*Error: no posit support in C */;
        double r1284056 = /*Error: no posit support in C */;
        double r1284057 = d1;
        double r1284058 = r1284056 * r1284057;
        return r1284058;
}

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(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(3\right), d3, 1.0\right)\right), d2, 1.0\right)\right) \cdot d1\]

Reproduce

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