\(\newcommand{L}[1]{\| #1 \|}\newcommand{VL}[1]{\L{ \vec{#1} }}\newcommand{R}[1]{\operatorname{Re}\,(#1)}\newcommand{I}[1]{\operatorname{Im}\, (#1)}\)
Sum of sines and cosines¶
Samuel Greitzer “Many cheerful Facts” Arbelos 4 (1986), no. 5, 14-17.
Michael P. Knapp Sines and cosines of angles in arithmetic progression Mathematics Magazine 82.5 (2009): 371-372.
The proof on this page follows Samuel Greitzner’s “Many cheerful facts”.
Theorems¶
For a positive integer \(N\) and real numbers \(a, d\):
Proof¶
The basic order of play is to rearrange the sum so that the terms in the current iteration of the sum cancel terms in the previous iteration, and we can therefore get rid of the sum. This is a telescoping series.
We will do the cosine series first. The sine proof is almost identical.
Cosine sum¶
For reasons that will become clear later, we start with the case where \(\sin(\frac{1}{2} d) = 0\).
If \(\sin(\frac{1}{2} d) = 0\) then \(d\) is a multiple of \(2 \pi\) and:
and:
Now we cover the case where \(\sin(\frac{1}{2} d) \ne 0\).
From the angle sum rules:
Let:
Only if \(\sin(\frac{1}{2} d) \ne 0\), we can safely multiply both sides by \(2 \sin(\frac{1}{2} d)\):
Now we use the angle sum derivation above. Let \(\alpha = a + nd\), \(\beta = \frac{1}{2} d\):
Writing out the terms in the sum:
The series telescopes, because the second term at each iteration cancels the first term at the previous iteration. We are left only with the first term in the last iteration and the second term from the first:
Now we go the opposite direction with \(\sin(\alpha + \beta) - \sin(\alpha - \beta) = 2\cos \alpha \sin \beta\).
Let \(\alpha + \beta = a + (N - \frac{1}{2}) d\) and \(\alpha - \beta = a - \frac{1}{2} d\). Solving for \(\alpha\) and \(\beta\) we get:
We solve for \(C\) to finish the proof.
\(\blacksquare\)
Sine sum¶
This is almost identical, but applying:
Let:
Only if \(\sin(\frac{1}{2}d) \ne 0\), we can safely multiply both sides by \(-2 \sin(\frac{1}{2}d)\) and continue with the same steps as for the cosine:
Then solve for \(S\).
\(\blacksquare\)
Numerical check¶
We check that the formulae give the right answers from numerical sums.
>>> import numpy as np
>>> def predicted_cos_sum(a, d, N):
... d2 = d / 2.
... if np.allclose(np.sin(d2), 0):
... return N * np.cos(a)
... return np.sin(N * d2) / np.sin(d2) * np.cos(a + (N - 1) * d2)
...
>>> def predicted_sin_sum(a, d, N):
... d2 = d / 2.
... if np.allclose(np.sin(d2), 0):
... return N * np.sin(a)
... return np.sin(N * d2) / np.sin(d2) * np.sin(a + (N - 1) * d2)
...
>>> def actual_cos_sum(a, d, N):
... angles = np.arange(N) * d + a
... return np.sum(np.cos(angles))
...
>>> def actual_sin_sum(a, d, N):
... angles = np.arange(N) * d + a
... return np.sum(np.sin(angles))
When \(\sin(\frac{1}{2}d) \ne 0\):
>>> print('cos',
... predicted_cos_sum(4, 0.2, 17),
... actual_cos_sum(4, 0.2, 17))
cos 7.7038472261 7.7038472261
>>> print('sin',
... predicted_sin_sum(4, 0.2, 17),
... actual_sin_sum(4, 0.2, 17))
sin -6.27049470825 -6.27049470825
When \(\sin(\frac{1}{2}d) \approx 0\):
>>> print('cos : sin(d/2) ~ 0;',
... predicted_cos_sum(4, np.pi * 2, 17),
... actual_cos_sum(4, np.pi * 2, 17))
cos : sin(d/2) ~ 0; -11.1119415547 -11.1119415547
>>> print('sin : sin(d/2) ~ 0;',
... predicted_sin_sum(4, np.pi * 2, 17),
... actual_sin_sum(4, np.pi * 2, 17))
sin : sin(d/2) ~ 0; -12.8656424202 -12.8656424202