Average Error: 0.0 → 0.0
Time: 3.1s
Precision: 64
\[\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1\]
\[\left(d1 \cdot d2 + d1 \cdot \left(-d3\right)\right) + d1 \cdot \left(d4 - d1\right)\]
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\left(d1 \cdot d2 + d1 \cdot \left(-d3\right)\right) + d1 \cdot \left(d4 - d1\right)
double f(double d1, double d2, double d3, double d4) {
        double r155646 = d1;
        double r155647 = d2;
        double r155648 = r155646 * r155647;
        double r155649 = d3;
        double r155650 = r155646 * r155649;
        double r155651 = r155648 - r155650;
        double r155652 = d4;
        double r155653 = r155652 * r155646;
        double r155654 = r155651 + r155653;
        double r155655 = r155646 * r155646;
        double r155656 = r155654 - r155655;
        return r155656;
}

double f(double d1, double d2, double d3, double d4) {
        double r155657 = d1;
        double r155658 = d2;
        double r155659 = r155657 * r155658;
        double r155660 = d3;
        double r155661 = -r155660;
        double r155662 = r155657 * r155661;
        double r155663 = r155659 + r155662;
        double r155664 = d4;
        double r155665 = r155664 - r155657;
        double r155666 = r155657 * r155665;
        double r155667 = r155663 + r155666;
        return r155667;
}

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. Simplified0.0

    \[\leadsto \color{blue}{d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right)}\]
  3. Using strategy rm
  4. Applied distribute-lft-in0.0

    \[\leadsto \color{blue}{d1 \cdot \left(d2 - d3\right) + d1 \cdot \left(d4 - d1\right)}\]
  5. Using strategy rm
  6. Applied sub-neg0.0

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

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

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

Reproduce

herbie shell --seed 2020027 
(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)))