On determining the constant term in Stirling's approximation

It is well-known that the discrete version of Stirling's formula is as follows

$$\log N!=\left(N+\frac12\right)\log N-N+\log C+\int_N^\infty{P_1(t)\over t}\mathrm dt\tag1$$

where $$P_1(t)=B_1(\{t\})$$, and $$C$$ is some constant term emerged while applying the Euler-Maclaurin formula. Using the limit definition of gamma function that

$$\Gamma(s+1)=\lim_{N\to\infty}{N^sN!\over(s+1)(s+2)\cdots(s+N)}$$

I am able to obtain an identity similar to (1) but with respect to continuous variable $$s$$:

$$\log\Gamma(s+1)=\left(s+\frac12\right)\log s-s+\log C+\int_0^\infty{P_1(t)\over s+t}\mathrm dt\tag2$$

I already know that $$C=\sqrt{2\pi}$$ can be obtained by replacing factorial terms in Wallis product, but I wonder if there is an alternative way to figure out the constant.

1 Answer

Indeed, it is possible to determine $$C$$ by employing Legendre's duplication formula, which states

$$\Pi(s)\Pi\left(s-\frac12\right)=2^{-2s}\sqrt\pi\cdot\Pi(2s)$$

where we set $$\Pi(s)=\Gamma(s+1)$$ for convenience

Taking logarithms, we have

$$\color{orange}{\log\Pi(s)+\log\Pi\left(s-\frac12\right)}-\color{purple}{[\log\Pi(2s)-2s\log2]}=\frac12\log\pi$$

Now, due to (2), we get

\begin{aligned} \color{orange}{\log\Pi(s)+\log\Pi\left(s-\frac12\right)} &=\left(s+\frac12\right)\log s-s \\ &+s\log\left(s-\frac12\right)-s+\frac12+2\log C+\mathcal O\left(\frac1s\right) \\ &=s\log\left[s\left(s-\frac12\right)\right]-2s+\frac12\log s \\ &+\frac12+2\log C+\mathcal O\left(\frac1s\right) \end{aligned}

and for the purple part we also have

\begin{aligned} \color{purple}{\log\Pi(2s)-2s\log2} &=\left(2s+\frac12\right)\log2s-2s-2s\log2+\log C+\mathcal O\left(\frac1s\right) \\ &=s\log(s^2)+\frac12\log2+\frac12\log s-2s+\log C+\mathcal O\left(\frac1s\right) \end{aligned}

Combining these results gives

$$\frac12\log\pi=s\log\left(1-{1\over2s}\right)-\log2+\frac12+\log C+\mathcal O\left(\frac1s\right)$$

Finally, if we were to take $$s\to\infty$$, we get $$C=\sqrt{2\pi}$$.