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 r3391931 = 2.0;
        double r3391932 = 1.0;
        double r3391933 = 9.0;
        double r3391934 = r3391932 / r3391933;
        double r3391935 = r3391932 * r3391934;
        double r3391936 = r3391934 * r3391934;
        double r3391937 = r3391935 + r3391936;
        double r3391938 = r3391934 * r3391932;
        double r3391939 = r3391937 + r3391938;
        double r3391940 = r3391931 * r3391939;
        return r3391940;
}

double f() {
        double r3391941 = 2.0;
        double r3391942 = 1.0;
        double r3391943 = 9.0;
        double r3391944 = r3391942 / r3391943;
        double r3391945 = 2.0;
        double r3391946 = fma(r3391945, r3391942, r3391944);
        double r3391947 = r3391944 * r3391946;
        double r3391948 = r3391941 * r3391947;
        return r3391948;
}

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