# Numerically solve ODE with boundary conditions

If I want to solve the eigenvalue problem $-y''=\lambda y$ with either periodic or antiperiodic boundary conditions on $[0,2\pi]$, how can I enter the boundary conditions?

I mean, in general I would take a finite Fourier basis and solve the problem by diagonalizing a matrix numericlaly, but how can I do it, if I am just interested in particular boundary conditions? Do I have to take particular basis functions?

Just take the corresponding basis, made from functions, which satisfy your boundary conditions. In particular, for periodic boundary conditions and $x\in[0,2\pi]$ these basis functions will work:
$$f_n(x)=e^{inx},\;n\in\mathbb Z.$$
• For example, take half-integer $n$ instead of integers... – Ruslan Feb 23 '15 at 13:59