# How to evaluate Sum with Singularities?

I derived equation of sum from the following problem,

$$\int_{a}^{b}\sum_{n=0}^{\infty} cos^n(x)dx$$.

Using the following definitions,

$$cos(x)=\frac{e^{ix}+e^{-ix}}{2}$$ and $$(a+b)^n=\sum_{m=0}^{n}\binom {n}m a^{n-m}b^m$$,

my solution to the above is,

$$\sum_{n=0}^{\infty}\sum_{m=0}^{n} \binom {n}m (-i)\frac{e^{i(n-2m)}}{n-2m}$$.

However, Mathematica cannot evaluate this summation because of singularities. Either my derivation is incorrect although steps are valid or I must add conditionals to this summation evaluation (if it is valid way to do). If my derivation is correct, how do I evaluate this summation,

Sum[Sum[-I*Binomial[n,m]*Exp[I*(n-2*m)/(n-2*m)),{m,0,n}],{n,0,100}]


Is there a way to avoid singularities? Like $$n \neq 2m$$

• Your sum is a geometric series that is convergent for most real xand easily summable. I would compute that and then integrate. Jun 19, 2021 at 7:04
• Sum[Cos[x]^n, {n, 0, \[Infinity]}, Assumptions -> x \[Element] Reals] produces 1/(1 - Cos[x]). If $\cos(x)=\pm1$, the series diverges. Jun 19, 2021 at 7:28

A direct approach to your problem works

sum = Sum[Cos[x]^n, {n, 0, ∞}]
(* 1/(1 - Cos[x]) *)

Integrate[sum, x]
(* -Cot[x/2] *)


Of course, the answer is only valid if the interval doesn't span a singularity (where Cos[x]==1)

• If Cos[x]==-1, the series diverges so such points should be excluded too, when integrating. Jun 19, 2021 at 12:52
• Think of sum = Sum[Cos[x]^n, {n, 0, \[Infinity]}, GenerateConditions -> True] which results in ConditionalExpression[1/(1 - Cos[x]), Abs[Cos[x]] < 1]. Jun 19, 2021 at 12:59