Average Error: 0.1 → 0.1
Time: 20.4s
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 r166659 = x;
        double r166660 = 0.5;
        double r166661 = r166659 * r166660;
        double r166662 = y;
        double r166663 = 1.0;
        double r166664 = z;
        double r166665 = r166663 - r166664;
        double r166666 = log(r166664);
        double r166667 = r166665 + r166666;
        double r166668 = r166662 * r166667;
        double r166669 = r166661 + r166668;
        return r166669;
}

double f(double x, double y, double z) {
        double r166670 = x;
        double r166671 = 0.5;
        double r166672 = 1.0;
        double r166673 = z;
        double r166674 = r166672 - r166673;
        double r166675 = y;
        double r166676 = log(r166673);
        double r166677 = r166676 * r166675;
        double r166678 = fma(r166674, r166675, r166677);
        double r166679 = fma(r166670, r166671, r166678);
        return r166679;
}

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)))))