Average Error: 0.1 → 0.1
Time: 16.1s
Precision: 64
\[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)\]
\[\mathsf{fma}\left(x, 0.5, y \cdot \left(1 - z\right) + \log z \cdot y\right)\]
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\mathsf{fma}\left(x, 0.5, y \cdot \left(1 - z\right) + \log z \cdot y\right)
double f(double x, double y, double z) {
        double r186670 = x;
        double r186671 = 0.5;
        double r186672 = r186670 * r186671;
        double r186673 = y;
        double r186674 = 1.0;
        double r186675 = z;
        double r186676 = r186674 - r186675;
        double r186677 = log(r186675);
        double r186678 = r186676 + r186677;
        double r186679 = r186673 * r186678;
        double r186680 = r186672 + r186679;
        return r186680;
}

double f(double x, double y, double z) {
        double r186681 = x;
        double r186682 = 0.5;
        double r186683 = y;
        double r186684 = 1.0;
        double r186685 = z;
        double r186686 = r186684 - r186685;
        double r186687 = r186683 * r186686;
        double r186688 = log(r186685);
        double r186689 = r186688 * r186683;
        double r186690 = r186687 + r186689;
        double r186691 = fma(r186681, r186682, r186690);
        return r186691;
}

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, y \cdot \left(1 - z\right) + \color{blue}{\log z \cdot y}\right)\]
  6. Final simplification0.1

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

Reproduce

herbie shell --seed 2019235 +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)))))