Average Error: 0 → 0
Time: 5.0s
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 2\right) \cdot \mathsf{fma}\left(2, 1, \frac{1}{9}\right)\]
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 2\right) \cdot \mathsf{fma}\left(2, 1, \frac{1}{9}\right)
double f() {
        double r98474 = 2.0;
        double r98475 = 1.0;
        double r98476 = 9.0;
        double r98477 = r98475 / r98476;
        double r98478 = r98475 * r98477;
        double r98479 = r98477 * r98477;
        double r98480 = r98478 + r98479;
        double r98481 = r98477 * r98475;
        double r98482 = r98480 + r98481;
        double r98483 = r98474 * r98482;
        return r98483;
}

double f() {
        double r98484 = 1.0;
        double r98485 = 9.0;
        double r98486 = r98484 / r98485;
        double r98487 = 2.0;
        double r98488 = r98486 * r98487;
        double r98489 = 2.0;
        double r98490 = fma(r98489, r98484, r98486);
        double r98491 = r98488 * r98490;
        return r98491;
}

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

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

Reproduce

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

  :herbie-target
  (+ (+ (* (* (/ 1 9) 1) 2) (* 2 (* (/ 1 9) (/ 1 9)))) (* 2 (* 1 (/ 1 9))))

  (* 2 (+ (+ (* 1 (/ 1 9)) (* (/ 1 9) (/ 1 9))) (* (/ 1 9) 1))))