# Numerical evaluation of an infinite sum

I am trying to evaluate numerically : $$G = \frac{-1}{4\pi}\sum_{l=0}^{\infty}\frac{2l+1}{\frac{l(l+1)}{R^2}+\frac{1}{L_d^2}}P_l(\cos(\gamma))$$ Where $P_l$ is the $l_{th}$ Legendre Polynomial, $R = 6371000, Ld = 1000000$ and $\cos(\gamma)\in [-1,1)$. I know that the series converges for any $\cos(\gamma) \neq 1$.

I did a very simple code on fortran90 that calculates the sum, but i really dont know how much terms to sum, is there any tolerance or relative errors i can include in my code?

• Maybe, you can rewrite your series as an integral. Usually, it can be evaluated with some quadrature. Commented Jun 25, 2017 at 22:35
• Using the asymptotics for the Legendre polynomials, $P_\ell(\cos\gamma) = \sqrt{\frac{2}{\pi\ell\sin\gamma}}\cos(\ell \gamma + \gamma/2 - \pi/4) + \mathcal{O}(1/\ell^{3/2})$, we can estimate the error of only summing up to $\ell = \ell_{\rm max}$ to be bounded by $\frac{2\sqrt{2}R^2}{4\pi\sqrt{\pi\sin\gamma}}\frac{2}{\sqrt{\ell_{\rm max}}}$. Commented Jun 25, 2017 at 23:30

Not a complete answer, just some thoughts:

$$\frac{2\ell+1}{\frac{\ell(\ell+1)}{R^2} + \frac1{L_d^2}} \leq \max(R^2,L_d^2) \cdot \ell^{-1}$$

Further, there is the asymptotic formula

$$P_\ell(\cos \gamma) = J_0(\ell\gamma) + \mathcal O(\ell^{-1})$$

where $J_\nu$ denotes the Bessel functions of the first kind. From what I found, the constant in the error term seems to be related to the error term in Stirling's formula for factorials, for which estimates are known. Unfortunately, I cannot provide a good reference for that.

Also, something is known about the error term in the asymptotic form of $J_0$:

$$\biggl|J_0(\ell \gamma) - \sqrt{\frac2{\pi \ell \gamma}}\cos(\ell \gamma-\tfrac14)\biggr| \leq \frac14 \cdot \Bigl(\frac2 \pi\Bigr)^{3/2}\cdot (\ell \gamma)^{-3/2}.$$ This follows from Theorem 10 in https://arxiv.org/pdf/1107.2007.pdf.

It should be possible to get a numerical estimate on the error of the partial sums in your problem by putting these pieces together. I guess it will be some work though. Sorry that I can't provide much more detail. I'm not an expert in approximation theory.

• For OP to verify what he does with this: i believe this should lead to the result that the convergence to the limit is at the rate $\mathcal {O}(l^{-1} )$ Commented Jun 25, 2017 at 21:26
• The terms of the sum in question are in $\mathcal O(\ell^{-3/2})$ and one would probably be able to get bounds on all the constants. This would give numerical control over the difference between the sum and partial sums. Probably that's overkill though. :)
– user296355
Commented Jun 25, 2017 at 22:33
• After the edit, it is true , the terms are of order $l^{-3/2}$. This is how user @Winther got the $l^{-1/2}$ bound on the residual. However, if we also use that the terms have oscillating signs we shoul be able to get the better residual bound $l^{-3/2}$ Commented Jun 26, 2017 at 7:33

$\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\ic}{\mathrm{i}} \newcommand{\mc}[1]{\mathcal{#1}} \newcommand{\mrm}[1]{\mathrm{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

Lets $\ds{r}$ and $\ds{\bar{r}}$ the roots of $\ds{x\pars{x + 1}/R^{2} + 1/L_{d}^{2} = 0}$ for the given values of $\ds{R = 6371000}$ and $\ds{L_{d} = 1000000}$.

Note that $\ds{r = -\,{1 \over 2} + {\root{40339641} \over 1000}\,\ic \approx -\,{1 \over 2} + 6.3514\,\ic}$.

Then, \begin{align} G & \equiv -\,{1 \over 4\pi}\sum_{\ell = 0}^{\infty}{2\ell + 1 \over \ell\pars{\ell + 1}/R^{2} + 1/L_{d}^{2}}\,\mrm{P}_{\ell}\pars{\cos\pars{\gamma}} = -\,{1 \over 4\pi}\sum_{\ell = 0}^{\infty}{2\ell + 1 \over \pars{\ell - r}\pars{\ell - \bar{r}}}\,\mrm{P}_{\ell}\pars{\cos\pars{\gamma}} \\[5mm] & = -\,{1 \over 4\pi}\sum_{\ell = 0}^{\infty}\pars{% {2\ell + 1 \over \ell - r} + {2\ell + 1 \over \ell -\bar{r}}} {1 \over r - \bar{r}}\,\mrm{P}_{\ell}\pars{\cos\pars{\gamma}} \\[5mm] & = -\,{1 \over 4\pi\,\Im\pars{r}}\,\Im\sum_{\ell = 0}^{\infty} {2\ell + 1 \over \ell - r}\,\mrm{P}_{\ell}\pars{\cos\pars{\gamma}} = -\,{1 \over 4\pi\,\Im\pars{r}}\,\Im\bracks{\pars{2r + 1}% \sum_{\ell = 0}^{\infty}{\mrm{P}_{\ell}\pars{\cos\pars{\gamma}} \over \ell - r}} \\[5mm] & = -\,{1 \over 4\pi\,\Im\pars{r}}\,\Im\bracks{\pars{2r + 1}% \sum_{\ell = 0}^{\infty}\mrm{P}_{\ell}\pars{\cos\pars{\gamma}} \int_{0}^{1}x^{\ell - r - 1}\,\dd x} \\[5mm] & = -\,{1 \over 4\pi\,\Im\pars{r}}\,\Im\bracks{\pars{2r + 1}% \int_{0}^{1}x^{-r - 1} \sum_{\ell = 0}^{\infty}\mrm{P}_{\ell}\pars{\cos\pars{\gamma}}x^{\ell}\,\dd x} \\[5mm] & = -\,{1 \over 4\pi\,\Im\pars{r}}\,\Im\bracks{\pars{2r + 1}\int_{0}^{1}{x^{-r - 1} \over \root{1 - 2x\cos\pars{\gamma} + x^{2}}}\,\dd x} \end{align}

It turns out that $\ds{\Re\pars{r} = -1/2}$ such that

\begin{align} G & \equiv -\,{1 \over 4\pi}\sum_{\ell = 0}^{\infty}{2\ell + 1 \over \ell\pars{\ell + 1}/R^{2} + 1/L_{d}^{2}}\,\mrm{P}_{\ell}\pars{\cos\pars{\gamma}} = -\,{1 \over 2\pi}\,\Re\bracks{\int_{0}^{1}{x^{-1/2 - \Im\pars{r}\,\ic} \over \root{1 - 2x\cos\pars{\gamma} + x^{2}}}\,\dd x} \\[5mm] & = -\,{1 \over 2\pi}\,\int_{0}^{1}{\cos\pars{\Im\pars{r}\ln\pars{x}} \over \root{1 - 2x\cos\pars{\gamma} + x^{2}}}\,{\dd x \over \root{x}} = \bbx{-\,{1 \over \pi}\,\int_{0}^{1}{\cos\pars{2\,\Im\pars{r}\ln\pars{x}} \over \root{1 - 2x^{2}\cos\pars{\gamma} + x^{4}}}\,\dd x} \end{align}

Now, you can try some quadrature !!!.

Moreover, \begin{align} G & \equiv -\,{1 \over 4\pi}\sum_{\ell = 0}^{\infty}{2\ell + 1 \over \ell\pars{\ell + 1}/R^{2} + 1/L_{d}^{2}}\,\mrm{P}_{\ell}\pars{\cos\pars{\gamma}} \\[5mm] & = {1 \over \pi}\int_{0}^{1}\mrm{f}\pars{x,\gamma}\,\dd x - {1 \over \pi}\,\ \underbrace{% \int_{0}^{1}\cos\pars{2\,\Im\pars{r}\ln\pars{x}}\,\dd x} _{\ds{1 \over 1 + 4\bracks{\Im\pars{r}}^{2}}} \\[5mm] & \mbox{where}\quad \mrm{f}\pars{x,\gamma} = \left\{\begin{array}{ll} \ds{\cos\pars{2\,\Im\pars{r}\ln\pars{x}}\bracks{% 1 - {1 \over \root{1 - 2x^{2}\cos\pars{\gamma} + x^{4}}}}\,,} & \ds{0 < x \leq 1} \\[2mm] \ds{0\,,} & \mbox{otherwise} \end{array}\right. \end{align}

The following picture depicts $\ds{G}$ as a function of $\ds{\gamma \in \pars{-4\pi,4\pi}}$. The integration was performed with a $\ds{20}$-Points Trapezoidal Rule (TR). There isn't a 'visible' improvement when we increase the number of points. Even with a $\ds{10}$-points TR the picture is very similar. I hope I didn't do any mistake !!!.

• how did you got the third equality from the second ???( At the beginning ) Commented Jun 26, 2017 at 15:10