Average Error: 0.3 → 0.1
Time: 18.0s
Precision: 64
\[\frac{\left(\frac{\left(d1 \cdot \left(10\right)\right)}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot \left(20\right)\right)}\]
\[\left(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(\left(d1 \cdot 10\right)\right), d1, d2\right)\right), d1, 20\right)\right)\]
\frac{\left(\frac{\left(d1 \cdot \left(10\right)\right)}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot \left(20\right)\right)}
\left(\mathsf{qma}\left(\left(\mathsf{qma}\left(\left(\left(d1 \cdot 10\right)\right), d1, d2\right)\right), d1, 20\right)\right)
double f(double d1, double d2) {
        double r5654291 = d1;
        double r5654292 = 10.0;
        double r5654293 = /* ERROR: no posit support in C */;
        double r5654294 = r5654291 * r5654293;
        double r5654295 = d2;
        double r5654296 = r5654291 * r5654295;
        double r5654297 = r5654294 + r5654296;
        double r5654298 = 20.0;
        double r5654299 = /* ERROR: no posit support in C */;
        double r5654300 = r5654291 * r5654299;
        double r5654301 = r5654297 + r5654300;
        return r5654301;
}

double f(double d1, double d2) {
        double r5654302 = d1;
        double r5654303 = 10.0;
        double r5654304 = r5654302 * r5654303;
        double r5654305 = /*Error: no posit support in C */;
        double r5654306 = d2;
        double r5654307 = /*Error: no posit support in C */;
        double r5654308 = 20.0;
        double r5654309 = /*Error: no posit support in C */;
        double r5654310 = /*Error: no posit support in C */;
        return r5654310;
}

Error

Bits error versus d1

Bits error versus d2

Derivation

  1. Initial program 0.3

    \[\frac{\left(\frac{\left(d1 \cdot \left(10\right)\right)}{\left(d1 \cdot d2\right)}\right)}{\left(d1 \cdot \left(20\right)\right)}\]
  2. Using strategy rm
  3. Applied introduce-quire0.3

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

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

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

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

Reproduce

herbie shell --seed 2019162 +o rules:numerics
(FPCore (d1 d2)
  :name "FastMath test2"
  (+.p16 (+.p16 (*.p16 d1 (real->posit16 10)) (*.p16 d1 d2)) (*.p16 d1 (real->posit16 20))))