Distance between function and subspace Let $f(x)=cos^{n+1}(x)$, where $n \in \mathbb{N}$. In the real vector space $C([-\pi,\pi],\mathbb{R})$, we consider the inner product $\int_{\pi}^{\pi} \! f(x) g(x) dx$. My question is:

What is the distance $d$ between $f$ and $V=span\{ 1,cos(x),sin(x),...,cos(nx),sin(nx)\}$?

I do not know how to attack this problem in a simple way. If I'm not mistaken, $d$ is going to be the distance between $f$ and the orthogonal projection, $\overline{f}$ of $f$ over $V$, but I could not evaluate the integrals required to calculate $\overline{f}$. Any help?
Edit(1): I'm mainly interested in a solution using only concepts from basic linear algebra (inner products, orthogonalization, etc.) and not Fourier series or derivatives.
Edit(2): Computer calculations seem to suggest that $d=\pi/2^n$.
 A: Let 
$$ g(x) = a_0+\sum_{k=1}^{n} a_k \sin kx +\sum_{k=1}^{n} b_k \cos kx  $$ 
where $a_0,a_i,b_i$ needs to be determined by minimizing the following function
$$ f(a_0,a_k,b_k) = \int_{-\pi}^{\pi} \left[ \cos^{n+1}(x)- \left( a_0+\sum_{k=1}^{n} a_k \sin kx +\sum_{k=1}^{n} b_k \cos kx \right) \right]dx $$
which can be done by solving the system of equations 
$$ f_{a_0}=0 \\ f_{a_k} =0\quad k=1,\dots,n \\ f_{b_k} =0 \quad  k=1,\dots,n  $$  
A: Sines and cosines form an orthonormal basis for the space of square-integrable functions with the inner product
$$
\tfrac{1}{\pi}\int_{-\pi}^\pi f(x)g(x)\,dx.
$$ $V_n=span\{ 1,\cos(x),\sin(x),...,\cos(nx),\sin(nx)\}$ is a linear space of trigonometric polynomials of nth degree. Using trigonometric power formulas we see that $\cos^{n+1}\theta\in V_{n+1}\supset V_n$ with the orthogonal component being $\frac{1}{2^n}\cos((n+1)\theta)$. Its length calculated in the inner product above is $\dfrac{1}{2^n}.$ We can call it the distance between $\cos^{n+1}\theta$ and $V_n.$
