I am trying to find a closed form expression for the following sum, $$ F(x,t)= \frac{1}{\log\left(\frac{1+x}{2}\right)}\sum_{n=1}^\infty \frac{P_n(x) - P_{n-1}(x)}{ n } \cos(nt) ~, $$ where $P_n(x)$ are Legendre polynomials. When I truncate the sum at $n=200$ and plot $1+F(x,t)$, for $x$ from -.8 to +.8 in steps of .2, I get the following result, where the function becomes more narrow for larger values of $x$:
My idea for evaluating the full sum was to use the well-known generating function of the Legendre polynomials, $\sum_{n=0}^\infty P_n(x) t^n = \frac{1}{\sqrt{1-2xt+t^2}}$, but as far as I understand this is only well-defined for $|t|<1$. I then tried to use the following identity, $$\sum_{n=1}^\infty P_n(x) \sin (n t) = -\frac{i e^{-i t} \left(e^{2 i t} \sqrt{-2 e^{-i t} x+e^{-2 i t}+1}-\sqrt{-2 e^{i t} x+e^{2 i t}+1}\right)}{2 \sqrt{(-2 e^{-i t} x+e^{-2 i t}+1)(-2 e^{i t} x+e^{2 i t}+1})}~. $$ This can be integrated to find $-\sum_{n=1}^\infty \frac{P_n(x)}{n} \cos (n t)$, and in a similar manner we can find $\sum_{n=1}^\infty \frac{P_{n-1}(x)}{n} \cos (n t)$. The final result that I get is
$$G(x,t)= \frac{1}{\log(\left(\frac{1+x}{2}\right)} \left[\frac{1}{2} \left(-\log \left(-e^{i t} x+\sqrt{(\cos (t)-x) (2 \cos (t)+2 i \sin (t))}+1\right)+ \\ -\log \left(1+e^{i t} \left(-x+\sqrt{(\cos (t)-x) (2 \cos (t)-2 i \sin (t))}\right)\right)+ \\ +\left(-1-\frac{e^{i t} \sqrt{e^{-i t} (\cos (t)-x)}}{\sqrt{e^{i t} (\cos (t)-x)}}\right) \log\left(\sqrt{(\cos (t)-x) (2 \cos (t)+2 i \sin (t))}+e^{i t}-x\right)+2 i t\right) \right] $$ However, when I plot $1+G(x,t)$ for $x$ from -.8 to +.8 in steps of .2 to compare with the truncated sum given above, I get the following:
This clearly shows that $G(x,t) \neq F(x,t)$. I am not sure what is going wrong here. I only care about finding the closed form expression and do not insist in any way on using the methods I outlined here. Any help is much appreciated.


For $x\in\mathbb{R}$ and $z\in\mathbb{C}$ with $|x|<1$ and $|z|<1$, the function $$G(x,z):=\sum_{n=1}^\infty\big(P_n(x)-P_{n-1}(x)\big)\frac{z^n}{n},$$ evaluated using the generating function of Legendre polynomials, equals $$G(x,z)=\log 2-\log\left(1+z+z^2-xz+(1+z)\sqrt{1-2xz+z^2}\right),$$ with the principal values (of the square root and the logarithm) taken. In fact (using Abel's theorem), this holds for $|x|\leqslant 1$ and $|z|\leqslant 1$, provided that $x$ and $z$ aren't both equal to $-1$. It remains to put $z=e^{it}$ and take the real part. This is somewhat tedious, but the final result is $$\sum_{n=1}^\infty\big(P_n(x)-P_{n-1}(x)\big)\frac{\cos nt}{n}=\log 2-\log S(x,\cos t),\\S(x,y):=\begin{cases}\hfill 1+x,\hfill&x\geqslant y\\\left(\sqrt{1+y}+\sqrt{y-x}\right)^2,&x<y\end{cases}.$$
(I didn't check your results; perhaps there are branching issues.)