Average Error: 6.0 → 3.4
Time: 26.6s
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 2.837151033571315686909541353898546681387 \cdot 10^{129}:\\ \;\;\;\;\left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \frac{1}{x \cdot \frac{1}{\mathsf{fma}\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, z, 0.08333333333333299564049667651488562114537\right)}}\right)\right) - x\\ \mathbf{else}:\\ \;\;\;\;\left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \frac{1}{x \cdot \mathsf{fma}\left(z, 0.4000000000000064059868520871532382443547 - 0.1009522780952416126654114236771420110017 \cdot z, 12.00000000000004796163466380676254630089\right)}\right)\right) - x\\ \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 2.837151033571315686909541353898546681387 \cdot 10^{129}:\\
\;\;\;\;\left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \frac{1}{x \cdot \frac{1}{\mathsf{fma}\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, z, 0.08333333333333299564049667651488562114537\right)}}\right)\right) - x\\

\mathbf{else}:\\
\;\;\;\;\left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \frac{1}{x \cdot \mathsf{fma}\left(z, 0.4000000000000064059868520871532382443547 - 0.1009522780952416126654114236771420110017 \cdot z, 12.00000000000004796163466380676254630089\right)}\right)\right) - x\\

\end{array}
double f(double x, double y, double z) {
        double r261860 = x;
        double r261861 = 0.5;
        double r261862 = r261860 - r261861;
        double r261863 = log(r261860);
        double r261864 = r261862 * r261863;
        double r261865 = r261864 - r261860;
        double r261866 = 0.91893853320467;
        double r261867 = r261865 + r261866;
        double r261868 = y;
        double r261869 = 0.0007936500793651;
        double r261870 = r261868 + r261869;
        double r261871 = z;
        double r261872 = r261870 * r261871;
        double r261873 = 0.0027777777777778;
        double r261874 = r261872 - r261873;
        double r261875 = r261874 * r261871;
        double r261876 = 0.083333333333333;
        double r261877 = r261875 + r261876;
        double r261878 = r261877 / r261860;
        double r261879 = r261867 + r261878;
        return r261879;
}

double f(double x, double y, double z) {
        double r261880 = x;
        double r261881 = 2.8371510335713157e+129;
        bool r261882 = r261880 <= r261881;
        double r261883 = 0.91893853320467;
        double r261884 = log(r261880);
        double r261885 = 0.5;
        double r261886 = r261880 - r261885;
        double r261887 = 1.0;
        double r261888 = y;
        double r261889 = 0.0007936500793651;
        double r261890 = r261888 + r261889;
        double r261891 = z;
        double r261892 = r261890 * r261891;
        double r261893 = 0.0027777777777778;
        double r261894 = r261892 - r261893;
        double r261895 = 0.083333333333333;
        double r261896 = fma(r261894, r261891, r261895);
        double r261897 = r261887 / r261896;
        double r261898 = r261880 * r261897;
        double r261899 = r261887 / r261898;
        double r261900 = fma(r261884, r261886, r261899);
        double r261901 = r261883 + r261900;
        double r261902 = r261901 - r261880;
        double r261903 = 0.4000000000000064;
        double r261904 = 0.10095227809524161;
        double r261905 = r261904 * r261891;
        double r261906 = r261903 - r261905;
        double r261907 = 12.000000000000048;
        double r261908 = fma(r261891, r261906, r261907);
        double r261909 = r261880 * r261908;
        double r261910 = r261887 / r261909;
        double r261911 = fma(r261884, r261886, r261910);
        double r261912 = r261883 + r261911;
        double r261913 = r261912 - r261880;
        double r261914 = r261882 ? r261902 : r261913;
        return r261914;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.0
Target1.4
Herbie3.4
\[\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 < 2.8371510335713157e+129

    1. Initial program 1.7

      \[\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. Simplified1.7

      \[\leadsto \color{blue}{\left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \frac{\mathsf{fma}\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, z, 0.08333333333333299564049667651488562114537\right)}{x}\right)\right) - x}\]
    3. Using strategy rm
    4. Applied clear-num1.8

      \[\leadsto \left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \color{blue}{\frac{1}{\frac{x}{\mathsf{fma}\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, z, 0.08333333333333299564049667651488562114537\right)}}}\right)\right) - x\]
    5. Using strategy rm
    6. Applied div-inv1.9

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

    if 2.8371510335713157e+129 < x

    1. Initial program 13.8

      \[\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. Simplified13.8

      \[\leadsto \color{blue}{\left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \frac{\mathsf{fma}\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, z, 0.08333333333333299564049667651488562114537\right)}{x}\right)\right) - x}\]
    3. Using strategy rm
    4. Applied clear-num13.8

      \[\leadsto \left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \color{blue}{\frac{1}{\frac{x}{\mathsf{fma}\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321, z, 0.08333333333333299564049667651488562114537\right)}}}\right)\right) - x\]
    5. Using strategy rm
    6. Applied div-inv13.8

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

      \[\leadsto \left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \frac{1}{x \cdot \color{blue}{\left(\left(0.4000000000000064059868520871532382443547 \cdot z + 12.00000000000004796163466380676254630089\right) - 0.1009522780952416126654114236771420110017 \cdot {z}^{2}\right)}}\right)\right) - x\]
    8. Simplified6.2

      \[\leadsto \left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \frac{1}{x \cdot \color{blue}{\mathsf{fma}\left(z, 0.4000000000000064059868520871532382443547 - 0.1009522780952416126654114236771420110017 \cdot z, 12.00000000000004796163466380676254630089\right)}}\right)\right) - x\]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.4

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

Reproduce

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