Average Error: 0.1 → 0.1
Time: 5.6s
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(\left(1 - z\right) + \log z\right)\right)\]
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\mathsf{fma}\left(x, 0.5, y \cdot \left(\left(1 - z\right) + \log z\right)\right)
double f(double x, double y, double z) {
        double r283417 = x;
        double r283418 = 0.5;
        double r283419 = r283417 * r283418;
        double r283420 = y;
        double r283421 = 1.0;
        double r283422 = z;
        double r283423 = r283421 - r283422;
        double r283424 = log(r283422);
        double r283425 = r283423 + r283424;
        double r283426 = r283420 * r283425;
        double r283427 = r283419 + r283426;
        return r283427;
}

double f(double x, double y, double z) {
        double r283428 = x;
        double r283429 = 0.5;
        double r283430 = y;
        double r283431 = 1.0;
        double r283432 = z;
        double r283433 = r283431 - r283432;
        double r283434 = log(r283432);
        double r283435 = r283433 + r283434;
        double r283436 = r283430 * r283435;
        double r283437 = fma(r283428, r283429, r283436);
        return r283437;
}

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. Using strategy rm
  6. Applied distribute-lft-out0.1

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

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

Reproduce

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