Average Error: 0.0 → 0.0
Time: 3.0s
Precision: 64
\[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1\]
\[d1 \cdot \left(\left(d4 + d2\right) - d3\right) - d1 \cdot d1\]
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
d1 \cdot \left(\left(d4 + d2\right) - d3\right) - d1 \cdot d1
double f(double d1, double d2, double d3, double d4) {
        double r241614 = d1;
        double r241615 = d2;
        double r241616 = r241614 * r241615;
        double r241617 = d3;
        double r241618 = r241614 * r241617;
        double r241619 = r241616 - r241618;
        double r241620 = d4;
        double r241621 = r241620 * r241614;
        double r241622 = r241619 + r241621;
        double r241623 = r241614 * r241614;
        double r241624 = r241622 - r241623;
        return r241624;
}

double f(double d1, double d2, double d3, double d4) {
        double r241625 = d1;
        double r241626 = d4;
        double r241627 = d2;
        double r241628 = r241626 + r241627;
        double r241629 = d3;
        double r241630 = r241628 - r241629;
        double r241631 = r241625 * r241630;
        double r241632 = r241625 * r241625;
        double r241633 = r241631 - r241632;
        return r241633;
}

Error

Bits error versus d1

Bits error versus d2

Bits error versus d3

Bits error versus d4

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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. Taylor expanded around inf 0.0

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

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

    \[\leadsto d1 \cdot \left(\left(d4 + d2\right) - d3\right) - d1 \cdot d1\]

Reproduce

herbie shell --seed 2020001 +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)))