Average Error: 45.0 → 8.4
Time: 17.6s
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 r3908888 = x;
        double r3908889 = y;
        double r3908890 = z;
        double r3908891 = fma(r3908888, r3908889, r3908890);
        double r3908892 = 1.0;
        double r3908893 = r3908888 * r3908889;
        double r3908894 = r3908893 + r3908890;
        double r3908895 = r3908892 + r3908894;
        double r3908896 = r3908891 - r3908895;
        return r3908896;
}

double f(double x, double y, double z) {
        double r3908897 = x;
        double r3908898 = y;
        double r3908899 = z;
        double r3908900 = fma(r3908897, r3908898, r3908899);
        double r3908901 = r3908897 * r3908898;
        double r3908902 = r3908899 + r3908901;
        double r3908903 = r3908900 - r3908902;
        double r3908904 = 1.0;
        double r3908905 = r3908903 - r3908904;
        double r3908906 = exp(r3908905);
        double r3908907 = log(r3908906);
        return r3908907;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original45.0
Target0
Herbie8.4
\[-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 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.6

    \[\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.6

    \[\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.6

    \[\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.6

    \[\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.6

    \[\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.6

    \[\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. Simplified34.7

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

    \[\leadsto \color{blue}{\left(\left(\mathsf{fma}\left(x, y, z\right) - x \cdot y\right) - 1\right) - z}\]
  13. Using strategy rm
  14. Applied add-log-exp36.2

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

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

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

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

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

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

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

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

    \[\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 2019172 
(FPCore (x y z)
  :name "simple fma test"

  :herbie-target
  -1.0

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