Average Error: 0.0 → 0.0
Time: 2.8s
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 r309644 = d1;
        double r309645 = d2;
        double r309646 = r309644 * r309645;
        double r309647 = d3;
        double r309648 = r309644 * r309647;
        double r309649 = r309646 - r309648;
        double r309650 = d4;
        double r309651 = r309650 * r309644;
        double r309652 = r309649 + r309651;
        double r309653 = r309644 * r309644;
        double r309654 = r309652 - r309653;
        return r309654;
}

double f(double d1, double d2, double d3, double d4) {
        double r309655 = d1;
        double r309656 = d4;
        double r309657 = d2;
        double r309658 = r309656 + r309657;
        double r309659 = d3;
        double r309660 = r309658 - r309659;
        double r309661 = r309655 * r309660;
        double r309662 = r309655 * r309655;
        double r309663 = r309661 - r309662;
        return r309663;
}

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)))