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,


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

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

1 Answer 1


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)

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.