Average Error: 0 → 0
Time: 5.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 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 r68493 = 2.0;
        double r68494 = 1.0;
        double r68495 = 9.0;
        double r68496 = r68494 / r68495;
        double r68497 = r68494 * r68496;
        double r68498 = r68496 * r68496;
        double r68499 = r68497 + r68498;
        double r68500 = r68496 * r68494;
        double r68501 = r68499 + r68500;
        double r68502 = r68493 * r68501;
        return r68502;
}

double f() {
        double r68503 = 1.0;
        double r68504 = 9.0;
        double r68505 = r68503 / r68504;
        double r68506 = 2.0;
        double r68507 = r68505 * r68506;
        double r68508 = 2.0;
        double r68509 = fma(r68508, r68503, r68505);
        double r68510 = r68507 * r68509;
        return r68510;
}

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 2019325 +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))))