I am trying to evaluate sums involving LegendreQ[n,x]
, the n-th order Legendre function of the second kind $Q_n(x)$, at large $x>1$. However, the problem is that every $Q_n(x)$ contains a term proportional to
$$\mathrm{Log}\left(\frac{1 + x}{1 - x}\right)$$
which for $x>1$ and the usual definition of the logarithm adds an imaginary part to the result.
Mathematically speaking, to obtain a result in the Reals, one must use a different branch of the complex logarithm appearing in the Legendre functions so that
$$\mathrm{Log}(z) = \ln(|z|) + i \mathrm{Arg}(z) - i\pi$$
then we have
$$\mathrm{Log}\left(\frac{1 + x}{1 - x}\right) = \ln \left(\frac{1 + x}{|1 - x|}\right) \,, \;x>1$$
and the Legendre functions are now real for $x>1$. What I do in practice, however, is that I observe that the different choice of the branch influences only the imaginary part of any $Q_n(x)$, so I do not attempt to shift the branch of the logarithm and just use Re[LegendreQ[n, x]]
.
But this causes some issues on the numerical level because for $x\to \infty$ and the usual branch of the logarithm
$$\Re(Q_n(x)) \sim x^{-n}$$
$$\Im(Q_n(x)) \sim x^{n}$$
The function Re
then probably takes in a small contribution from the imaginary part at large $x$, and what results is a disaster. This is a plot of Re[LegendreQ[4, x]]
in an interval which is relevant for me:
Do you have any idea how to troubleshoot this?
FullSimplify @ ComplexExpand[Re @ LegendreQ[4,x]]
. $\endgroup$WorkingPrecision
and keepingRe[LegendreQ[n,x]]
works as well, that is the easiest solution. $\endgroup$