Average Error: 0.1 → 0.1
Time: 4.5s
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) + y \cdot \log z\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) + y \cdot \log z\right)
double f(double x, double y, double z) {
        double r205368 = x;
        double r205369 = 0.5;
        double r205370 = r205368 * r205369;
        double r205371 = y;
        double r205372 = 1.0;
        double r205373 = z;
        double r205374 = r205372 - r205373;
        double r205375 = log(r205373);
        double r205376 = r205374 + r205375;
        double r205377 = r205371 * r205376;
        double r205378 = r205370 + r205377;
        return r205378;
}

double f(double x, double y, double z) {
        double r205379 = x;
        double r205380 = 0.5;
        double r205381 = y;
        double r205382 = 1.0;
        double r205383 = z;
        double r205384 = r205382 - r205383;
        double r205385 = r205381 * r205384;
        double r205386 = log(r205383);
        double r205387 = r205381 * r205386;
        double r205388 = r205385 + r205387;
        double r205389 = fma(r205379, r205380, r205388);
        return r205389;
}

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. Final simplification0.1

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

Reproduce

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