Average Error: 0 → 0
Time: 5.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 r4697105 = 2.0;
        double r4697106 = 1.0;
        double r4697107 = 9.0;
        double r4697108 = r4697106 / r4697107;
        double r4697109 = r4697106 * r4697108;
        double r4697110 = r4697108 * r4697108;
        double r4697111 = r4697109 + r4697110;
        double r4697112 = r4697108 * r4697106;
        double r4697113 = r4697111 + r4697112;
        double r4697114 = r4697105 * r4697113;
        return r4697114;
}

double f() {
        double r4697115 = 2.0;
        double r4697116 = 1.0;
        double r4697117 = 9.0;
        double r4697118 = r4697116 / r4697117;
        double r4697119 = fma(r4697115, r4697116, r4697118);
        double r4697120 = 2.0;
        double r4697121 = r4697118 * r4697120;
        double r4697122 = r4697119 * r4697121;
        return r4697122;
}

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