Sum over cosines = dirac delta - how to get the coefficients? Given this formula:
$$\sum\limits_{n=0}^\infty a_n \cos(n \pi x / d) = \delta(x-x_0)$$
Where $0 \leq x \leq d$. How can one calculate the coeffciients $a_n$?
I googled and searched all kinds of books, but could not find a representation of the Dirac delta to solve this problem.
 A: If you want a Fourier series then you need a repetition of the $\delta$ distribution at the right.
The 'Dirac comb' is defined by :
$$\Delta_T(t):=\sum_{k=-\infty}^\infty \delta(t-kT)$$
with 
$$\Delta_T(t)=\frac 1T\sum_{n=-\infty}^\infty e^{i2\pi nt/T}=\frac 1T+\frac 2T\sum_{n=1}^\infty \cos\left(\frac{2\pi nt}T\right)$$
Replace $\frac T2$ by $d\ $ and $\ t$ by $x-x_0$ to get an interesting result
A: Here's another approach. 
Consider the boundary value problem 
$$f''+\lambda^2f = 0$$ 
where
$f'(0) = f'(d)=0$. 
The orthonormal solutions 
$$f_n(x) = 
\begin{cases}
\sqrt{\frac{1}{d}}, & n = 0 \\
\sqrt{\frac{2}{d}} \cos \frac{n\pi x}{d}, & n\ne 0
\end{cases}$$
form a basis for square integrable function on $[0,d]$. 
As such, they satisfy a completeness relation 
$$\sum_n f_n(x)f_n(x_0) = \delta(x-x_0).$$
Therefore, 
$$\frac{1}{d} + \frac{2}{d}\sum_{n=1}^\infty 
\cos \frac{n\pi x}{d} \cos \frac{n\pi x_0}{d} = \delta(x-x_0).$$
This solution is a symmetrized version of @RaymondManzoni's---it is $\Delta_{2d}(x-x_0) + \Delta_{2d}(x+x_0)$.
It has period $2d$ so the Dirac comb's don't interfere with one another on $[0,d]$. 
On the interval of interest it is $\delta(x-x_0)$ and it does not contain terms of the form $\sin\frac{n\pi x}{d}$. 
Below we plot the sums for 
$\Delta_{2d}(x-x_0)$
and 
$\Delta_{2d}(x-x_0) + \Delta_{2d}(x+x_0)$. 
We cut off the sums at $n=15$, let $d=1$, and $x_0=1/3$. 


