Average Error: 6.1 → 3.4
Time: 8.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 2.039249629896831462504857340149709590195 \cdot 10^{108}:\\ \;\;\;\;\frac{\log x \cdot \left(x \cdot x - 0.5 \cdot 0.5\right)}{x + 0.5} + \left(\frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log x, x - 0.5, \frac{1}{\mathsf{fma}\left(0.4000000000000064059868520871532382443547 \cdot x, z, 12.00000000000004796163466380676254630089 \cdot x - 0.1009522780952416126654114236771420110017 \cdot \left(x \cdot {z}^{2}\right)\right)} - x\right) + 0.9189385332046700050057097541866824030876\\ \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.039249629896831462504857340149709590195 \cdot 10^{108}:\\
\;\;\;\;\frac{\log x \cdot \left(x \cdot x - 0.5 \cdot 0.5\right)}{x + 0.5} + \left(\frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r386679 = x;
        double r386680 = 0.5;
        double r386681 = r386679 - r386680;
        double r386682 = log(r386679);
        double r386683 = r386681 * r386682;
        double r386684 = r386683 - r386679;
        double r386685 = 0.91893853320467;
        double r386686 = r386684 + r386685;
        double r386687 = y;
        double r386688 = 0.0007936500793651;
        double r386689 = r386687 + r386688;
        double r386690 = z;
        double r386691 = r386689 * r386690;
        double r386692 = 0.0027777777777778;
        double r386693 = r386691 - r386692;
        double r386694 = r386693 * r386690;
        double r386695 = 0.083333333333333;
        double r386696 = r386694 + r386695;
        double r386697 = r386696 / r386679;
        double r386698 = r386686 + r386697;
        return r386698;
}

double f(double x, double y, double z) {
        double r386699 = x;
        double r386700 = 2.0392496298968315e+108;
        bool r386701 = r386699 <= r386700;
        double r386702 = log(r386699);
        double r386703 = r386699 * r386699;
        double r386704 = 0.5;
        double r386705 = r386704 * r386704;
        double r386706 = r386703 - r386705;
        double r386707 = r386702 * r386706;
        double r386708 = r386699 + r386704;
        double r386709 = r386707 / r386708;
        double r386710 = y;
        double r386711 = 0.0007936500793651;
        double r386712 = r386710 + r386711;
        double r386713 = z;
        double r386714 = r386712 * r386713;
        double r386715 = 0.0027777777777778;
        double r386716 = r386714 - r386715;
        double r386717 = r386716 * r386713;
        double r386718 = 0.083333333333333;
        double r386719 = r386717 + r386718;
        double r386720 = r386719 / r386699;
        double r386721 = 0.91893853320467;
        double r386722 = r386699 - r386721;
        double r386723 = r386720 - r386722;
        double r386724 = r386709 + r386723;
        double r386725 = r386699 - r386704;
        double r386726 = 1.0;
        double r386727 = 0.4000000000000064;
        double r386728 = r386727 * r386699;
        double r386729 = 12.000000000000048;
        double r386730 = r386729 * r386699;
        double r386731 = 0.10095227809524161;
        double r386732 = 2.0;
        double r386733 = pow(r386713, r386732);
        double r386734 = r386699 * r386733;
        double r386735 = r386731 * r386734;
        double r386736 = r386730 - r386735;
        double r386737 = fma(r386728, r386713, r386736);
        double r386738 = r386726 / r386737;
        double r386739 = r386738 - r386699;
        double r386740 = fma(r386702, r386725, r386739);
        double r386741 = r386740 + r386721;
        double r386742 = r386701 ? r386724 : r386741;
        return r386742;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.1
Target1.1
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.0392496298968315e+108

    1. Initial program 1.5

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

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

      \[\leadsto \color{blue}{\log x \cdot \left(x - 0.5\right) + \left(\frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)}\]
    5. Using strategy rm
    6. Applied flip--1.5

      \[\leadsto \log x \cdot \color{blue}{\frac{x \cdot x - 0.5 \cdot 0.5}{x + 0.5}} + \left(\frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)\]
    7. Applied associate-*r/1.5

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

    if 2.0392496298968315e+108 < x

    1. Initial program 13.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. Simplified13.1

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

      \[\leadsto \color{blue}{\log x \cdot \left(x - 0.5\right) + \left(\frac{\left(\left(y + 7.936500793651000149400709382518925849581 \cdot 10^{-4}\right) \cdot z - 0.002777777777777800001512975569539776188321\right) \cdot z + 0.08333333333333299564049667651488562114537}{x} - \left(x - 0.9189385332046700050057097541866824030876\right)\right)}\]
    5. Using strategy rm
    6. Applied associate--r-13.2

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

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

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

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

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

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

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

Reproduce

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