Sums of sines and cosines
Introduction
In signal processing applications you will inevitably stumble across a summation of cosines (or sines), where the argument of the cosines form an arithmetic progression. Specifically, let's consider summations of the form:
SN(θ)=N−1∑n=0cos(nθ)
This looks rather intractable a first, but with a couple of tricks involving complex exponentials and some algebra, it is possible to derive a nice closed form expression. We will do precisely that in this post.
Analysis
The key here is to use Euler's formula: ejx=cos(x)+jsin(x)
cos(x)=12(ejx+e−jx)
Let's rewrite SN(θ)
SN(θ)=12N−1∑n=0(ejnθ+e−jnθ)=12N−1∑n=0ejnθ⏟S+N(θ)+12N−1∑n=0e−jnθ⏟S−N(θ)
We have split SN(θ)
S+N(θ)=N−1∑n=0ejnθ
=1−ejNθ1−ejθ
=ejNθ/2(e−jNθ/2−ejNθ/2)ejθ/2(e−jθ/2−ejθ/2)
Invoking Euler's formula again, we can write sin(x)
sin(x)=12j(ejx−e−jx)
Applying this to the expression for S+N(θ)
S+N(θ)=ej(N−1)θ/2sin(Nθ/2)sin(θ/2)
With very similar analysis, we can rewrite S−N(θ)
S−N(θ)=e−j(N−1)θ/2sin(Nθ/2)sin(θ/2)
Now, we can combine the expressions for S+N(θ)
SN(θ)=sin(Nθ/2)sin(θ/2)⋅12(ej(N−1)θ/2+e−j(N−1)θ/2)
Using Euler's formula one more time gives
SN(θ)=sin(Nθ/2)sin(θ/2)cos((N−1)θ2)
Extensions
A slight variant of the above analysis can be used to show that
˜SN(θ)=N−1∑n=0sin(nθ)=sin(Nθ/2)sin(θ/2)sin((N−1)θ2)
The same analysis can also be used to compute the sum N−1∑n=0cos(nθ+ϕ)
Finally, the analysis can be extended to compute the summations N−1∑n=0ncos(nθ)
∂∂θSN(θ)=−N−1∑n=0nsin(nθ)=∂∂θ[sin(Nθ/2)sin(θ/2)cos((N−1)θ2)]
∂∂θ˜SN(θ)=N−1∑n=0ncos(nθ)=∂∂θ[sin(Nθ/2)sin(θ/2)sin((N−1)θ2)]
We are not going to go through the algebra here, but the above approach gives a clear path to the computation of linearly weighted sums of cosines and sines.
Here to share a few nuggets of my math wisdom with the world and to learn from you!