Average Error: 45.2 → 7.7
Time: 14.4s
Precision: 64
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
\[\left(\left(\log \left(e^{\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right) - 1}\right)\right)\right)\]
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
\left(\left(\log \left(e^{\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right) - 1}\right)\right)\right)
double f(double x, double y, double z) {
        double r1542925 = x;
        double r1542926 = y;
        double r1542927 = z;
        double r1542928 = fma(r1542925, r1542926, r1542927);
        double r1542929 = 1.0;
        double r1542930 = r1542925 * r1542926;
        double r1542931 = r1542930 + r1542927;
        double r1542932 = r1542929 + r1542931;
        double r1542933 = r1542928 - r1542932;
        return r1542933;
}

double f(double x, double y, double z) {
        double r1542934 = x;
        double r1542935 = y;
        double r1542936 = z;
        double r1542937 = fma(r1542934, r1542935, r1542936);
        double r1542938 = r1542934 * r1542935;
        double r1542939 = r1542936 + r1542938;
        double r1542940 = r1542937 - r1542939;
        double r1542941 = 1.0;
        double r1542942 = r1542940 - r1542941;
        double r1542943 = exp(r1542942);
        double r1542944 = log(r1542943);
        double r1542945 = /* ERROR: no posit support in C */;
        double r1542946 = /* ERROR: no posit support in C */;
        return r1542946;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original45.2
Target0
Herbie7.7
\[-1\]

Derivation

  1. Initial program 45.2

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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

  :herbie-target
  -1

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