Average Error: 45.1 → 7.7
Time: 12.7s
Precision: 64
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
\[\log \left(e^{\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right) - 1}\right)\]
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
\log \left(e^{\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right) - 1}\right)
double f(double x, double y, double z) {
        double r4467982 = x;
        double r4467983 = y;
        double r4467984 = z;
        double r4467985 = fma(r4467982, r4467983, r4467984);
        double r4467986 = 1.0;
        double r4467987 = r4467982 * r4467983;
        double r4467988 = r4467987 + r4467984;
        double r4467989 = r4467986 + r4467988;
        double r4467990 = r4467985 - r4467989;
        return r4467990;
}

double f(double x, double y, double z) {
        double r4467991 = x;
        double r4467992 = y;
        double r4467993 = z;
        double r4467994 = fma(r4467991, r4467992, r4467993);
        double r4467995 = r4467991 * r4467992;
        double r4467996 = r4467993 + r4467995;
        double r4467997 = r4467994 - r4467996;
        double r4467998 = 1.0;
        double r4467999 = r4467997 - r4467998;
        double r4468000 = exp(r4467999);
        double r4468001 = log(r4468000);
        return r4468001;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original45.1
Target0
Herbie7.7
\[-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 associate--r+45.1

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

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

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

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

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

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

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

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

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

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

Reproduce

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

  :herbie-target
  -1.0

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