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 r317274 = d1;
        double r317275 = d2;
        double r317276 = r317274 * r317275;
        double r317277 = d3;
        double r317278 = r317274 * r317277;
        double r317279 = r317276 - r317278;
        double r317280 = d4;
        double r317281 = r317280 * r317274;
        double r317282 = r317279 + r317281;
        double r317283 = r317274 * r317274;
        double r317284 = r317282 - r317283;
        return r317284;
}

double f(double d1, double d2, double d3, double d4) {
        double r317285 = d1;
        double r317286 = d4;
        double r317287 = d2;
        double r317288 = r317286 + r317287;
        double r317289 = d3;
        double r317290 = r317288 - r317289;
        double r317291 = r317285 * r317290;
        double r317292 = r317285 * r317285;
        double r317293 = r317291 - r317292;
        return r317293;
}

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