Average Error: 0.5 → 0.2
Time: 28.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(\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 r3750696 = d1;
        double r3750697 = 3.0;
        double r3750698 = /* ERROR: no posit support in C */;
        double r3750699 = r3750696 * r3750698;
        double r3750700 = d2;
        double r3750701 = r3750696 * r3750700;
        double r3750702 = r3750699 + r3750701;
        double r3750703 = d3;
        double r3750704 = r3750696 * r3750703;
        double r3750705 = r3750702 + r3750704;
        return r3750705;
}

double f(double d1, double d2, double d3) {
        double r3750706 = 3.0;
        double r3750707 = /*Error: no posit support in C */;
        double r3750708 = d3;
        double r3750709 = 1.0;
        double r3750710 = /*Error: no posit support in C */;
        double r3750711 = d2;
        double r3750712 = /*Error: no posit support in C */;
        double r3750713 = /*Error: no posit support in C */;
        double r3750714 = d1;
        double r3750715 = r3750713 * r3750714;
        return r3750715;
}

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 2019163 +o rules:numerics
(FPCore (d1 d2 d3)
  :name "FastMath test3"
  (+.p16 (+.p16 (*.p16 d1 (real->posit16 3)) (*.p16 d1 d2)) (*.p16 d1 d3)))