Average Error: 0 → 0
Time: 7.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 \mathsf{fma}\left(2, 1, \frac{1}{9}\right)\right) \cdot 2\]
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 \mathsf{fma}\left(2, 1, \frac{1}{9}\right)\right) \cdot 2
double f() {
        double r2800864 = 2.0;
        double r2800865 = 1.0;
        double r2800866 = 9.0;
        double r2800867 = r2800865 / r2800866;
        double r2800868 = r2800865 * r2800867;
        double r2800869 = r2800867 * r2800867;
        double r2800870 = r2800868 + r2800869;
        double r2800871 = r2800867 * r2800865;
        double r2800872 = r2800870 + r2800871;
        double r2800873 = r2800864 * r2800872;
        return r2800873;
}

double f() {
        double r2800874 = 1.0;
        double r2800875 = 9.0;
        double r2800876 = r2800874 / r2800875;
        double r2800877 = 2.0;
        double r2800878 = fma(r2800877, r2800874, r2800876);
        double r2800879 = r2800876 * r2800878;
        double r2800880 = 2.0;
        double r2800881 = r2800879 * r2800880;
        return r2800881;
}

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

    \[\leadsto \left(\frac{1}{9} \cdot \mathsf{fma}\left(2, 1, \frac{1}{9}\right)\right) \cdot 2\]

Reproduce

herbie shell --seed 2019200 +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))))