Average Error: 0 → 0
Time: 4.9m
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 r3093311 = 2.0;
        double r3093312 = 1.0;
        double r3093313 = 9.0;
        double r3093314 = r3093312 / r3093313;
        double r3093315 = r3093312 * r3093314;
        double r3093316 = r3093314 * r3093314;
        double r3093317 = r3093315 + r3093316;
        double r3093318 = r3093314 * r3093312;
        double r3093319 = r3093317 + r3093318;
        double r3093320 = r3093311 * r3093319;
        return r3093320;
}

double f() {
        double r3093321 = 2.0;
        double r3093322 = 1.0;
        double r3093323 = 9.0;
        double r3093324 = r3093322 / r3093323;
        double r3093325 = 2.0;
        double r3093326 = fma(r3093325, r3093322, r3093324);
        double r3093327 = r3093324 * r3093326;
        double r3093328 = r3093321 * r3093327;
        return r3093328;
}

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