Average Error: 0 → 0
Time: 7.0s
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 r65875 = 2.0;
        double r65876 = 1.0;
        double r65877 = 9.0;
        double r65878 = r65876 / r65877;
        double r65879 = r65876 * r65878;
        double r65880 = r65878 * r65878;
        double r65881 = r65879 + r65880;
        double r65882 = r65878 * r65876;
        double r65883 = r65881 + r65882;
        double r65884 = r65875 * r65883;
        return r65884;
}

double f() {
        double r65885 = 2.0;
        double r65886 = 1.0;
        double r65887 = 9.0;
        double r65888 = r65886 / r65887;
        double r65889 = fma(r65885, r65886, r65888);
        double r65890 = 2.0;
        double r65891 = r65888 * r65890;
        double r65892 = r65889 * r65891;
        return r65892;
}

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