Average Error: 0 → 0
Time: 4.2s
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)\]
\[\mathsf{fma}\left(2, 1, \frac{1}{9}\right) \cdot \left(\frac{1}{9} \cdot 2\right)\]
2 \cdot \left(\left(1 \cdot \frac{1}{9} + \frac{1}{9} \cdot \frac{1}{9}\right) + \frac{1}{9} \cdot 1\right)
\mathsf{fma}\left(2, 1, \frac{1}{9}\right) \cdot \left(\frac{1}{9} \cdot 2\right)
double f() {
        double r4786240 = 2.0;
        double r4786241 = 1.0;
        double r4786242 = 9.0;
        double r4786243 = r4786241 / r4786242;
        double r4786244 = r4786241 * r4786243;
        double r4786245 = r4786243 * r4786243;
        double r4786246 = r4786244 + r4786245;
        double r4786247 = r4786243 * r4786241;
        double r4786248 = r4786246 + r4786247;
        double r4786249 = r4786240 * r4786248;
        return r4786249;
}

double f() {
        double r4786250 = 2.0;
        double r4786251 = 1.0;
        double r4786252 = 9.0;
        double r4786253 = r4786251 / r4786252;
        double r4786254 = fma(r4786250, r4786251, r4786253);
        double r4786255 = 2.0;
        double r4786256 = r4786253 * r4786255;
        double r4786257 = r4786254 * r4786256;
        return r4786257;
}

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