Average Error: 0 → 0
Time: 4.7m
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 r3442504 = 2.0;
        double r3442505 = 1.0;
        double r3442506 = 9.0;
        double r3442507 = r3442505 / r3442506;
        double r3442508 = r3442505 * r3442507;
        double r3442509 = r3442507 * r3442507;
        double r3442510 = r3442508 + r3442509;
        double r3442511 = r3442507 * r3442505;
        double r3442512 = r3442510 + r3442511;
        double r3442513 = r3442504 * r3442512;
        return r3442513;
}

double f() {
        double r3442514 = 2.0;
        double r3442515 = 1.0;
        double r3442516 = 9.0;
        double r3442517 = r3442515 / r3442516;
        double r3442518 = 2.0;
        double r3442519 = fma(r3442518, r3442515, r3442517);
        double r3442520 = r3442517 * r3442519;
        double r3442521 = r3442514 * r3442520;
        return r3442521;
}

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