Average Error: 6.0 → 4.1
Time: 6.9s
Precision: 64
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le 4636713545035469:\\ \;\;\;\;x \cdot \log x + \mathsf{fma}\left(-0.5, \log x, \left(\frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - x\right) + 0.91893853320467001\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\ \end{array}\]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}
\begin{array}{l}
\mathbf{if}\;x \le 4636713545035469:\\
\;\;\;\;x \cdot \log x + \mathsf{fma}\left(-0.5, \log x, \left(\frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - x\right) + 0.91893853320467001\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\

\end{array}
double f(double x, double y, double z) {
        double r416353 = x;
        double r416354 = 0.5;
        double r416355 = r416353 - r416354;
        double r416356 = log(r416353);
        double r416357 = r416355 * r416356;
        double r416358 = r416357 - r416353;
        double r416359 = 0.91893853320467;
        double r416360 = r416358 + r416359;
        double r416361 = y;
        double r416362 = 0.0007936500793651;
        double r416363 = r416361 + r416362;
        double r416364 = z;
        double r416365 = r416363 * r416364;
        double r416366 = 0.0027777777777778;
        double r416367 = r416365 - r416366;
        double r416368 = r416367 * r416364;
        double r416369 = 0.083333333333333;
        double r416370 = r416368 + r416369;
        double r416371 = r416370 / r416353;
        double r416372 = r416360 + r416371;
        return r416372;
}

double f(double x, double y, double z) {
        double r416373 = x;
        double r416374 = 4636713545035469.0;
        bool r416375 = r416373 <= r416374;
        double r416376 = log(r416373);
        double r416377 = r416373 * r416376;
        double r416378 = 0.5;
        double r416379 = -r416378;
        double r416380 = y;
        double r416381 = 0.0007936500793651;
        double r416382 = r416380 + r416381;
        double r416383 = z;
        double r416384 = r416382 * r416383;
        double r416385 = 0.0027777777777778;
        double r416386 = r416384 - r416385;
        double r416387 = r416386 * r416383;
        double r416388 = 0.083333333333333;
        double r416389 = r416387 + r416388;
        double r416390 = r416389 / r416373;
        double r416391 = r416390 - r416373;
        double r416392 = 0.91893853320467;
        double r416393 = r416391 + r416392;
        double r416394 = fma(r416379, r416376, r416393);
        double r416395 = r416377 + r416394;
        double r416396 = 2.0;
        double r416397 = pow(r416383, r416396);
        double r416398 = r416397 / r416373;
        double r416399 = r416381 * r416398;
        double r416400 = 1.0;
        double r416401 = r416400 / r416373;
        double r416402 = log(r416401);
        double r416403 = fma(r416402, r416373, r416373);
        double r416404 = r416399 - r416403;
        double r416405 = fma(r416398, r416380, r416404);
        double r416406 = r416375 ? r416395 : r416405;
        return r416406;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.0
Target1.2
Herbie4.1
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.91893853320467001 - x\right)\right) + \frac{0.0833333333333329956}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 7.93650079365100015 \cdot 10^{-4}\right) - 0.0027777777777778\right)\]

Derivation

  1. Split input into 2 regimes
  2. if x < 4636713545035469.0

    1. Initial program 0.2

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    2. Simplified0.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)}\]
    3. Using strategy rm
    4. Applied associate--r-0.2

      \[\leadsto \mathsf{fma}\left(\log x, x - 0.5, \color{blue}{\left(\frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - x\right) + 0.91893853320467001}\right)\]
    5. Using strategy rm
    6. Applied fma-udef0.2

      \[\leadsto \color{blue}{\log x \cdot \left(x - 0.5\right) + \left(\left(\frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - x\right) + 0.91893853320467001\right)}\]
    7. Using strategy rm
    8. Applied sub-neg0.2

      \[\leadsto \log x \cdot \color{blue}{\left(x + \left(-0.5\right)\right)} + \left(\left(\frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - x\right) + 0.91893853320467001\right)\]
    9. Applied distribute-rgt-in0.2

      \[\leadsto \color{blue}{\left(x \cdot \log x + \left(-0.5\right) \cdot \log x\right)} + \left(\left(\frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - x\right) + 0.91893853320467001\right)\]
    10. Applied associate-+l+0.2

      \[\leadsto \color{blue}{x \cdot \log x + \left(\left(-0.5\right) \cdot \log x + \left(\left(\frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - x\right) + 0.91893853320467001\right)\right)}\]
    11. Simplified0.2

      \[\leadsto x \cdot \log x + \color{blue}{\mathsf{fma}\left(-0.5, \log x, \left(\frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - x\right) + 0.91893853320467001\right)}\]

    if 4636713545035469.0 < x

    1. Initial program 10.5

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.91893853320467001\right) + \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x}\]
    2. Simplified10.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(\log x, x - 0.5, \frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - \left(x - 0.91893853320467001\right)\right)}\]
    3. Taylor expanded around inf 10.5

      \[\leadsto \color{blue}{\left(7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} + \frac{{z}^{2} \cdot y}{x}\right) - \left(x + x \cdot \log \left(\frac{1}{x}\right)\right)}\]
    4. Simplified7.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 4636713545035469:\\ \;\;\;\;x \cdot \log x + \mathsf{fma}\left(-0.5, \log x, \left(\frac{\left(\left(y + 7.93650079365100015 \cdot 10^{-4}\right) \cdot z - 0.0027777777777778\right) \cdot z + 0.0833333333333329956}{x} - x\right) + 0.91893853320467001\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{{z}^{2}}{x}, y, 7.93650079365100015 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} - \mathsf{fma}\left(\log \left(\frac{1}{x}\right), x, x\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020064 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:$slogFactorial from math-functions-0.1.5.2, B"
  :precision binary64

  :herbie-target
  (+ (+ (+ (* (- x 0.5) (log x)) (- 0.91893853320467 x)) (/ 0.083333333333333 x)) (* (/ z x) (- (* z (+ y 0.0007936500793651)) 0.0027777777777778)))

  (+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467) (/ (+ (* (- (* (+ y 0.0007936500793651) z) 0.0027777777777778) z) 0.083333333333333) x)))