Average Error: 0 → 0
Time: 5.0m
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 r2968546 = 2.0;
        double r2968547 = 1.0;
        double r2968548 = 9.0;
        double r2968549 = r2968547 / r2968548;
        double r2968550 = r2968547 * r2968549;
        double r2968551 = r2968549 * r2968549;
        double r2968552 = r2968550 + r2968551;
        double r2968553 = r2968549 * r2968547;
        double r2968554 = r2968552 + r2968553;
        double r2968555 = r2968546 * r2968554;
        return r2968555;
}

double f() {
        double r2968556 = 2.0;
        double r2968557 = 1.0;
        double r2968558 = 9.0;
        double r2968559 = r2968557 / r2968558;
        double r2968560 = 2.0;
        double r2968561 = fma(r2968560, r2968557, r2968559);
        double r2968562 = r2968559 * r2968561;
        double r2968563 = r2968556 * r2968562;
        return r2968563;
}

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