Average Error: 6.3 → 2.7
Time: 29.0s
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 6265973.915414215065538883209228515625:\\ \;\;\;\;\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{elif}\;x \le 2.140356648813802971504363166122303237728 \cdot 10^{175}:\\ \;\;\;\;\left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(-\frac{z}{x}, 0.002777777777777800001512975569539776188321, \frac{{z}^{2}}{x} \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right)\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 6265973.915414215065538883209228515625:\\
\;\;\;\;\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{elif}\;x \le 2.140356648813802971504363166122303237728 \cdot 10^{175}:\\
\;\;\;\;\left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(-\frac{z}{x}, 0.002777777777777800001512975569539776188321, \frac{{z}^{2}}{x} \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right)\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 r256748 = x;
        double r256749 = 0.5;
        double r256750 = r256748 - r256749;
        double r256751 = log(r256748);
        double r256752 = r256750 * r256751;
        double r256753 = r256752 - r256748;
        double r256754 = 0.91893853320467;
        double r256755 = r256753 + r256754;
        double r256756 = y;
        double r256757 = 0.0007936500793651;
        double r256758 = r256756 + r256757;
        double r256759 = z;
        double r256760 = r256758 * r256759;
        double r256761 = 0.0027777777777778;
        double r256762 = r256760 - r256761;
        double r256763 = r256762 * r256759;
        double r256764 = 0.083333333333333;
        double r256765 = r256763 + r256764;
        double r256766 = r256765 / r256748;
        double r256767 = r256755 + r256766;
        return r256767;
}

double f(double x, double y, double z) {
        double r256768 = x;
        double r256769 = 6265973.915414215;
        bool r256770 = r256768 <= r256769;
        double r256771 = 0.91893853320467;
        double r256772 = log(r256768);
        double r256773 = 0.5;
        double r256774 = r256768 - r256773;
        double r256775 = 1.0;
        double r256776 = y;
        double r256777 = 0.0007936500793651;
        double r256778 = r256776 + r256777;
        double r256779 = z;
        double r256780 = r256778 * r256779;
        double r256781 = 0.0027777777777778;
        double r256782 = r256780 - r256781;
        double r256783 = 0.083333333333333;
        double r256784 = fma(r256782, r256779, r256783);
        double r256785 = r256775 / r256784;
        double r256786 = r256768 * r256785;
        double r256787 = r256775 / r256786;
        double r256788 = fma(r256772, r256774, r256787);
        double r256789 = r256771 + r256788;
        double r256790 = r256789 - r256768;
        double r256791 = 2.140356648813803e+175;
        bool r256792 = r256768 <= r256791;
        double r256793 = r256779 / r256768;
        double r256794 = -r256793;
        double r256795 = 2.0;
        double r256796 = pow(r256779, r256795);
        double r256797 = r256796 / r256768;
        double r256798 = r256797 * r256778;
        double r256799 = fma(r256794, r256781, r256798);
        double r256800 = fma(r256772, r256774, r256799);
        double r256801 = r256771 + r256800;
        double r256802 = r256801 - r256768;
        double r256803 = 0.4000000000000064;
        double r256804 = 0.10095227809524161;
        double r256805 = r256804 * r256779;
        double r256806 = r256803 - r256805;
        double r256807 = 12.000000000000048;
        double r256808 = fma(r256779, r256806, r256807);
        double r256809 = r256768 * r256808;
        double r256810 = r256775 / r256809;
        double r256811 = fma(r256772, r256774, r256810);
        double r256812 = r256771 + r256811;
        double r256813 = r256812 - r256768;
        double r256814 = r256792 ? r256802 : r256813;
        double r256815 = r256770 ? r256790 : r256814;
        return r256815;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.3
Target1.2
Herbie2.7
\[\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 3 regimes
  2. if x < 6265973.915414215

    1. Initial program 0.1

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

      \[\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-num0.3

      \[\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-inv0.4

      \[\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 6265973.915414215 < x < 2.140356648813803e+175

    1. Initial program 6.6

      \[\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. Simplified6.6

      \[\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. Taylor expanded around inf 6.6

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

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

    if 2.140356648813803e+175 < x

    1. Initial program 15.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. Simplified15.2

      \[\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-num15.2

      \[\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-inv15.2

      \[\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 4.4

      \[\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. Simplified4.4

      \[\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 3 regimes into one program.
  4. Final simplification2.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 6265973.915414215065538883209228515625:\\ \;\;\;\;\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{elif}\;x \le 2.140356648813802971504363166122303237728 \cdot 10^{175}:\\ \;\;\;\;\left(0.9189385332046700050057097541866824030876 + \mathsf{fma}\left(\log x, x - 0.5, \mathsf{fma}\left(-\frac{z}{x}, 0.002777777777777800001512975569539776188321, \frac{{z}^{2}}{x} \cdot \left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right)\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 2019304 +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.91893853320467001 x)) (/ 0.0833333333333329956 x)) (* (/ z x) (- (* z (+ y 7.93650079365100015e-4)) 0.0027777777777778)))

  (+ (+ (- (* (- x 0.5) (log x)) x) 0.91893853320467001) (/ (+ (* (- (* (+ y 7.93650079365100015e-4) z) 0.0027777777777778) z) 0.0833333333333329956) x)))