Average Error: 0.5 → 0.3
Time: 19.9s
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(\left(d1 \cdot 3\right)\right), d1, d2\right)\right), d1, d3\right)\right)\]
\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(\left(d1 \cdot 3\right)\right), d1, d2\right)\right), d1, d3\right)\right)
double f(double d1, double d2, double d3) {
        double r1185025 = d1;
        double r1185026 = 3.0;
        double r1185027 = /* ERROR: no posit support in C */;
        double r1185028 = r1185025 * r1185027;
        double r1185029 = d2;
        double r1185030 = r1185025 * r1185029;
        double r1185031 = r1185028 + r1185030;
        double r1185032 = d3;
        double r1185033 = r1185025 * r1185032;
        double r1185034 = r1185031 + r1185033;
        return r1185034;
}

double f(double d1, double d2, double d3) {
        double r1185035 = d1;
        double r1185036 = 3.0;
        double r1185037 = r1185035 * r1185036;
        double r1185038 = /*Error: no posit support in C */;
        double r1185039 = d2;
        double r1185040 = /*Error: no posit support in C */;
        double r1185041 = d3;
        double r1185042 = /*Error: no posit support in C */;
        double r1185043 = /*Error: no posit support in C */;
        return r1185043;
}

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. Using strategy rm
  3. Applied introduce-quire0.5

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

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

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

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

Reproduce

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