Average Error: 45.1 → 8.3
Time: 32.6s
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 r3926944 = x;
        double r3926945 = y;
        double r3926946 = z;
        double r3926947 = fma(r3926944, r3926945, r3926946);
        double r3926948 = 1.0;
        double r3926949 = r3926944 * r3926945;
        double r3926950 = r3926949 + r3926946;
        double r3926951 = r3926948 + r3926950;
        double r3926952 = r3926947 - r3926951;
        return r3926952;
}

double f(double x, double y, double z) {
        double r3926953 = x;
        double r3926954 = y;
        double r3926955 = z;
        double r3926956 = fma(r3926953, r3926954, r3926955);
        double r3926957 = r3926953 * r3926954;
        double r3926958 = r3926955 + r3926957;
        double r3926959 = r3926956 - r3926958;
        double r3926960 = 1.0;
        double r3926961 = r3926959 - r3926960;
        return r3926961;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original45.1
Target0
Herbie8.3
\[-1\]

Derivation

  1. Initial program 45.1

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

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + \color{blue}{\log \left(e^{z}\right)}\right)\right)\]
  4. Applied add-log-exp47.7

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \left(1 + \left(\color{blue}{\log \left(e^{x \cdot y}\right)} + \log \left(e^{z}\right)\right)\right)\]
  5. Applied sum-log47.7

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \left(1 + \color{blue}{\log \left(e^{x \cdot y} \cdot e^{z}\right)}\right)\]
  6. Applied add-log-exp47.7

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \left(\color{blue}{\log \left(e^{1}\right)} + \log \left(e^{x \cdot y} \cdot e^{z}\right)\right)\]
  7. Applied sum-log47.7

    \[\leadsto \mathsf{fma}\left(x, y, z\right) - \color{blue}{\log \left(e^{1} \cdot \left(e^{x \cdot y} \cdot e^{z}\right)\right)}\]
  8. Applied add-log-exp47.7

    \[\leadsto \color{blue}{\log \left(e^{\mathsf{fma}\left(x, y, z\right)}\right)} - \log \left(e^{1} \cdot \left(e^{x \cdot y} \cdot e^{z}\right)\right)\]
  9. Applied diff-log47.7

    \[\leadsto \color{blue}{\log \left(\frac{e^{\mathsf{fma}\left(x, y, z\right)}}{e^{1} \cdot \left(e^{x \cdot y} \cdot e^{z}\right)}\right)}\]
  10. Simplified31.6

    \[\leadsto \log \color{blue}{\left(e^{\left(\mathsf{fma}\left(x, y, z\right) - z\right) - \left(x \cdot y + 1\right)}\right)}\]
  11. Using strategy rm
  12. Applied associate--r+15.4

    \[\leadsto \log \left(e^{\color{blue}{\left(\left(\mathsf{fma}\left(x, y, z\right) - z\right) - x \cdot y\right) - 1}}\right)\]
  13. Using strategy rm
  14. Applied exp-diff15.4

    \[\leadsto \log \color{blue}{\left(\frac{e^{\left(\mathsf{fma}\left(x, y, z\right) - z\right) - x \cdot y}}{e^{1}}\right)}\]
  15. Applied log-div15.4

    \[\leadsto \color{blue}{\log \left(e^{\left(\mathsf{fma}\left(x, y, z\right) - z\right) - x \cdot y}\right) - \log \left(e^{1}\right)}\]
  16. Simplified8.3

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(x, y, z\right) - \left(y \cdot x + z\right)\right)} - \log \left(e^{1}\right)\]
  17. Simplified8.3

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

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

Reproduce

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

  :herbie-target
  -1.0

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