Average Error: 6.0 → 2.2
Time: 23.1s
Precision: 64
\[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le 8.101543792246118631008911597981331166876 \cdot 10^{82}:\\ \;\;\;\;\left(0.9189385332046700050057097541866824030876 + \left(\sqrt{\log x \cdot \left(x - 0.5\right)} \cdot \sqrt{\log x \cdot \left(x - 0.5\right)} - x\right)\right) + \frac{0.08333333333333299564049667651488562114537 + \left(z \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) - 0.002777777777777800001512975569539776188321\right) \cdot z}{x}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876 - x\right) + \mathsf{fma}\left(\frac{z}{x}, -0.002777777777777800001512975569539776188321, \mathsf{fma}\left(7.936500793651000149400709382518925849581 \cdot 10^{-4}, \frac{z}{\frac{x}{z}}, \frac{0.08333333333333299564049667651488562114537}{x}\right)\right)\\ \end{array}\]
\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}
\begin{array}{l}
\mathbf{if}\;x \le 8.101543792246118631008911597981331166876 \cdot 10^{82}:\\
\;\;\;\;\left(0.9189385332046700050057097541866824030876 + \left(\sqrt{\log x \cdot \left(x - 0.5\right)} \cdot \sqrt{\log x \cdot \left(x - 0.5\right)} - x\right)\right) + \frac{0.08333333333333299564049667651488562114537 + \left(z \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) - 0.002777777777777800001512975569539776188321\right) \cdot z}{x}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876 - x\right) + \mathsf{fma}\left(\frac{z}{x}, -0.002777777777777800001512975569539776188321, \mathsf{fma}\left(7.936500793651000149400709382518925849581 \cdot 10^{-4}, \frac{z}{\frac{x}{z}}, \frac{0.08333333333333299564049667651488562114537}{x}\right)\right)\\

\end{array}
double f(double x, double y, double z) {
        double r424396 = x;
        double r424397 = 0.5;
        double r424398 = r424396 - r424397;
        double r424399 = log(r424396);
        double r424400 = r424398 * r424399;
        double r424401 = r424400 - r424396;
        double r424402 = 0.91893853320467;
        double r424403 = r424401 + r424402;
        double r424404 = y;
        double r424405 = 0.0007936500793651;
        double r424406 = r424404 + r424405;
        double r424407 = z;
        double r424408 = r424406 * r424407;
        double r424409 = 0.0027777777777778;
        double r424410 = r424408 - r424409;
        double r424411 = r424410 * r424407;
        double r424412 = 0.083333333333333;
        double r424413 = r424411 + r424412;
        double r424414 = r424413 / r424396;
        double r424415 = r424403 + r424414;
        return r424415;
}

double f(double x, double y, double z) {
        double r424416 = x;
        double r424417 = 8.101543792246119e+82;
        bool r424418 = r424416 <= r424417;
        double r424419 = 0.91893853320467;
        double r424420 = log(r424416);
        double r424421 = 0.5;
        double r424422 = r424416 - r424421;
        double r424423 = r424420 * r424422;
        double r424424 = sqrt(r424423);
        double r424425 = r424424 * r424424;
        double r424426 = r424425 - r424416;
        double r424427 = r424419 + r424426;
        double r424428 = 0.083333333333333;
        double r424429 = z;
        double r424430 = y;
        double r424431 = 0.0007936500793651;
        double r424432 = r424430 + r424431;
        double r424433 = r424429 * r424432;
        double r424434 = 0.0027777777777778;
        double r424435 = r424433 - r424434;
        double r424436 = r424435 * r424429;
        double r424437 = r424428 + r424436;
        double r424438 = r424437 / r424416;
        double r424439 = r424427 + r424438;
        double r424440 = r424419 - r424416;
        double r424441 = fma(r424422, r424420, r424440);
        double r424442 = r424429 / r424416;
        double r424443 = -r424434;
        double r424444 = r424416 / r424429;
        double r424445 = r424429 / r424444;
        double r424446 = r424428 / r424416;
        double r424447 = fma(r424431, r424445, r424446);
        double r424448 = fma(r424442, r424443, r424447);
        double r424449 = r424441 + r424448;
        double r424450 = r424418 ? r424439 : r424449;
        return r424450;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.0
Target1.2
Herbie2.2
\[\left(\left(\left(x - 0.5\right) \cdot \log x + \left(0.9189385332046700050057097541866824030876 - x\right)\right) + \frac{0.08333333333333299564049667651488562114537}{x}\right) + \frac{z}{x} \cdot \left(z \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) - 0.002777777777777800001512975569539776188321\right)\]

Derivation

  1. Split input into 2 regimes
  2. if x < 8.101543792246119e+82

    1. Initial program 0.9

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt1.0

      \[\leadsto \left(\left(\color{blue}{\sqrt{\left(x - 0.5\right) \cdot \log x} \cdot \sqrt{\left(x - 0.5\right) \cdot \log x}} - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
    4. Simplified1.0

      \[\leadsto \left(\left(\color{blue}{\sqrt{\log x \cdot \left(x - 0.5\right)}} \cdot \sqrt{\left(x - 0.5\right) \cdot \log x} - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
    5. Simplified1.0

      \[\leadsto \left(\left(\sqrt{\log x \cdot \left(x - 0.5\right)} \cdot \color{blue}{\sqrt{\log x \cdot \left(x - 0.5\right)}} - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]

    if 8.101543792246119e+82 < x

    1. Initial program 12.2

      \[\left(\left(\left(x - 0.5\right) \cdot \log x - x\right) + 0.9189385332046700050057097541866824030876\right) + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
    2. Taylor expanded around 0 12.2

      \[\leadsto \color{blue}{\left(\left(x \cdot \log x + 0.9189385332046700050057097541866824030876\right) - \left(x + 0.5 \cdot \log x\right)\right)} + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
    3. Simplified12.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876 - x\right)} + \frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x}\]
    4. Taylor expanded around 0 10.5

      \[\leadsto \mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876 - x\right) + \color{blue}{\left(\left(7.936500793651000149400709382518925849581 \cdot 10^{-4} \cdot \frac{{z}^{2}}{x} + 0.08333333333333299564049667651488562114537 \cdot \frac{1}{x}\right) - 0.002777777777777800001512975569539776188321 \cdot \frac{z}{x}\right)}\]
    5. Simplified3.7

      \[\leadsto \mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876 - x\right) + \color{blue}{\mathsf{fma}\left(\frac{z}{x}, -0.002777777777777800001512975569539776188321, \mathsf{fma}\left(7.936500793651000149400709382518925849581 \cdot 10^{-4}, \frac{z}{\frac{x}{z}}, \frac{0.08333333333333299564049667651488562114537}{x}\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 8.101543792246118631008911597981331166876 \cdot 10^{82}:\\ \;\;\;\;\left(0.9189385332046700050057097541866824030876 + \left(\sqrt{\log x \cdot \left(x - 0.5\right)} \cdot \sqrt{\log x \cdot \left(x - 0.5\right)} - x\right)\right) + \frac{0.08333333333333299564049667651488562114537 + \left(z \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) - 0.002777777777777800001512975569539776188321\right) \cdot z}{x}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x - 0.5, \log x, 0.9189385332046700050057097541866824030876 - x\right) + \mathsf{fma}\left(\frac{z}{x}, -0.002777777777777800001512975569539776188321, \mathsf{fma}\left(7.936500793651000149400709382518925849581 \cdot 10^{-4}, \frac{z}{\frac{x}{z}}, \frac{0.08333333333333299564049667651488562114537}{x}\right)\right)\\ \end{array}\]

Reproduce

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

  :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)))