Average Error: 0.1 → 0.1
Time: 16.3s
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)\right) + y \cdot \log z\]
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)\right) + y \cdot \log z
double f(double x, double y, double z) {
        double r211292 = x;
        double r211293 = 0.5;
        double r211294 = r211292 * r211293;
        double r211295 = y;
        double r211296 = 1.0;
        double r211297 = z;
        double r211298 = r211296 - r211297;
        double r211299 = log(r211297);
        double r211300 = r211298 + r211299;
        double r211301 = r211295 * r211300;
        double r211302 = r211294 + r211301;
        return r211302;
}

double f(double x, double y, double z) {
        double r211303 = x;
        double r211304 = 0.5;
        double r211305 = y;
        double r211306 = 1.0;
        double r211307 = z;
        double r211308 = r211306 - r211307;
        double r211309 = r211305 * r211308;
        double r211310 = fma(r211303, r211304, r211309);
        double r211311 = log(r211307);
        double r211312 = r211305 * r211311;
        double r211313 = r211310 + r211312;
        return r211313;
}

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

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

Reproduce

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