Average Error: 45.0 → 8.4
Time: 17.0s
Precision: 64
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
\[\log \left(e^{\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right) - 1}\right)\]
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
\log \left(e^{\left(\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)\right) - 1}\right)
double f(double x, double y, double z) {
        double r4416210 = x;
        double r4416211 = y;
        double r4416212 = z;
        double r4416213 = fma(r4416210, r4416211, r4416212);
        double r4416214 = 1.0;
        double r4416215 = r4416210 * r4416211;
        double r4416216 = r4416215 + r4416212;
        double r4416217 = r4416214 + r4416216;
        double r4416218 = r4416213 - r4416217;
        return r4416218;
}

double f(double x, double y, double z) {
        double r4416219 = x;
        double r4416220 = y;
        double r4416221 = z;
        double r4416222 = fma(r4416219, r4416220, r4416221);
        double r4416223 = r4416219 * r4416220;
        double r4416224 = r4416221 + r4416223;
        double r4416225 = r4416222 - r4416224;
        double r4416226 = 1.0;
        double r4416227 = r4416225 - r4416226;
        double r4416228 = exp(r4416227);
        double r4416229 = log(r4416228);
        return r4416229;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 45.0

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(\left(\mathsf{fma}\left(x, y, z\right) - x \cdot y\right) - 1\right) - z}\]
  13. Using strategy rm
  14. Applied add-log-exp36.2

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

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

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

    \[\leadsto \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}\right)\right) - \log \left(e^{z}\right)\]
  18. Applied diff-log47.6

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

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

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

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

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

Reproduce

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

  :herbie-target
  -1.0

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