There is a cephes math library on the Internet to provide accuracy computation of math function, e.g. sin,cos,tan,erf, gamma, lgamma, etc.
It implements the function in an intelligent way. For example, it uses different asymptotic series on the different domain when computing gamma function and switches to Stirling's approximation when the argument is too large.
Basically, the library uses all means of methods, e.g. Asymptotic series, Numerical Integration, Newton's method, Pade approximation, continued fraction.
If I want to fully understand what it is going on and study how to deduce such formula and implement such numerical algorithms, what are the recommended textbook?
For example, I want to compute an efficient and accurate specialized lgamma_exp(x) = lgamma(exp(x)) with argument in exp(x) rather than in x. There is no way except computing exp(x) first, which might overflow on the computer.
This is an answer to your example question.
For large values of the argument of a function, you can rely on asymptotic formulas. In the case of Gamma, you can work with the Stirling approximation
$$\log(\Gamma(e^x))\approx\log\sqrt{2\pi}+(x-1)e^x-\frac x2.$$
the relative error will be on the order of $$\frac{e^{-x}}{12}.$$