Average Error: 0.1 → 0.1
Time: 24.8s
Precision: 64
\[\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z\]
\[x - \mathsf{fma}\left(\log y, y + 0.5, z - y\right)\]
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
x - \mathsf{fma}\left(\log y, y + 0.5, z - y\right)
double f(double x, double y, double z) {
        double r13179336 = x;
        double r13179337 = y;
        double r13179338 = 0.5;
        double r13179339 = r13179337 + r13179338;
        double r13179340 = log(r13179337);
        double r13179341 = r13179339 * r13179340;
        double r13179342 = r13179336 - r13179341;
        double r13179343 = r13179342 + r13179337;
        double r13179344 = z;
        double r13179345 = r13179343 - r13179344;
        return r13179345;
}

double f(double x, double y, double z) {
        double r13179346 = x;
        double r13179347 = y;
        double r13179348 = log(r13179347);
        double r13179349 = 0.5;
        double r13179350 = r13179347 + r13179349;
        double r13179351 = z;
        double r13179352 = r13179351 - r13179347;
        double r13179353 = fma(r13179348, r13179350, r13179352);
        double r13179354 = r13179346 - r13179353;
        return r13179354;
}

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 - \mathsf{fma}\left(\log y, 0.5 + y, z - y\right)}\]
  3. Using strategy rm
  4. Applied fma-udef0.1

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

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

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

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

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

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

Reproduce

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