Average Error: 0 → 0
Time: 5.3s
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 r45389 = 2.0;
        double r45390 = 1.0;
        double r45391 = 9.0;
        double r45392 = r45390 / r45391;
        double r45393 = r45390 * r45392;
        double r45394 = r45392 * r45392;
        double r45395 = r45393 + r45394;
        double r45396 = r45392 * r45390;
        double r45397 = r45395 + r45396;
        double r45398 = r45389 * r45397;
        return r45398;
}

double f() {
        double r45399 = 1.0;
        double r45400 = 9.0;
        double r45401 = r45399 / r45400;
        double r45402 = 2.0;
        double r45403 = r45401 * r45402;
        double r45404 = 2.0;
        double r45405 = fma(r45404, r45399, r45401);
        double r45406 = r45403 * r45405;
        return r45406;
}

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