# Averaging the values of $\cos x$ over one period

I'm calculating the average value of $\cos x$ by dividing the period $[0,2\pi]$ into ten intervals which means that I should be looking for the average of 11 results. What I get is approx. 0.09. The expected result 0 is only obtained if I average over the values of the first 10 points. However, 10 points do not span the whole period $[0, 2\pi]$. What are your thoughts on this apparent problem?

-

Imagine another sensible way of calculating the average.

Divide into $10$ intervals, find the midpoint of each. Calculate the function value at these midpoints, add up, divide by $(10)(2\pi)$. This natural calculation uses $10$ points.

Using both $f(0)$ and $f(2\pi)$ is a useful idea, if modified slightly, by counting $f(0)$ and $f(2\pi)$ each with half-weight. So use $$\frac{1}{2\pi}\left(\frac{\frac{1}{2}f(0)+f(2\pi/10)+\cdots+f(18\pi/10)+\frac{1}{2}f(2\pi)}{10}\right).$$ This is essentially the useful Trapezoidal Rule.

-

The problem in your computation of the average value of $\cos(x)$ over one period represented by the closed interval $[0, 2\pi]$ you include $\cos 0 = \cos(2\pi) = 1$ twice...so you get an average greater than $0$.

One period would be defined by $[0, 2\pi)$. (Think of the unit circle: without excluding one of the interval's endpoints, once you transverse the circle from $0$ to $2\pi$, you land back at the starting point, so you're "double counting" the value of $\cos(0) = \cos(2\pi) =1$.

I'm simply explaining why you are getting a positive result.

Put differently we can take the union of the periods of $\cos(x) \text{ for}\;\;x \ge 0 =[0, \infty)$: $$= [0, 2\pi) \cup [2\pi, 4\pi) \cup \cdots \cup [2n\pi, 2(n+1)\pi) \cup \cdots$$ $$= \bigcup_{n=0}^\infty[2n\pi, 2(n+1)\pi)$$

If we want to consider a distinct/disjoint period, we need a half-open interval, for otherwise any given period would "overlap" with another period: they would not be disjoint.

If you want to use the interval $[0, 2\pi]$ to represent the period of $\cos(x)$, then your first and last values of the 11 you selected would need to be weighted: multiplying each by 1/2. Then your sum will equivalent to the sum you get for using, say, 10 midpoints of intervals.

-
It should be included twice because it belongs to the interval $[0,2\pi]$ (not $[0,2\pi)$), doesn't it? – ganzewoort Dec 13 '12 at 16:39

If we take $2n$ intervals,

$$\sum_{0\le r\le 2n}\cos\frac{2\pi r}{2n}=\cos0+\sum_{1\le r\le n}\cos\frac{2\pi r}{2n}+\sum_{n+1\le r\le 2n}\cos\frac{2\pi r}{2n}$$

But, $$\sum_{n+1\le r\le 2n}\cos\frac{2\pi r}{2n}$$

$=\sum_{1\le s\le n}\cos\frac{2\pi (s+n)}{2n}$(Putting $r=n+s$)

$=\sum_{1\le s\le n}\cos\left(\pi+\frac{2\pi s}{2n}\right)$

$=-\sum_{1\le s\le n}\cos\frac{2\pi s}{2n}$ (as $\cos(\pi+x)=-\cos x$ )

So, $$\sum_{0\le r\le 2n}\cos\frac{2\pi r}{2n}=\cos0=1$$

So, the average will be $\frac1{2n+1}$

-
$\int_0^{2\pi}\cos x\,dx=0$... – David Mitra Dec 13 '12 at 16:46
@DavidMitra Yup – andybenji Dec 13 '12 at 16:50
@DavidMitra, thanks for your observation.Would you please look into the edited answer. – lab bhattacharjee Dec 14 '12 at 4:36