CP 2.8 - Sums of series with de Moivre

CP 2.8 - Sums of series with de Moivre

Sum trigonometric series by treating their cosine and sine terms as the real and imaginary parts of one complex geometric progression. You will derive finite-sum formulae, prove a useful half-circle identity and handle geometric weights as well as unit-length terms.

Summing a complex geometric progression

Can you find

1+cos⁡π20+cos⁡2π20+⋯+cos⁡19π201+\cos\frac{\pi}{20}+\cos\frac{2\pi}{20}+\cdots+\cos\frac{19\pi}{20}

without calculating nineteen cosines? Its exact value is 11. There is also a compact exact expression for the matching sine sum. A single complex series will produce both answers.

You already know

From A-level Mathematics, a geometric progression has a constant ratio. De Moivre gives qk=cos⁡kθ+isin⁡kθq^k=\cos k\theta+\mathrm{i}\sin k\theta when q=cos⁡θ+isin⁡θq=\cos\theta+\mathrm{i}\sin\theta. Thus the real and imaginary parts of 1+q+⋯+qn−11+q+\cdots+q^{n-1} are the corresponding cosine and sine sums.

For example, let q=cos⁡π3+isin⁡π3q=\cos\frac{\pi}{3}+\mathrm{i}\sin\frac{\pi}{3}. The terms 1,q,q2,…1,q,q^2,\ldots are unit arrows whose directions turn by π3\frac{\pi}{3} each time. Adding them means placing the arrows head to tail. Six close the chain, while four finish on the imaginary axis.

[DIAGRAM: asset_name: A complex geometric sum as a chain of arrows; asset_slug: 9fm0-cp11-geometric-chain; caption: Six unit terms close the chain and four have sum i root 3; description: Six successive unit arrows, directed at zero, pi over 3, two pi over 3, pi, four pi over 3 and five pi over 3, form a closed hexagonal chain. The first four are blue and the last two sage. The endpoint after four terms is marked i root 3. A side panel gives q equals cosine pi over 3 plus i sine pi over 3 and explains that the six-term sum is zero.]
Six unit terms close the chain and four have sum i root 3

The familiar finite geometric-series formula works for a complex ratio because its proof uses only multiplication and subtraction. Write Tn=1+q+⋯+qn−1T_n=1+q+\cdots+q^{n-1}; then qTn=q+q2+⋯+qnqT_n=q+q^2+\cdots+q^n. Subtraction gives (1−q)Tn=1−qn(1-q)T_n=1-q^n.

Finite geometric series

For a positive integer nn and complex q≠1q\ne1,

Tn=1+q+q2+⋯+qn−1=1−qn1−qT_n=1+q+q^2+\cdots+q^{n-1}=\frac{1-q^n}{1-q}

For q=1q=1, add the nn terms directly to obtain Tn=nT_n=n. The finite-sum formula has no restriction ∣q∣<1|q|<1.

In the formula booklet.

Count the terms carefully: the last exponent is n−1n-1, but the numerator contains qnq^n. The first example uses four terms, so it needs the fourth power in the numerator.

Worked example 1: four unit terms

Question. For q=cos⁡π3+isin⁡π3q=\cos\frac{\pi}{3}+\mathrm{i}\sin\frac{\pi}{3}, find 1+q+q2+q31+q+q^2+q^3 in Cartesian form.

Plan. Apply the finite GP formula, evaluate q4q^4 using de Moivre and rationalise the denominator.

q=12+i32exact valuesq4=cos⁡4π3+isin⁡4π3=−12−i32de MoivreT4=1−q41−q=32+i3212−i32four-term GP=(32+i32)(12+i32)14+34multiply by conjugate=i3real terms cancel\begin{aligned} q&=\frac12+\frac{\mathrm{i}\sqrt{3}}2 && \text{exact values} \\ q^4&=\cos\frac{4\pi}{3}+\mathrm{i}\sin\frac{4\pi}{3} =-\frac12-\frac{\mathrm{i}\sqrt{3}}2 && \text{de Moivre} \\ T_4&=\frac{1-q^4}{1-q} =\frac{\frac32+\frac{\mathrm{i}\sqrt{3}}2}{\frac12-\frac{\mathrm{i}\sqrt{3}}2} && \text{four-term GP} \\ &=\frac{(\frac32+\frac{\mathrm{i}\sqrt{3}}2)(\frac12+\frac{\mathrm{i}\sqrt{3}}2)}{\frac14+\frac34} && \text{multiply by conjugate} \\ &=\mathrm{i}\sqrt{3} && \text{real terms cancel} \end{aligned}

Why this step? The complex denominator is turned into the real number 11, so the real and imaginary sums can be read directly.

Answer. 1+q+q2+q3=i31+q+q^2+q^3=\mathrm{i}\sqrt{3}.

Check. The real parts add to 1+12−12−1=01+\frac12-\frac12-1=0; the imaginary parts add to 0+32+32+0=30+\frac{\sqrt{3}}2+\frac{\sqrt{3}}2+0=\sqrt{3}, agreeing with the diagram.

Change only the number of terms from four to five. The new final term changes both components of the sum.

Worked example 2: five unit terms

Question. For the same qq, find 1+q+q2+q3+q41+q+q^2+q^3+q^4 in Cartesian form.

Plan. Use T5=(1−q5)/(1−q)T_5=(1-q^5)/(1-q) and simplify with the conjugate.

q5=cos⁡5π3+isin⁡5π3=12−i32de MoivreT5=12+i3212−i32five-term GP=(12+i32)214+34multiply by conjugate=14−34+i32expand the square\begin{aligned} q^5&=\cos\frac{5\pi}{3}+\mathrm{i}\sin\frac{5\pi}{3} =\frac12-\frac{\mathrm{i}\sqrt{3}}2 && \text{de Moivre} \\ T_5&=\frac{\frac12+\frac{\mathrm{i}\sqrt{3}}2}{\frac12-\frac{\mathrm{i}\sqrt{3}}2} && \text{five-term GP} \\ &=\frac{(\frac12+\frac{\mathrm{i}\sqrt{3}}2)^2}{\frac14+\frac34} && \text{multiply by conjugate} \\ &=\frac14-\frac34+\frac{\mathrm{i}\sqrt{3}}2 && \text{expand the square} \end{aligned}

Why this step? The conjugate of the denominator happens to equal the numerator, so the numerator becomes a square; it must still be expanded correctly.

Answer. T5=−12+i32T_5=-\frac12+\frac{\mathrm{i}\sqrt{3}}2.

Check. Adding q4=−12−i32q^4=-\frac12-\frac{\mathrm{i}\sqrt{3}}2 to T4=i3T_4=\mathrm{i}\sqrt{3} gives exactly this answer.

The denominator condition is essential; the convergence condition for an infinite GP is a different matter.

Watch out

Wrong: “∣q∣=1|q|=1, so the geometric-series formula cannot be used.” The finite formula needs only q≠1q\ne1. The condition ∣q∣<1|q|<1 belongs to a sum to infinity, not to a finite sum.

One more term closes the chain in this example.

Extracting cosine and sine sums

The real part of a complex sum is the sum of its real parts, and the imaginary part is the sum of its imaginary parts. Keeping them together lets one geometric progression do two jobs.

For q=cos⁡θ+isin⁡θq=\cos\theta+\mathrm{i}\sin\theta, define

Cn=∑k=0n−1cos⁡kθSn=∑k=0n−1sin⁡kθC_n=\sum_{k=0}^{n-1}\cos k\theta \qquad S_n=\sum_{k=0}^{n-1}\sin k\theta

Then Cn+iSn=(1−qn)/(1−q)C_n+\mathrm{i}S_n=(1-q^n)/(1-q). The first sine term is zero; the first cosine term is 11.

To put that quotient into a useful form, write u(ϕ)=cos⁡ϕ+isin⁡ϕu(\phi)=\cos\phi+\mathrm{i}\sin\phi. For any real ϕ\phi, the double-angle identities give

−2isin⁡ϕ u(ϕ)=2sin⁡2ϕ−2isin⁡ϕcos⁡ϕ=1−cos⁡2ϕ−isin⁡2ϕ=1−u(2ϕ)\begin{aligned} -2\mathrm{i}\sin\phi\,u(\phi) &=2\sin^2\phi-2\mathrm{i}\sin\phi\cos\phi \\ &=1-\cos2\phi-\mathrm{i}\sin2\phi \\ &=1-u(2\phi) \end{aligned}

Apply this with ϕ=nθ/2\phi=n\theta/2 in the numerator and ϕ=θ/2\phi=\theta/2 in the denominator. The common factor −2i-2\mathrm{i} cancels, while dividing the two unit complex numbers subtracts their angles:

1−qn1−q=sin⁡(nθ/2)sin⁡(θ/2)(cos⁡(n−1)θ2+isin⁡(n−1)θ2)\frac{1-q^n}{1-q} =\frac{\sin(n\theta/2)}{\sin(\theta/2)} \left(\cos\frac{(n-1)\theta}{2}+\mathrm{i}\sin\frac{(n-1)\theta}{2}\right)

The derivation is still valid when sin⁡(nθ/2)=0\sin(n\theta/2)=0: we never divided by that numerator factor.

Finite cosine and sine sums

For positive integer nn and real θ\theta with sin⁡(θ/2)≠0\sin(\theta/2)\ne0,

Cn=sin⁡(nθ/2)cos⁡((n−1)θ/2)sin⁡(θ/2)C_n=\frac{\sin(n\theta/2)\cos((n-1)\theta/2)}{\sin(\theta/2)} Sn=sin⁡(nθ/2)sin⁡((n−1)θ/2)sin⁡(θ/2)S_n=\frac{\sin(n\theta/2)\sin((n-1)\theta/2)}{\sin(\theta/2)}

If θ\theta is an integer multiple of 2π2\pi, use Cn=nC_n=n and Sn=0S_n=0 directly. You may derive these sums from the finite GP instead of memorising them.

Not in the formula booklet: learn it.

The angles in the factors have different jobs: nθ/2n\theta/2 comes from the numerator, whereas (n−1)θ/2(n-1)\theta/2 is the middle direction of the terms being added.

Worked example 3: five equally spaced angles

Question. Find the exact values of ∑k=04cos⁡kπ6\sum_{k=0}^{4}\cos\frac{k\pi}{6} and ∑k=04sin⁡kπ6\sum_{k=0}^{4}\sin\frac{k\pi}{6}.

Plan. Use n=5n=5, θ=π6\theta=\frac{\pi}{6} in the two finite-sum formulae.

sin⁡(5π/12)sin⁡(π/12)=6+26−2exact angle values=2+3rationalise\begin{aligned} \frac{\sin(5\pi/12)}{\sin(\pi/12)} &=\frac{\sqrt{6}+\sqrt{2}}{\sqrt{6}-\sqrt{2}} && \text{exact angle values} \\ &=2+\sqrt{3} && \text{rationalise} \end{aligned}

Therefore

C5=(2+3)cos⁡π3=1+32real partS5=(2+3)sin⁡π3=32+3imaginary part\begin{aligned} C_5&=(2+\sqrt{3})\cos\frac{\pi}{3} =1+\frac{\sqrt{3}}2 && \text{real part} \\ S_5&=(2+\sqrt{3})\sin\frac{\pi}{3} =\frac32+\sqrt{3} && \text{imaginary part} \end{aligned}

Why this step? Five terms run from angle 00 to 4θ4\theta, so their middle direction is 2θ=π32\theta=\frac{\pi}{3}, not 5π12\frac{5\pi}{12}.

Answer. The cosine sum is 1+321+\frac{\sqrt{3}}2, and the sine sum is 32+3\frac32+\sqrt{3}.

Check. Directly, the cosine terms are 1,32,12,0,−121,\frac{\sqrt{3}}2,\frac12,0,-\frac12, and the sine terms are 0,12,32,1,320,\frac12,\frac{\sqrt{3}}2,1,\frac{\sqrt{3}}2.

Change only the number of terms from five to six, keeping the angular step π6\frac{\pi}{6}.

Worked example 4: six equally spaced angles

Question. Find the exact values of ∑k=05cos⁡kπ6\sum_{k=0}^{5}\cos\frac{k\pi}{6} and ∑k=05sin⁡kπ6\sum_{k=0}^{5}\sin\frac{k\pi}{6}.

Plan. Use n=6n=6 and the same θ\theta, then simplify the real and imaginary parts.

Since 1/sin⁡π12=6+21/\sin\frac{\pi}{12}=\sqrt{6}+\sqrt{2},

C6=sin⁡(π/2)cos⁡(5π/12)sin⁡(π/12)cosine-sum formula=(6+2)6−24=1difference of squaresS6=sin⁡(π/2)sin⁡(5π/12)sin⁡(π/12)sine-sum formula=(6+2)24=2+3expand the square\begin{aligned} C_6&=\frac{\sin(\pi/2)\cos(5\pi/12)}{\sin(\pi/12)} && \text{cosine-sum formula} \\ &=(\sqrt{6}+\sqrt{2})\frac{\sqrt{6}-\sqrt{2}}4=1 && \text{difference of squares} \\ S_6&=\frac{\sin(\pi/2)\sin(5\pi/12)}{\sin(\pi/12)} && \text{sine-sum formula} \\ &=\frac{(\sqrt{6}+\sqrt{2})^2}{4}=2+\sqrt{3} && \text{expand the square} \end{aligned}

Why this step? Increasing the number of terms changes both nθ/2n\theta/2 and (n−1)θ/2(n-1)\theta/2; retaining the old middle direction would mix two different series.

Answer. The cosine sum is 11, and the sine sum is 2+32+\sqrt{3}.

Check. The added term has cosine −32-\frac{\sqrt{3}}2 and sine 12\frac12, taking the previous two answers to these values.

If a series begins at k=1k=1, remove the initial cosine term 11 from the matching k=0k=0 sum. Removing the initial sine term changes nothing.

Watch out

Wrong: ∑k=0n−1cos⁡kθ=Re⁡(q+q2+⋯+qn)\sum_{k=0}^{n-1}\cos k\theta=\operatorname{Re}(q+q^2+\cdots+q^n). The indices have shifted. Right: use 1+q+⋯+qn−11+q+\cdots+q^{n-1}; the first term and the number of terms must match the question.

One more term changes the cosine sum but leaves the sine sum unchanged.

The half-circle series identity

A useful special case takes q=cos⁡πn+isin⁡πnq=\cos\frac{\pi}{n}+\mathrm{i}\sin\frac{\pi}{n}. Raising it to the power nn gives −1-1, so the numerator of the finite GP becomes the real number 22.

The following identity is not printed in the formula booklet. Deriving it from the GP also proves the cosine and sine sums together.

Worked example 5: the half-circle identity

Question. Show that, for every positive integer nn,

1+q+q2+⋯+qn−1=1+icot⁡π2n1+q+q^2+\cdots+q^{n-1}=1+\mathrm{i}\cot\frac{\pi}{2n}

where q=cos⁡πn+isin⁡πnq=\cos\frac{\pi}{n}+\mathrm{i}\sin\frac{\pi}{n}.

Plan. Use qn=−1q^n=-1, rationalise 2/(1−q)2/(1-q) and apply the half-angle identities.

Put α=πn\alpha=\frac{\pi}{n}. Then

qn=cos⁡π+isin⁡π=−1de MoivreTn=21−cos⁡α−isin⁡αfinite GP, q≠1=2(1−cos⁡α+isin⁡α)(1−cos⁡α)2+sin⁡2αmultiply by conjugate=1−cos⁡α+isin⁡α1−cos⁡αdenominator 2(1−cos⁡α)=1+isin⁡α1−cos⁡αsplit the components=1+i2sin⁡(α/2)cos⁡(α/2)2sin⁡2(α/2)half-angle identities=1+icot⁡α2cancel a non-zero sine\begin{aligned} q^n&=\cos\pi+\mathrm{i}\sin\pi=-1 && \text{de Moivre} \\ T_n&=\frac{2}{1-\cos\alpha-\mathrm{i}\sin\alpha} && \text{finite GP, }q\ne1 \\ &=\frac{2(1-\cos\alpha+\mathrm{i}\sin\alpha)}{(1-\cos\alpha)^2+\sin^2\alpha} && \text{multiply by conjugate} \\ &=\frac{1-\cos\alpha+\mathrm{i}\sin\alpha}{1-\cos\alpha} && \text{denominator }2(1-\cos\alpha) \\ &=1+\mathrm{i}\frac{\sin\alpha}{1-\cos\alpha} && \text{split the components} \\ &=1+\mathrm{i}\frac{2\sin(\alpha/2)\cos(\alpha/2)}{2\sin^2(\alpha/2)} && \text{half-angle identities} \\ &=1+\mathrm{i}\cot\frac{\alpha}{2} && \text{cancel a non-zero sine} \end{aligned}

Why this step? 0<α≤π0<\alpha\le\pi, so sin⁡(α/2)≠0\sin(\alpha/2)\ne0. The cancellation and the GP denominator are both justified, including when n=1n=1.

Answer. Tn=1+icot⁡π2nT_n=1+\mathrm{i}\cot\frac{\pi}{2n}, as required.

Check. At n=2n=2, q=iq=\mathrm{i} and the sum is 1+i=1+icot⁡π41+\mathrm{i}=1+\mathrm{i}\cot\frac{\pi}{4}. At n=1n=1, the sum is 11 and cot⁡π2=0\cot\frac{\pi}{2}=0.

Change only the angular step, from πn\frac{\pi}{n} to 3πn\frac{3\pi}{n}. Raising the ratio to the power nn still gives −1-1, so nearly all the algebra survives.

Worked example 6: three times the angular step

Question. For positive integer nn, let w=cos⁡3πn+isin⁡3πnw=\cos\frac{3\pi}{n}+\mathrm{i}\sin\frac{3\pi}{n}. Find 1+w+⋯+wn−11+w+\cdots+w^{n-1} in terms of a cotangent.

Plan. Use the odd half-turn in wnw^n, then rationalise exactly as before.

Write β=3πn\beta=\frac{3\pi}{n}. Since wn=cos⁡3π+isin⁡3π=−1w^n=\cos3\pi+\mathrm{i}\sin3\pi=-1,

1+w+⋯+wn−1=21−cos⁡β−isin⁡βfinite GP=1+isin⁡β1−cos⁡βrationalise=1+icot⁡β2half-angle identities\begin{aligned} 1+w+\cdots+w^{n-1} &=\frac{2}{1-\cos\beta-\mathrm{i}\sin\beta} && \text{finite GP} \\ &=1+\mathrm{i}\frac{\sin\beta}{1-\cos\beta} && \text{rationalise} \\ &=1+\mathrm{i}\cot\frac{\beta}{2} && \text{half-angle identities} \end{aligned}

Why this step? A ratio equal to 11 would have wn=1w^n=1, contradicting wn=−1w^n=-1. Thus the denominator cannot vanish, even when β\beta is outside the principal-argument range.

Answer. 1+w+⋯+wn−1=1+icot⁡3π2n\displaystyle 1+w+\cdots+w^{n-1}=1+\mathrm{i}\cot\frac{3\pi}{2n}.

Check. At n=3n=3, w=−1w=-1, so the sum is 1−1+1=11-1+1=1; the formula gives 1+icot⁡π2=11+\mathrm{i}\cot\frac{\pi}{2}=1.

The opening puzzle is now solved. Taking real and imaginary parts of Worked example 5 gives

∑k=0n−1cos⁡kπn=1∑k=0n−1sin⁡kπn=cot⁡π2n\sum_{k=0}^{n-1}\cos\frac{k\pi}{n}=1 \qquad \sum_{k=0}^{n-1}\sin\frac{k\pi}{n}=\cot\frac{\pi}{2n}

These specialised sums are not printed in the formula booklet. At n=20n=20, the cosine sum is exactly 11, and the sine sum is cot⁡π40\cot\frac{\pi}{40}. The cosine terms other than the initial 11 cancel in pairs, because cos⁡(π−ϕ)=−cos⁡ϕ\cos(\pi-\phi)=-\cos\phi; the complex method discovers the less obvious sine sum at the same time.

Watch out

Wrong: qn=cos⁡π+isin⁡π=1q^n=\cos\pi+\mathrm{i}\sin\pi=1. Right: it is −1-1. A half-turn gives the numerator 1−(−1)=21-(-1)=2; a full turn gives numerator 00.

An odd multiple of the same angular step leads to the same pattern, with a changed cotangent argument.

Geometrically weighted trigonometric sums

A geometric weight changes the modulus of the complex ratio. For a real r>0r>0, put q=r(cos⁡θ+isin⁡θ)q=r(\cos\theta+\mathrm{i}\sin\theta). De Moivre gives qk=rk(cos⁡kθ+isin⁡kθ)q^k=r^k(\cos k\theta+\mathrm{i}\sin k\theta), so the same finite GP method sums weighted cosine and sine terms.

Weighted finite sums

For positive integer nn, real r>0r>0, real θ\theta and q=r(cos⁡θ+isin⁡θ)≠1q=r(\cos\theta+\mathrm{i}\sin\theta)\ne1,

∑k=0n−1rkcos⁡kθ+i∑k=0n−1rksin⁡kθ=1−qn1−q\sum_{k=0}^{n-1}r^k\cos k\theta +\mathrm{i}\sum_{k=0}^{n-1}r^k\sin k\theta =\frac{1-q^n}{1-q}

This application of the geometric-sum formula is not printed separately.

Not in the formula booklet: learn it.

Do not use q+q−1=2cos⁡θq+q^{-1}=2\cos\theta here unless r=1r=1. The GP formula itself works with either unit or non-unit modulus.

Worked example 7: four weighted terms

Question. Find

A=∑k=03cos⁡(kπ/2)2kB=∑k=03sin⁡(kπ/2)2kA=\sum_{k=0}^{3}\frac{\cos(k\pi/2)}{2^k} \qquad B=\sum_{k=0}^{3}\frac{\sin(k\pi/2)}{2^k}

Plan. Combine the sums using q=12(cos⁡π2+isin⁡π2)=i2q=\frac12(\cos\frac{\pi}{2}+\mathrm{i}\sin\frac{\pi}{2})=\frac{\mathrm{i}}2.

A+iB=1−(i/2)41−i/2four-term GP=15/161−i/2(i/2)4=1/16=15161+i/21+1/4multiply by conjugate=34+3i8simplify\begin{aligned} A+\mathrm{i}B &=\frac{1-(\mathrm{i}/2)^4}{1-\mathrm{i}/2} && \text{four-term GP} \\ &=\frac{15/16}{1-\mathrm{i}/2} && (\mathrm{i}/2)^4=1/16 \\ &=\frac{15}{16}\frac{1+\mathrm{i}/2}{1+1/4} && \text{multiply by conjugate} \\ &=\frac34+\frac{3\mathrm{i}}8 && \text{simplify} \end{aligned}

Why this step? The factor 12\frac12 belongs in the complex ratio, so it generates exactly the weights 1,12,14,181,\frac12,\frac14,\frac18.

Answer. A=34A=\frac34, B=38B=\frac38.

Check. Directly, A=1−14=34A=1-\frac14=\frac34, and B=12−18=38B=\frac12-\frac18=\frac38.

Change only the number of terms from four to five. The new term has a real component and no imaginary component.

Worked example 8: five weighted terms

Question. Find A=∑k=04cos⁡(kπ/2)2k\displaystyle A=\sum_{k=0}^{4}\frac{\cos(k\pi/2)}{2^k} and B=∑k=04sin⁡(kπ/2)2k\displaystyle B=\sum_{k=0}^{4}\frac{\sin(k\pi/2)}{2^k}.

Plan. Use q=i2q=\frac{\mathrm{i}}2 again, with five terms in the finite GP.

A+iB=1−(i/2)51−i/2five-term GP=1−i/321−i/2(i/2)5=i/32=(1−i/32)(1+i/2)5/4multiply by conjugate=65/64+15i/325/4i2=−1=1316+3i8divide both components\begin{aligned} A+\mathrm{i}B &=\frac{1-(\mathrm{i}/2)^5}{1-\mathrm{i}/2} && \text{five-term GP} \\ &=\frac{1-\mathrm{i}/32}{1-\mathrm{i}/2} && (\mathrm{i}/2)^5=\mathrm{i}/32 \\ &=\frac{(1-\mathrm{i}/32)(1+\mathrm{i}/2)}{5/4} && \text{multiply by conjugate} \\ &=\frac{65/64+15\mathrm{i}/32}{5/4} && \mathrm{i}^2=-1 \\ &=\frac{13}{16}+\frac{3\mathrm{i}}8 && \text{divide both components} \end{aligned}

Why this step? The imaginary part of the numerator is 12−132=1532\frac12-\frac1{32}=\frac{15}{32}, while the product of the two imaginary terms adds 164\frac1{64} to the real part.

Answer. A=1316A=\frac{13}{16}, B=38B=\frac38.

Check. The added term is q4=116q^4=\frac1{16}, so only the real part increases, from 34\frac34 to 1316\frac{13}{16}.

When the terms have weights, keep those weights in every complex power. Using only a unit complex ratio would sum a different series.

Watch out

Wrong: using q=iq=\mathrm{i} for weights 2−k2^{-k}. Right: q=i2q=\frac{\mathrm{i}}2. Its modulus controls the weights, and its argument controls the trigonometric angles.

One further term now changes the imaginary sum.

Quick Recap

  • Combine cosine and sine sums into powers of one complex ratio.
  • Count the terms: 1+q+⋯+qn−11+q+\cdots+q^{n-1} has nn terms and numerator 1−qn1-q^n.
  • Use de Moivre for qnq^n, then simplify the quotient before extracting real and imaginary parts.
  • The half-circle sum is 1+icot⁡π2n1+\mathrm{i}\cot\frac{\pi}{2n}; its real part is always 11.
  • A ratio with modulus rr produces geometric weights rkr^k.

The opening twenty-term cosine sum is exactly 11, and its sine partner is cot⁡π40\cot\frac{\pi}{40}.