Average Error: 0.1 → 0.1
Time: 21.5s
Precision: 64
\[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)\]
\[\mathsf{fma}\left(x, 0.5, \left(1 - z\right) \cdot y + \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, \left(1 - z\right) \cdot y + \log z \cdot y\right)
double f(double x, double y, double z) {
        double r17244382 = x;
        double r17244383 = 0.5;
        double r17244384 = r17244382 * r17244383;
        double r17244385 = y;
        double r17244386 = 1.0;
        double r17244387 = z;
        double r17244388 = r17244386 - r17244387;
        double r17244389 = log(r17244387);
        double r17244390 = r17244388 + r17244389;
        double r17244391 = r17244385 * r17244390;
        double r17244392 = r17244384 + r17244391;
        return r17244392;
}

double f(double x, double y, double z) {
        double r17244393 = x;
        double r17244394 = 0.5;
        double r17244395 = 1.0;
        double r17244396 = z;
        double r17244397 = r17244395 - r17244396;
        double r17244398 = y;
        double r17244399 = r17244397 * r17244398;
        double r17244400 = log(r17244396);
        double r17244401 = r17244400 * r17244398;
        double r17244402 = r17244399 + r17244401;
        double r17244403 = fma(r17244393, r17244394, r17244402);
        return r17244403;
}

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-rgt-in0.1

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

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

Reproduce

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

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

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