Average Error: 45.4 → 8.5
Time: 6.9s
Precision: 64
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
\[\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right) - 1\]
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right) - 1
double f(double x, double y, double z) {
        double r56241 = x;
        double r56242 = y;
        double r56243 = z;
        double r56244 = fma(r56241, r56242, r56243);
        double r56245 = 1.0;
        double r56246 = r56241 * r56242;
        double r56247 = r56246 + r56243;
        double r56248 = r56245 + r56247;
        double r56249 = r56244 - r56248;
        return r56249;
}

double f(double x, double y, double z) {
        double r56250 = x;
        double r56251 = y;
        double r56252 = z;
        double r56253 = fma(r56250, r56251, r56252);
        double r56254 = r56250 * r56251;
        double r56255 = r56252 + r56254;
        double r56256 = r56253 - r56255;
        double r56257 = 1.0;
        double r56258 = r56256 - r56257;
        return r56258;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original45.4
Target0
Herbie8.5
\[-1\]

Derivation

  1. Initial program 45.4

    \[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
  2. Simplified45.4

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, y, z\right) - 1\right) - \left(x \cdot y + z\right)}\]
  3. Taylor expanded around 0 45.4

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z\right) - \left(z + \left(1 + x \cdot y\right)\right)}\]
  4. Simplified8.5

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, y, z\right) - \left(x \cdot y + z\right)\right) - 1}\]
  5. Final simplification8.5

    \[\leadsto \left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right) - 1\]

Reproduce

herbie shell --seed 2019174 
(FPCore (x y z)
  :name "simple fma test"

  :herbie-target
  -1.0

  (- (fma x y z) (+ 1.0 (+ (* x y) z))))