Average Error: 0.1 → 0.1
Time: 5.3s
Precision: 64
\[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)\]
\[\mathsf{fma}\left(\log z, y, \mathsf{fma}\left(x, 0.5, \left(1 - z\right) \cdot y\right)\right)\]
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\mathsf{fma}\left(\log z, y, \mathsf{fma}\left(x, 0.5, \left(1 - z\right) \cdot y\right)\right)
double f(double x, double y, double z) {
        double r270580 = x;
        double r270581 = 0.5;
        double r270582 = r270580 * r270581;
        double r270583 = y;
        double r270584 = 1.0;
        double r270585 = z;
        double r270586 = r270584 - r270585;
        double r270587 = log(r270585);
        double r270588 = r270586 + r270587;
        double r270589 = r270583 * r270588;
        double r270590 = r270582 + r270589;
        return r270590;
}

double f(double x, double y, double z) {
        double r270591 = z;
        double r270592 = log(r270591);
        double r270593 = y;
        double r270594 = x;
        double r270595 = 0.5;
        double r270596 = 1.0;
        double r270597 = r270596 - r270591;
        double r270598 = r270597 * r270593;
        double r270599 = fma(r270594, r270595, r270598);
        double r270600 = fma(r270592, r270593, r270599);
        return r270600;
}

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

    \[\leadsto x \cdot 0.5 + \color{blue}{\left(y \cdot \left(1 - z\right) + y \cdot \log z\right)}\]
  4. Applied associate-+r+0.1

    \[\leadsto \color{blue}{\left(x \cdot 0.5 + y \cdot \left(1 - z\right)\right) + y \cdot \log z}\]
  5. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 0.5, \left(1 - z\right) \cdot y\right)} + y \cdot \log z\]
  6. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{\left(\log z \cdot y + \left(1 \cdot y + 0.5 \cdot x\right)\right) - z \cdot y}\]
  7. Simplified0.1

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

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

Reproduce

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