Average Error: 44.8 → 8.2
Time: 30.0s
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(y \cdot x + z\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(y \cdot x + z\right)\right) - 1
double f(double x, double y, double z) {
        double r3915785 = x;
        double r3915786 = y;
        double r3915787 = z;
        double r3915788 = fma(r3915785, r3915786, r3915787);
        double r3915789 = 1.0;
        double r3915790 = r3915785 * r3915786;
        double r3915791 = r3915790 + r3915787;
        double r3915792 = r3915789 + r3915791;
        double r3915793 = r3915788 - r3915792;
        return r3915793;
}

double f(double x, double y, double z) {
        double r3915794 = x;
        double r3915795 = y;
        double r3915796 = z;
        double r3915797 = fma(r3915794, r3915795, r3915796);
        double r3915798 = r3915795 * r3915794;
        double r3915799 = r3915798 + r3915796;
        double r3915800 = r3915797 - r3915799;
        double r3915801 = 1.0;
        double r3915802 = r3915800 - r3915801;
        return r3915802;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original44.8
Target0
Herbie8.2
\[-1\]

Derivation

  1. Initial program 44.8

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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

  :herbie-target
  -1.0

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