Average Error: 0.0 → 0.0
Time: 4.4s
Precision: 64
\[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1\]
\[\left(d1 \cdot d2 + \mathsf{fma}\left(d1, d4, -d3 \cdot d1\right)\right) - d1 \cdot d1\]
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\left(d1 \cdot d2 + \mathsf{fma}\left(d1, d4, -d3 \cdot d1\right)\right) - d1 \cdot d1
double f(double d1, double d2, double d3, double d4) {
        double r213447 = d1;
        double r213448 = d2;
        double r213449 = r213447 * r213448;
        double r213450 = d3;
        double r213451 = r213447 * r213450;
        double r213452 = r213449 - r213451;
        double r213453 = d4;
        double r213454 = r213453 * r213447;
        double r213455 = r213452 + r213454;
        double r213456 = r213447 * r213447;
        double r213457 = r213455 - r213456;
        return r213457;
}

double f(double d1, double d2, double d3, double d4) {
        double r213458 = d1;
        double r213459 = d2;
        double r213460 = r213458 * r213459;
        double r213461 = d4;
        double r213462 = d3;
        double r213463 = r213462 * r213458;
        double r213464 = -r213463;
        double r213465 = fma(r213458, r213461, r213464);
        double r213466 = r213460 + r213465;
        double r213467 = r213458 * r213458;
        double r213468 = r213466 - r213467;
        return r213468;
}

Error

Bits error versus d1

Bits error versus d2

Bits error versus d3

Bits error versus d4

Target

Original0.0
Target0.0
Herbie0.0
\[d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right)\]

Derivation

  1. Initial program 0.0

    \[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1\]
  2. Using strategy rm
  3. Applied sub-neg0.0

    \[\leadsto \left(\color{blue}{\left(d1 \cdot d2 + \left(-d1 \cdot d3\right)\right)} + d4 \cdot d1\right) - d1 \cdot d1\]
  4. Applied associate-+l+0.0

    \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(\left(-d1 \cdot d3\right) + d4 \cdot d1\right)\right)} - d1 \cdot d1\]
  5. Simplified0.0

    \[\leadsto \left(d1 \cdot d2 + \color{blue}{\mathsf{fma}\left(d1, d4, -d3 \cdot d1\right)}\right) - d1 \cdot d1\]
  6. Final simplification0.0

    \[\leadsto \left(d1 \cdot d2 + \mathsf{fma}\left(d1, d4, -d3 \cdot d1\right)\right) - d1 \cdot d1\]

Reproduce

herbie shell --seed 2020036 +o rules:numerics
(FPCore (d1 d2 d3 d4)
  :name "FastMath dist4"
  :precision binary64

  :herbie-target
  (* d1 (- (+ (- d2 d3) d4) d1))

  (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))