Average Error: 45.2 → 7.7
Time: 15.9s
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 r1408224 = x;
        double r1408225 = y;
        double r1408226 = z;
        double r1408227 = fma(r1408224, r1408225, r1408226);
        double r1408228 = 1.0;
        double r1408229 = r1408224 * r1408225;
        double r1408230 = r1408229 + r1408226;
        double r1408231 = r1408228 + r1408230;
        double r1408232 = r1408227 - r1408231;
        return r1408232;
}

double f(double x, double y, double z) {
        double r1408233 = x;
        double r1408234 = y;
        double r1408235 = z;
        double r1408236 = fma(r1408233, r1408234, r1408235);
        double r1408237 = r1408233 * r1408234;
        double r1408238 = r1408235 + r1408237;
        double r1408239 = r1408236 - r1408238;
        double r1408240 = 1.0;
        double r1408241 = r1408239 - r1408240;
        double r1408242 = exp(r1408241);
        double r1408243 = log(r1408242);
        double r1408244 = /* ERROR: no posit support in C */;
        double r1408245 = /* ERROR: no posit support in C */;
        return r1408245;
}

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-exp47.1

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

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

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

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

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

    \[\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 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)}\]
  11. 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)}\]
  12. Using strategy rm
  13. Applied add-log-exp31.6

    \[\leadsto \left(\left(\left(\mathsf{fma}\left(x, y, z\right) - z\right) - \color{blue}{\log \left(e^{y \cdot x + 1}\right)}\right)\right)\]
  14. 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 + 1}\right)\right)\right)\]
  15. 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 + 1}\right)\right)\right)\]
  16. 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 + 1}\right)\right)\right)\]
  17. 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 + 1}}\right)\right)}\right)\]
  18. 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)\]
  19. 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))))