Average Error: 2.1 → 1.9
Time: 8.9s
Precision: 64
\[\left(-1\right) \cdot \left(v12 \cdot vec1\right) + \left(v12 \cdot vec2\right) \cdot \left(vec1 \cdot vec2\right)\]
\[\left(-1\right) \cdot \left(v12 \cdot vec1\right) + \left(v12 \cdot \left(vec1 \cdot vec2\right)\right) \cdot vec2\]
\left(-1\right) \cdot \left(v12 \cdot vec1\right) + \left(v12 \cdot vec2\right) \cdot \left(vec1 \cdot vec2\right)
\left(-1\right) \cdot \left(v12 \cdot vec1\right) + \left(v12 \cdot \left(vec1 \cdot vec2\right)\right) \cdot vec2
double f(double v12, double vec1, double vec2) {
        double r2487538 = 1.0;
        double r2487539 = -r2487538;
        double r2487540 = v12;
        double r2487541 = vec1;
        double r2487542 = r2487540 * r2487541;
        double r2487543 = r2487539 * r2487542;
        double r2487544 = vec2;
        double r2487545 = r2487540 * r2487544;
        double r2487546 = r2487541 * r2487544;
        double r2487547 = r2487545 * r2487546;
        double r2487548 = r2487543 + r2487547;
        return r2487548;
}

double f(double v12, double vec1, double vec2) {
        double r2487549 = 1.0;
        double r2487550 = -r2487549;
        double r2487551 = v12;
        double r2487552 = vec1;
        double r2487553 = r2487551 * r2487552;
        double r2487554 = r2487550 * r2487553;
        double r2487555 = vec2;
        double r2487556 = r2487552 * r2487555;
        double r2487557 = r2487551 * r2487556;
        double r2487558 = r2487557 * r2487555;
        double r2487559 = r2487554 + r2487558;
        return r2487559;
}

Error

Bits error versus v12

Bits error versus vec1

Bits error versus vec2

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 2.1

    \[\left(-1\right) \cdot \left(v12 \cdot vec1\right) + \left(v12 \cdot vec2\right) \cdot \left(vec1 \cdot vec2\right)\]
  2. Using strategy rm
  3. Applied associate-*r*1.8

    \[\leadsto \left(-1\right) \cdot \left(v12 \cdot vec1\right) + \color{blue}{\left(\left(v12 \cdot vec2\right) \cdot vec1\right) \cdot vec2}\]
  4. Using strategy rm
  5. Applied associate-*l*1.9

    \[\leadsto \left(-1\right) \cdot \left(v12 \cdot vec1\right) + \color{blue}{\left(v12 \cdot \left(vec2 \cdot vec1\right)\right)} \cdot vec2\]
  6. Simplified1.9

    \[\leadsto \left(-1\right) \cdot \left(v12 \cdot vec1\right) + \left(v12 \cdot \color{blue}{\left(vec1 \cdot vec2\right)}\right) \cdot vec2\]
  7. Final simplification1.9

    \[\leadsto \left(-1\right) \cdot \left(v12 \cdot vec1\right) + \left(v12 \cdot \left(vec1 \cdot vec2\right)\right) \cdot vec2\]

Reproduce

herbie shell --seed 1 
(FPCore (v12 vec1 vec2)
  :name "-1.0 * (v12 * vec1) + (v12 * vec2) * (vec1 * vec2)"
  :precision binary64
  (+ (* (- 1) (* v12 vec1)) (* (* v12 vec2) (* vec1 vec2))))