Average Error: 0.1 → 0.1
Time: 36.7s
Precision: 64
\[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z\]
\[x + \left(y - \mathsf{fma}\left(y + 0.5, \log y, z\right)\right)\]
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
x + \left(y - \mathsf{fma}\left(y + 0.5, \log y, z\right)\right)
double f(double x, double y, double z) {
        double r16973271 = x;
        double r16973272 = y;
        double r16973273 = 0.5;
        double r16973274 = r16973272 + r16973273;
        double r16973275 = log(r16973272);
        double r16973276 = r16973274 * r16973275;
        double r16973277 = r16973271 - r16973276;
        double r16973278 = r16973277 + r16973272;
        double r16973279 = z;
        double r16973280 = r16973278 - r16973279;
        return r16973280;
}

double f(double x, double y, double z) {
        double r16973281 = x;
        double r16973282 = y;
        double r16973283 = 0.5;
        double r16973284 = r16973282 + r16973283;
        double r16973285 = log(r16973282);
        double r16973286 = z;
        double r16973287 = fma(r16973284, r16973285, r16973286);
        double r16973288 = r16973282 - r16973287;
        double r16973289 = r16973281 + r16973288;
        return r16973289;
}

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. Simplified0.1

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

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

Reproduce

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

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

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