Average Error: 0 → 0
Time: 8.1s
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 r3156123 = 2.0;
        double r3156124 = 1.0;
        double r3156125 = 9.0;
        double r3156126 = r3156124 / r3156125;
        double r3156127 = r3156124 * r3156126;
        double r3156128 = r3156126 * r3156126;
        double r3156129 = r3156127 + r3156128;
        double r3156130 = r3156126 * r3156124;
        double r3156131 = r3156129 + r3156130;
        double r3156132 = r3156123 * r3156131;
        return r3156132;
}

double f() {
        double r3156133 = 2.0;
        double r3156134 = 1.0;
        double r3156135 = 9.0;
        double r3156136 = r3156134 / r3156135;
        double r3156137 = fma(r3156133, r3156134, r3156136);
        double r3156138 = 2.0;
        double r3156139 = r3156136 * r3156138;
        double r3156140 = r3156137 * r3156139;
        return r3156140;
}

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