Average Error: 0 → 0
Time: 3.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 2\right) \cdot \mathsf{fma}\left(2, 1, \frac{1}{9}\right)\]
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 2\right) \cdot \mathsf{fma}\left(2, 1, \frac{1}{9}\right)
double f() {
        double r57966 = 2.0;
        double r57967 = 1.0;
        double r57968 = 9.0;
        double r57969 = r57967 / r57968;
        double r57970 = r57967 * r57969;
        double r57971 = r57969 * r57969;
        double r57972 = r57970 + r57971;
        double r57973 = r57969 * r57967;
        double r57974 = r57972 + r57973;
        double r57975 = r57966 * r57974;
        return r57975;
}

double f() {
        double r57976 = 1.0;
        double r57977 = 9.0;
        double r57978 = r57976 / r57977;
        double r57979 = 2.0;
        double r57980 = r57978 * r57979;
        double r57981 = 2.0;
        double r57982 = fma(r57981, r57976, r57978);
        double r57983 = r57980 * r57982;
        return r57983;
}

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

Reproduce

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