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(\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 r3342614 = d1;
        double r3342615 = 3.0;
        double r3342616 = /* ERROR: no posit support in C */;
        double r3342617 = r3342614 * r3342616;
        double r3342618 = d2;
        double r3342619 = r3342614 * r3342618;
        double r3342620 = r3342617 + r3342619;
        double r3342621 = d3;
        double r3342622 = r3342614 * r3342621;
        double r3342623 = r3342620 + r3342622;
        return r3342623;
}

double f(double d1, double d2, double d3) {
        double r3342624 = 3.0;
        double r3342625 = /* ERROR: no posit support in C */;
        double r3342626 = /*Error: no posit support in C */;
        double r3342627 = d3;
        double r3342628 = 1.0;
        double r3342629 = /* ERROR: no posit support in C */;
        double r3342630 = /*Error: no posit support in C */;
        double r3342631 = d2;
        double r3342632 = /*Error: no posit support in C */;
        double r3342633 = /*Error: no posit support in C */;
        double r3342634 = d1;
        double r3342635 = r3342633 * r3342634;
        return r3342635;
}

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