Average Error: 0 → 0
Time: 4.8m
Precision: 64
\[2 \cdot \left(\left(1 \cdot \frac{1}{9} + \frac{1}{9} \cdot \frac{1}{9}\right) + \frac{1}{9} \cdot 1\right)\]
\[2 \cdot \left(\frac{1}{9} \cdot \mathsf{fma}\left(2, 1, \frac{1}{9}\right)\right)\]
2 \cdot \left(\left(1 \cdot \frac{1}{9} + \frac{1}{9} \cdot \frac{1}{9}\right) + \frac{1}{9} \cdot 1\right)
2 \cdot \left(\frac{1}{9} \cdot \mathsf{fma}\left(2, 1, \frac{1}{9}\right)\right)
double f() {
        double r2895539 = 2.0;
        double r2895540 = 1.0;
        double r2895541 = 9.0;
        double r2895542 = r2895540 / r2895541;
        double r2895543 = r2895540 * r2895542;
        double r2895544 = r2895542 * r2895542;
        double r2895545 = r2895543 + r2895544;
        double r2895546 = r2895542 * r2895540;
        double r2895547 = r2895545 + r2895546;
        double r2895548 = r2895539 * r2895547;
        return r2895548;
}

double f() {
        double r2895549 = 2.0;
        double r2895550 = 1.0;
        double r2895551 = 9.0;
        double r2895552 = r2895550 / r2895551;
        double r2895553 = 2.0;
        double r2895554 = fma(r2895553, r2895550, r2895552);
        double r2895555 = r2895552 * r2895554;
        double r2895556 = r2895549 * r2895555;
        return r2895556;
}

Error

Target

Original0
Target0
Herbie0
\[\left(\left(\frac{1}{9} \cdot 1\right) \cdot 2 + 2 \cdot \left(\frac{1}{9} \cdot \frac{1}{9}\right)\right) + 2 \cdot \left(1 \cdot \frac{1}{9}\right)\]

Derivation

  1. Initial program 0

    \[2 \cdot \left(\left(1 \cdot \frac{1}{9} + \frac{1}{9} \cdot \frac{1}{9}\right) + \frac{1}{9} \cdot 1\right)\]
  2. Simplified0

    \[\leadsto \color{blue}{2 \cdot \left(\mathsf{fma}\left(2, 1, \frac{1}{9}\right) \cdot \frac{1}{9}\right)}\]
  3. Final simplification0

    \[\leadsto 2 \cdot \left(\frac{1}{9} \cdot \mathsf{fma}\left(2, 1, \frac{1}{9}\right)\right)\]

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore ()
  :name "Rectangular parallelepiped of dimension a×b×c"

  :herbie-target
  (+ (+ (* (* (/ 1.0 9.0) 1.0) 2.0) (* 2.0 (* (/ 1.0 9.0) (/ 1.0 9.0)))) (* 2.0 (* 1.0 (/ 1.0 9.0))))

  (* 2.0 (+ (+ (* 1.0 (/ 1.0 9.0)) (* (/ 1.0 9.0) (/ 1.0 9.0))) (* (/ 1.0 9.0) 1.0))))