Average Error: 0.1 → 0.1
Time: 21.9s
Precision: 64
\[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)\]
\[\mathsf{fma}\left(x, 0.5, \mathsf{fma}\left(1 - z, y, \log z \cdot y\right)\right)\]
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\mathsf{fma}\left(x, 0.5, \mathsf{fma}\left(1 - z, y, \log z \cdot y\right)\right)
double f(double x, double y, double z) {
        double r156705 = x;
        double r156706 = 0.5;
        double r156707 = r156705 * r156706;
        double r156708 = y;
        double r156709 = 1.0;
        double r156710 = z;
        double r156711 = r156709 - r156710;
        double r156712 = log(r156710);
        double r156713 = r156711 + r156712;
        double r156714 = r156708 * r156713;
        double r156715 = r156707 + r156714;
        return r156715;
}

double f(double x, double y, double z) {
        double r156716 = x;
        double r156717 = 0.5;
        double r156718 = 1.0;
        double r156719 = z;
        double r156720 = r156718 - r156719;
        double r156721 = y;
        double r156722 = log(r156719);
        double r156723 = r156722 * r156721;
        double r156724 = fma(r156720, r156721, r156723);
        double r156725 = fma(r156716, r156717, r156724);
        return r156725;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
Herbie0.1
\[\left(y + 0.5 \cdot x\right) - y \cdot \left(z - \log z\right)\]

Derivation

  1. Initial program 0.1

    \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)\]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 0.5, y \cdot \left(\left(1 - z\right) + \log z\right)\right)}\]
  3. Using strategy rm
  4. Applied distribute-lft-in0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, \color{blue}{y \cdot \left(1 - z\right) + y \cdot \log z}\right)\]
  5. Simplified0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, \color{blue}{\left(1 - z\right) \cdot y} + y \cdot \log z\right)\]
  6. Simplified0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, \left(1 - z\right) \cdot y + \color{blue}{\log z \cdot y}\right)\]
  7. Using strategy rm
  8. Applied fma-def0.1

    \[\leadsto \mathsf{fma}\left(x, 0.5, \color{blue}{\mathsf{fma}\left(1 - z, y, \log z \cdot y\right)}\right)\]
  9. Final simplification0.1

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

Reproduce

herbie shell --seed 2019325 +o rules:numerics
(FPCore (x y z)
  :name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
  :precision binary64

  :herbie-target
  (- (+ y (* 0.5 x)) (* y (- z (log z))))

  (+ (* x 0.5) (* y (+ (- 1 z) (log z)))))