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 r2660431 = 2.0;
        double r2660432 = 1.0;
        double r2660433 = 9.0;
        double r2660434 = r2660432 / r2660433;
        double r2660435 = r2660432 * r2660434;
        double r2660436 = r2660434 * r2660434;
        double r2660437 = r2660435 + r2660436;
        double r2660438 = r2660434 * r2660432;
        double r2660439 = r2660437 + r2660438;
        double r2660440 = r2660431 * r2660439;
        return r2660440;
}

double f() {
        double r2660441 = 2.0;
        double r2660442 = 1.0;
        double r2660443 = 9.0;
        double r2660444 = r2660442 / r2660443;
        double r2660445 = fma(r2660441, r2660442, r2660444);
        double r2660446 = 2.0;
        double r2660447 = r2660444 * r2660446;
        double r2660448 = r2660445 * r2660447;
        return r2660448;
}

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