How to turn ODE into an Eigenvalue Problem My Question:
What is the general formula/method for turning an ODE into an eigenvalue problem?
My book turns this equation from an example
$$\frac{d^2u}{dx^2}+ u=e^x, u(0)=u(\pi)=0$$
into
$$\frac{d^2\phi}{dx^2}+ \phi=-\lambda \phi, \phi(0)=\phi(\pi)=0$$
If $u$ is replaced by $\phi$ everywhere it appears, why does $e^x$ turn into $\phi$ as well?
The Problem:

Without determining $u(x)$, how many solutions are there of
$$\frac{d^2u}{dx^2}+ u=\sin(x),
 \frac{du}{dx}(0)=\frac{du}{dx}(\pi)=0~?$$

Work So Far:
The eigenvalue problem for our given equation is:
$$\frac{d^2\phi}{dx^2}+\phi=-\lambda \phi, \frac{d\phi}{dx}(0)=\frac{d\phi}{dx}(\pi)=0$$
 A: The usual idea is to expand the right side in an orthonormal eigenbasis (self-adjoint operator required) so that the construction of a solution decouples as a series of one-dimensional equations. If
$$L=\sum_i \lambda_iu_iu_i^*$$ where $(λ_i,u_i)$ are the pairs of eigenvalues and eigenvectors,
then the solution to $$Ly=f\iff \sum_i \lambda_iu_i(u_i^*y)=\sum_i u_i(u_i^*f)$$ can be constructed as $$y=\sum _iu_i(u_i^*y)=\sum_i \frac{(u_i^*f)}{\lambda_i}u_i.$$
In the case of a zero eigenvalue or higher-dimensional eigenspaces a little more care is required.

More specifically, every function $u\in C^2([0,\pi])$ with $u(0)=u(\pi)=0$ can be expanded into a Fourier sine series, $u(x)=\sum_{k=1}^\infty a_k\sin(kx)$. This also shows that the system of eigenfunctions is a complete orthogonal basis. The effect of $L[u]=u''+u$ on this series is $L[u]=\sum_{k=1}^\infty (1-k^2)a_k\sin(kx)$. 
As the first Fourier coefficient for $f(x)=e^x$ is non-zero, no solution exists, the same for $f(x)=\sin x$. This can also be tested directly, for $f(x)=e^x$ the solution is $y(x)=\frac12e^x+c_1\sin(x)+c_2\cos(x)$ and the boundary conditions lead to the conditions $\frac12+c_2=0=\frac12e^\pi-c_2$, which can not simultaneously hold. For the right side $f(x)=\sin x$ one gets similarly that the general solution of the ODE is $-\frac12x\cos(x)+c_1\sin(x)+c_2\cos(x)$ with contradicting conditions $c_2=0=\frac12-c_2$.
A: The goal is to express the solution as the linear combination some basis functions
$$ u(x) = \sum_n c_n \phi_n(x) $$
where $c_n$ are unknown constants and $\phi_n$ are linearly independent. Plugging this form into the original ODE gives
$$ u''(x) + u(x) = \sum_n c_n\big[\phi_n''(x) + \phi_n(x)\big] $$
It would be really convenient if this result was also a linear combination of the same basis functions, i,e,
$$ \sum_n c_n\big[\phi_n''(x) + \phi_n(x)\big] = -\sum_n c_n\lambda_n\phi_n(x) $$
where $\lambda_n$ is known. Then the equation becomes
$$ -\sum_n c_n\lambda_n\phi_n(x) = e^x $$
If you decompose the RHS function into its own basis functions, then $c_n$ can easily be found.

As for the boundary conditions, note that
$$ u(0) = \sum_n c_n \phi_n(0) = 0 $$
Since $\phi_n(x)$ are linearly independent, it follows that $\phi_n(0) = 0$. The same goes for $\phi_n(\pi)=0$
