Average Error: 0 → 0
Time: 7.5s
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)\]
\[\left(\frac{1}{9} \cdot \mathsf{fma}\left(2, 1, \frac{1}{9}\right)\right) \cdot 2\]
2 \cdot \left(\left(1 \cdot \frac{1}{9} + \frac{1}{9} \cdot \frac{1}{9}\right) + \frac{1}{9} \cdot 1\right)
\left(\frac{1}{9} \cdot \mathsf{fma}\left(2, 1, \frac{1}{9}\right)\right) \cdot 2
double f() {
        double r2824498 = 2.0;
        double r2824499 = 1.0;
        double r2824500 = 9.0;
        double r2824501 = r2824499 / r2824500;
        double r2824502 = r2824499 * r2824501;
        double r2824503 = r2824501 * r2824501;
        double r2824504 = r2824502 + r2824503;
        double r2824505 = r2824501 * r2824499;
        double r2824506 = r2824504 + r2824505;
        double r2824507 = r2824498 * r2824506;
        return r2824507;
}

double f() {
        double r2824508 = 1.0;
        double r2824509 = 9.0;
        double r2824510 = r2824508 / r2824509;
        double r2824511 = 2.0;
        double r2824512 = fma(r2824511, r2824508, r2824510);
        double r2824513 = r2824510 * r2824512;
        double r2824514 = 2.0;
        double r2824515 = r2824513 * r2824514;
        return r2824515;
}

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(\frac{1}{9} \cdot \mathsf{fma}\left(2, 1, \frac{1}{9}\right)\right)}\]
  3. Final simplification0

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

Reproduce

herbie shell --seed 2019200 +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))))