Average Error: 45.5 → 8.3
Time: 13.9s
Precision: 64
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
\[\log \left(e^{\left(\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right)\right) - 1}\right)\]
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
\log \left(e^{\left(\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right)\right) - 1}\right)
double f(double x, double y, double z) {
        double r2733474 = x;
        double r2733475 = y;
        double r2733476 = z;
        double r2733477 = fma(r2733474, r2733475, r2733476);
        double r2733478 = 1.0;
        double r2733479 = r2733474 * r2733475;
        double r2733480 = r2733479 + r2733476;
        double r2733481 = r2733478 + r2733480;
        double r2733482 = r2733477 - r2733481;
        return r2733482;
}

double f(double x, double y, double z) {
        double r2733483 = x;
        double r2733484 = y;
        double r2733485 = z;
        double r2733486 = fma(r2733483, r2733484, r2733485);
        double r2733487 = r2733483 * r2733484;
        double r2733488 = r2733485 + r2733487;
        double r2733489 = r2733486 - r2733488;
        double r2733490 = /* ERROR: no posit support in C */;
        double r2733491 = /* ERROR: no posit support in C */;
        double r2733492 = 1.0;
        double r2733493 = r2733491 - r2733492;
        double r2733494 = exp(r2733493);
        double r2733495 = log(r2733494);
        return r2733495;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 45.5

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

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

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

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

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

    \[\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-exp48.0

    \[\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-log48.0

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

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

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

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

Reproduce

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

  :herbie-target
  -1

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