Average Error: 0 → 0
Time: 8.7s
Precision: 64
\[2.0 \cdot \left(\left(1.0 \cdot \frac{1.0}{9.0} + \frac{1.0}{9.0} \cdot \frac{1.0}{9.0}\right) + \frac{1.0}{9.0} \cdot 1.0\right)\]
\[\mathsf{fma}\left(2, 1.0, \frac{1.0}{9.0}\right) \cdot \left(\frac{1.0}{9.0} \cdot 2.0\right)\]
2.0 \cdot \left(\left(1.0 \cdot \frac{1.0}{9.0} + \frac{1.0}{9.0} \cdot \frac{1.0}{9.0}\right) + \frac{1.0}{9.0} \cdot 1.0\right)
\mathsf{fma}\left(2, 1.0, \frac{1.0}{9.0}\right) \cdot \left(\frac{1.0}{9.0} \cdot 2.0\right)
double f() {
        double r2440180 = 2.0;
        double r2440181 = 1.0;
        double r2440182 = 9.0;
        double r2440183 = r2440181 / r2440182;
        double r2440184 = r2440181 * r2440183;
        double r2440185 = r2440183 * r2440183;
        double r2440186 = r2440184 + r2440185;
        double r2440187 = r2440183 * r2440181;
        double r2440188 = r2440186 + r2440187;
        double r2440189 = r2440180 * r2440188;
        return r2440189;
}

double f() {
        double r2440190 = 2.0;
        double r2440191 = 1.0;
        double r2440192 = 9.0;
        double r2440193 = r2440191 / r2440192;
        double r2440194 = fma(r2440190, r2440191, r2440193);
        double r2440195 = 2.0;
        double r2440196 = r2440193 * r2440195;
        double r2440197 = r2440194 * r2440196;
        return r2440197;
}

Error

Target

Original0
Target0
Herbie0
\[\left(\left(\frac{1.0}{9.0} \cdot 1.0\right) \cdot 2.0 + 2.0 \cdot \left(\frac{1.0}{9.0} \cdot \frac{1.0}{9.0}\right)\right) + 2.0 \cdot \left(1.0 \cdot \frac{1.0}{9.0}\right)\]

Derivation

  1. Initial program 0

    \[2.0 \cdot \left(\left(1.0 \cdot \frac{1.0}{9.0} + \frac{1.0}{9.0} \cdot \frac{1.0}{9.0}\right) + \frac{1.0}{9.0} \cdot 1.0\right)\]
  2. Simplified0

    \[\leadsto \color{blue}{\left(\frac{1.0}{9.0} \cdot 2.0\right) \cdot \mathsf{fma}\left(2, 1.0, \frac{1.0}{9.0}\right)}\]
  3. Final simplification0

    \[\leadsto \mathsf{fma}\left(2, 1.0, \frac{1.0}{9.0}\right) \cdot \left(\frac{1.0}{9.0} \cdot 2.0\right)\]

Reproduce

herbie shell --seed 2019165 +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))))