Average Error: 45.0 → 45.1
Time: 22.7s
Precision: 64
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(\frac{1}{z + x \cdot y} \cdot \left(z + x \cdot y\right)\right) \cdot \left(z + x \cdot y\right)\right)\]
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(\frac{1}{z + x \cdot y} \cdot \left(z + x \cdot y\right)\right) \cdot \left(z + x \cdot y\right)\right)
double f(double x, double y, double z) {
        double r3585326 = x;
        double r3585327 = y;
        double r3585328 = z;
        double r3585329 = fma(r3585326, r3585327, r3585328);
        double r3585330 = 1.0;
        double r3585331 = r3585326 * r3585327;
        double r3585332 = r3585331 + r3585328;
        double r3585333 = r3585330 + r3585332;
        double r3585334 = r3585329 - r3585333;
        return r3585334;
}

double f(double x, double y, double z) {
        double r3585335 = x;
        double r3585336 = y;
        double r3585337 = z;
        double r3585338 = fma(r3585335, r3585336, r3585337);
        double r3585339 = 1.0;
        double r3585340 = 1.0;
        double r3585341 = r3585335 * r3585336;
        double r3585342 = r3585337 + r3585341;
        double r3585343 = r3585340 / r3585342;
        double r3585344 = r3585343 * r3585342;
        double r3585345 = r3585344 * r3585342;
        double r3585346 = r3585339 + r3585345;
        double r3585347 = r3585338 - r3585346;
        return r3585347;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original45.0
Target0
Herbie45.1
\[-1\]

Derivation

  1. Initial program 45.0

    \[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
  2. Using strategy rm
  3. Applied flip-+45.7

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

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \left(1 + \frac{\color{blue}{\left(x \cdot y - z\right) \cdot \left(x \cdot y + z\right)}}{x \cdot y - z}\right)\]
  5. Using strategy rm
  6. Applied flip--49.6

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \left(1 + \frac{\left(x \cdot y - z\right) \cdot \left(x \cdot y + z\right)}{\color{blue}{\frac{\left(x \cdot y\right) \cdot \left(x \cdot y\right) - z \cdot z}{x \cdot y + z}}}\right)\]
  7. Applied associate-/r/49.6

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \left(1 + \color{blue}{\frac{\left(x \cdot y - z\right) \cdot \left(x \cdot y + z\right)}{\left(x \cdot y\right) \cdot \left(x \cdot y\right) - z \cdot z} \cdot \left(x \cdot y + z\right)}\right)\]
  8. Simplified45.1

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

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

Reproduce

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

  :herbie-target
  -1.0

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