Average Error: 44.8 → 7.6
Time: 16.2s
Precision: 64
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
\[\log \left(\frac{e^{\left(\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right)\right)}}{e}\right)\]
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
\log \left(\frac{e^{\left(\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right)\right)}}{e}\right)
double f(double x, double y, double z) {
        double r1379168 = x;
        double r1379169 = y;
        double r1379170 = z;
        double r1379171 = fma(r1379168, r1379169, r1379170);
        double r1379172 = 1.0;
        double r1379173 = r1379168 * r1379169;
        double r1379174 = r1379173 + r1379170;
        double r1379175 = r1379172 + r1379174;
        double r1379176 = r1379171 - r1379175;
        return r1379176;
}

double f(double x, double y, double z) {
        double r1379177 = x;
        double r1379178 = y;
        double r1379179 = z;
        double r1379180 = fma(r1379177, r1379178, r1379179);
        double r1379181 = r1379177 * r1379178;
        double r1379182 = r1379179 + r1379181;
        double r1379183 = r1379180 - r1379182;
        double r1379184 = /* ERROR: no posit support in C */;
        double r1379185 = /* ERROR: no posit support in C */;
        double r1379186 = exp(r1379185);
        double r1379187 = exp(1.0);
        double r1379188 = r1379186 / r1379187;
        double r1379189 = log(r1379188);
        return r1379189;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original44.8
Target0
Herbie7.6
\[-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.8

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

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

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

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

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

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

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

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

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

    \[\leadsto \log \left(e^{\log \color{blue}{\left(\frac{e^{\left(\mathsf{fma}\left(x, y, z\right) - z\right) - x \cdot y}}{e}\right)}}\right)\]
  14. Taylor expanded around -inf 7.5

    \[\leadsto \log \color{blue}{\left(\frac{e^{\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)}}{e}\right)}\]
  15. Using strategy rm
  16. Applied insert-posit167.6

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

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

Reproduce

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

  :herbie-target
  -1

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