Average Error: 0.3 → 0.3
Time: 9.7s
Precision: 64
\[\left(d1 \cdot 10 + d1 \cdot d2\right) + d1 \cdot 20\]
\[d1 \cdot \left(10 + d2\right) + d1 \cdot 20\]
double f(double d1, double d2) {
        double r2213401 = d1;
        double r2213402 = 10.0;
        double r2213403 = r2213401 * r2213402;
        double r2213404 = d2;
        double r2213405 = r2213401 * r2213404;
        double r2213406 = r2213403 + r2213405;
        double r2213407 = 20.0;
        double r2213408 = r2213401 * r2213407;
        double r2213409 = r2213406 + r2213408;
        return r2213409;
}

double f(double d1, double d2) {
        double r2213410 = d1;
        double r2213411 = 10.0;
        double r2213412 = d2;
        double r2213413 = r2213411 + r2213412;
        double r2213414 = r2213410 * r2213413;
        double r2213415 = 20.0;
        double r2213416 = r2213410 * r2213415;
        double r2213417 = r2213414 + r2213416;
        return r2213417;
}

\left(d1 \cdot 10 + d1 \cdot d2\right) + d1 \cdot 20
d1 \cdot \left(10 + d2\right) + d1 \cdot 20

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 distribute-lft-out0.3

    \[\leadsto \frac{\color{blue}{\left(d1 \cdot \left(\frac{\left(10\right)}{d2}\right)\right)}}{\left(d1 \cdot \left(20\right)\right)}\]
  4. Final simplification0.3

    \[\leadsto d1 \cdot \left(10 + d2\right) + d1 \cdot 20\]

Reproduce

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