Average Error: 45.4 → 7.9
Time: 2.1s
Precision: binary64
\[\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\]
\[\log \left(\frac{e^{\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)}}{e}\right)\]
\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)
\log \left(\frac{e^{\mathsf{fma}\left(x, y, z\right) - \left(z + x \cdot y\right)}}{e}\right)
(FPCore (x y z) :precision binary64 (- (fma x y z) (+ 1.0 (+ (* x y) z))))
(FPCore (x y z)
 :precision binary64
 (log (/ (exp (- (fma x y z) (+ z (* x y)))) E)))
double code(double x, double y, double z) {
	return ((double) (((double) fma(x, y, z)) - ((double) (1.0 + ((double) (((double) (x * y)) + z))))));
}
double code(double x, double y, double z) {
	return ((double) log((((double) exp(((double) (((double) fma(x, y, z)) - ((double) (z + ((double) (x * y)))))))) / ((double) M_E))));
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original45.4
Target0
Herbie7.9
\[-1\]

Derivation

  1. Initial program 45.4

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

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

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

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

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

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

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

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

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

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

Reproduce

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

  :herbie-target
  -1.0

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