Fourier Series: question on the period and terms Wiki defines the Fourier coefficients as:
$a_n = \frac 2 P \int_P s(x) cos(2\pi x \frac n P) dx, b_n = \frac 2 P \int_P s(x) sin(2\pi x \frac n P) dx$
It's my understanding the leading term $\frac 1 P$ is for the average value theorem.
Question : Does anyone know why the $2$ is in the numerator? For average valueI I would expect just $\frac 1 P$.
The Fourier Series is defined:
$s_N(x) = \frac {a_0} 2 + \sum_{n=1}^N (a_n cos(\frac {2 \pi n x} P) + b_n sin(\frac {2 \pi n x} P))$
Question : similarly, why is $\frac {a_0} 2$ divided by $2$?
I ask the first question because on another site the coefficients are different:
Where $L = \frac P 2$, then
$a_n = \frac 1 L \int_{2L} s(x) cos(\pi x \frac n L) dx, b_n = \frac 1 L \int_{2L} s(x) sin(\pi x \frac n L) dx$
Substituting in $P/2$ for $L$ equals the same equation at the beginning of this post:
$a_n = \frac 2 P \int_{P} s(x) cos(2 \pi x \frac n P) dx, b_n = \frac 2 P \int_{P} s(x) sin(2 \pi x \frac n P) dx$
My suspicion is there is something going on with the period that I'm overlooking.  It appears in form where $L = P/2$ the average value form is as expected.
 A: To make things easier, I will explain it for the case $P=2\pi$, since this is the standard case. Furthermore let $\mathcal T_n=\text{span}\{\unicode{x1D7D9},\cos(\cdot),\dots,\cos(n\cdot),\sin(\cdot),\dots,\sin(n\cdot)\}$ (where $\unicode{x1D7D9}(x):=1$) the vector space of all trigonometric functions of maximum degree $n$ and let $\mathcal L^1_{2\pi}:=\{s:\mathbb R\to\mathbb R| 2\pi\,\,\text{ periodic, and absolutly integrable}\}$.
(We can clearly see that $\mathcal T_n\subset \mathcal L^1_{2\pi}$).
Now is important that we have a skalar product on $\mathcal L^1_{2\pi}$ given by
$$\langle f,g\rangle:=\tfrac 1 \pi\int_0^{2\pi}f(x)\cdot g(x)\,dx$$
and the norm
$$||f||:=\sqrt{\langle f,f\rangle}.$$
We need that $\tfrac1 \pi$ to make thinks work good, because we want that the Fourier Sum of degree $n$ is just the orthogonal Projection from $\mathcal L^1_{2\pi}$ to $\mathcal T_n$ . That means we want define an operator $$S_n:\mathcal L^1_{2\pi}\to \mathcal T_n\\f\mapsto\sum_{k=0}^{2n}\langle f,u_k\rangle\cdot u_k$$
with an orthonormal Base $u_k$ of $\mathcal T_n$. (Maybe you have seen this before in linear algebra.)
Furthermore we want to use our Base of $\mathcal T_n$ that I wrote before. Our Base is already Orthogonal (independent of the factor $\tfrac 1 \pi$) but this factor is important that $\sin(kx)$ and $\cos(kx)$ has the norm 1 since:
$$\int_0^{2\pi}(\cos(kx))^2dx=\int_0^{2\pi} (\sin(kx))^2dx=\pi\quad\quad k\geq 1$$
We get now:
$$||\cos(k\cdot)||:=\left(\langle \cos(k\cdot),\cos(k\cdot)\rangle\right)^{\tfrac1 2}=\left(\frac 1 \pi\int_0^{2\pi}\cos(kx)^2dx\right)^{\tfrac 1 2}=\left(\frac \pi \pi \right)^{\tfrac 1 2}=1$$
(Analogously for $\sin(kx)$).
So this is the reason why we have this special factor infront of the integral. We just want that our standard Base has norm 1. Maybe you have already notice that I ignored our Base function $\unicode{x1D7D9}$ all the time, this guy has (sadly) not norm 1:
$$||\unicode{x1D7D9}||=\left(\frac 1\pi\int_0^{2\pi}\unicode{x1D7D9}(x)^2dx\right)^{\tfrac 1 2}=\left(\frac 1 \pi \int_0^{2\pi}dx\right)^{\tfrac 1 2}=\sqrt 2$$
So if we want that the last Base function has norm 1 we need to devide it by $\sqrt 2$:
$$||\tfrac {1} {\sqrt{2}} \unicode{x1D7D9}||=\left(\frac 1{\pi}\int_0^{2\pi}(\tfrac {1} {\sqrt{2}}\unicode{x1D7D9}(x))^2dx\right)^{\tfrac 1 2}=\left(\frac 1 {2\pi }\int_0^{2\pi}dx\right)^{\tfrac 1 2}=1$$
So if we want to have our Base now orthonormal we need to change the first Base Vector we now have the new Base :
$\mathcal T_n=\text{span}\{\tfrac 1 {\sqrt 2}\unicode{x1D7D9},\cos(\cdot),\dots,\cos(n\cdot),\sin(\cdot),\dots,\sin(n\cdot)\}$. We can now rewrite $\tfrac {a_0} 2$:
$$\frac {a_0} 2=\frac 1 {2\pi}\int_0^{2\pi} f(x)\underbrace{\cos(0\cdot x)}_{=1=\unicode{x1D7D9}(x)}dx=\frac 1{2\pi}\int_0^{2\pi}f(x)\unicode{x1D7D9}(x)dx=\langle f,\tfrac 1{\sqrt 2} \unicode{x1D7D9}\rangle \tfrac 1 {\sqrt 2}\unicode{x1D7D9}$$
This is the reason why we need to devide $a_0$ by 2. We now have  that the Fourier sum is the Orthogonal Projection:
$$\frac {a_0} 2 +\sum_{k=1}^{n} a_k\cdot \cos(kx)+b_k\cdot\sin(kx)=\\ \langle f,\tfrac 1{\sqrt 2} \unicode{x1D7D9}\rangle \tfrac 1 {\sqrt 2}\unicode{x1D7D9}+\sum_{k=1}^{n}\langle f,\cos(k\cdot)\rangle\, \cos(kx)+\langle f,\sin(k\cdot)\rangle\,\sin(kx)$$
That was all what we wanted, I hope that anwsers your questions.
