Average Error: 0.1 → 0.1
Time: 54.3s
Precision: 64
\[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z\]
\[\left(x - \left(\left(y + 0.5\right) \cdot 0 + \mathsf{fma}\left(\log y, y + 0.5, -y\right)\right)\right) - z\]
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\left(x - \left(\left(y + 0.5\right) \cdot 0 + \mathsf{fma}\left(\log y, y + 0.5, -y\right)\right)\right) - z
double f(double x, double y, double z) {
        double r196587 = x;
        double r196588 = y;
        double r196589 = 0.5;
        double r196590 = r196588 + r196589;
        double r196591 = log(r196588);
        double r196592 = r196590 * r196591;
        double r196593 = r196587 - r196592;
        double r196594 = r196593 + r196588;
        double r196595 = z;
        double r196596 = r196594 - r196595;
        return r196596;
}

double f(double x, double y, double z) {
        double r196597 = x;
        double r196598 = y;
        double r196599 = 0.5;
        double r196600 = r196598 + r196599;
        double r196601 = 0.0;
        double r196602 = r196600 * r196601;
        double r196603 = log(r196598);
        double r196604 = -r196598;
        double r196605 = fma(r196603, r196600, r196604);
        double r196606 = r196602 + r196605;
        double r196607 = r196597 - r196606;
        double r196608 = z;
        double r196609 = r196607 - r196608;
        return r196609;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
Herbie0.1
\[\left(\left(y + x\right) - z\right) - \left(y + 0.5\right) \cdot \log y\]

Derivation

  1. Initial program 0.1

    \[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z\]
  2. Using strategy rm
  3. Applied associate-+l-0.1

    \[\leadsto \color{blue}{\left(x - \left(\left(y + 0.5\right) \cdot \log y - y\right)\right)} - z\]
  4. Using strategy rm
  5. Applied *-un-lft-identity0.1

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019304 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
  :precision binary64

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

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