Average Error: 45.3 → 8.0
Time: 20.2s
Precision: 64
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
\[\left(\left(\log \left(\frac{e^{\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)}}{e}\right)\right)\right)\]
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
\left(\left(\log \left(\frac{e^{\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)}}{e}\right)\right)\right)
double f(double x, double y, double z) {
        double r3641794 = x;
        double r3641795 = y;
        double r3641796 = z;
        double r3641797 = fma(r3641794, r3641795, r3641796);
        double r3641798 = 1.0;
        double r3641799 = r3641794 * r3641795;
        double r3641800 = r3641799 + r3641796;
        double r3641801 = r3641798 + r3641800;
        double r3641802 = r3641797 - r3641801;
        return r3641802;
}

double f(double x, double y, double z) {
        double r3641803 = x;
        double r3641804 = y;
        double r3641805 = z;
        double r3641806 = fma(r3641803, r3641804, r3641805);
        double r3641807 = r3641803 * r3641804;
        double r3641808 = r3641805 + r3641807;
        double r3641809 = r3641806 - r3641808;
        double r3641810 = exp(r3641809);
        double r3641811 = exp(1.0);
        double r3641812 = r3641810 / r3641811;
        double r3641813 = log(r3641812);
        double r3641814 = /* ERROR: no posit support in C */;
        double r3641815 = /* ERROR: no posit support in C */;
        return r3641815;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 45.3

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

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

    \[\leadsto \left(\left(\mathsf{fma}\left(x, y, z\right) - \left(1 + \color{blue}{\left(\sqrt[3]{x \cdot y + z} \cdot \sqrt[3]{x \cdot y + z}\right) \cdot \sqrt[3]{x \cdot y + z}}\right)\right)\right)\]
  6. Using strategy rm
  7. Applied insert-posit1644.6

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

    \[\leadsto \color{blue}{\left(\left(\left(\mathsf{fma}\left(x, y, z\right) - x \cdot y\right) - \left(1 + z\right)\right)\right)}\]
  9. Using strategy rm
  10. Applied add-log-exp35.7

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

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

    \[\leadsto \left(\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 + z}\right)\right)\right)\]
  13. Applied diff-log47.7

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

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

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

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

Reproduce

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

  :herbie-target
  -1

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