What we want to do with the eigenfunctions once we have them is to compute the eigenfunction decomposition of an arbitrary function \(f(x)\text{.}\) That is, we wish to write
\begin{equation}
f(x) = \sum_{n=1}^\infty c_n y_n(x) ,\tag{5.3}
\end{equation}
where
\(y_n(x)\) are eigenfunctions. We wish to find out if we can represent any function
\(f(x)\) in this way, and if so, we wish to calculate the
\(c_n\) (and of course we would want to know if the sum converges). OK, so imagine we could write
\(f(x)\) as
(5.3). We will assume convergence and the ability to integrate the series term by term. Because of orthogonality we have
\begin{equation*}
\begin{split}
\langle f , y_m \rangle
= \int_a^b f(x) \, y_m (x) \, r(x) \, dx
& = \int_a^b \left( \sum_{n=1}^\infty c_n y_n(x) \right) \, y_m (x) \, r(x)
\, dx\\
&= \sum_{n=1}^\infty c_n \int_a^b y_n(x) \, y_m (x) \, r(x) \, dx\\
&= c_m \int_a^b y_m(x) \, y_m (x) \, r(x) \, dx = c_m \langle y_m , y_m \rangle
.
\end{split}
\end{equation*}
Hence,
\begin{equation}
\mybxbg{~~
c_m = \frac{\langle f , y_m \rangle}{\langle y_m , y_m \rangle}
=
\frac{\int_a^b f(x) \, y_m (x)\, r(x) \, dx}{\int_a^b {\bigl(y_m(x)\bigr)}^2 \, r(x) \,dx} .
~~}\tag{5.4}
\end{equation}
Note that
\(y_m\) are known up to a constant multiple, so we could have picked a scalar multiple of an eigenfunction such that
\(\langle y_m , y_m \rangle = 1\) (if we had an arbitrary eigenfunction
\(\tilde{y}_m\text{,}\) divide it by
\(\sqrt{\langle \tilde{y}_m , \tilde{y}_m \rangle}\)). When
\(\langle y_m , y_m \rangle = 1\text{,}\) we have the simpler form
\(c_m = \langle f, y_m \rangle\text{.}\) The following theorem holds more generally, but the statement given is enough for our purposes.
Example 5.1.4.
Consider
\begin{equation*}
\begin{aligned}
& y'' + \lambda y = 0, \quad 0 < x < \nicefrac{\pi}{2} , \\
& y(0) =0, \quad y'(\nicefrac{\pi}{2}) = 0 .
\end{aligned}
\end{equation*}
The above is a regular Sturm–Liouville problem, and
Theorem 5.1.1 says that if
\(\lambda\) is an eigenvalue then
\(\lambda \geq 0\text{.}\)
Suppose
\(\lambda = 0\text{.}\) The general solution is
\(y(x) = Ax + B\text{.}\) We plug in the initial conditions to get
\(0=y(0) = B\text{,}\) and
\(0 = y'(\nicefrac{\pi}{2}) = A\text{.}\) Hence
\(\lambda = 0\) is not an eigenvalue.
So let us consider \(\lambda > 0\text{,}\) where the general solution is
\begin{equation*}
y(x) = A \cos \bigl( \sqrt{\lambda} \, x \bigr)
+ B \sin \bigl( \sqrt{\lambda} \, x \bigr) .
\end{equation*}
Plugging in the boundary conditions we get \(0 = y(0) = A\) and \(0 = y'(\nicefrac{\pi}{2})
= \sqrt{\lambda} \, B \cos \bigl(\sqrt{\lambda} \, \frac{\pi}{2}\bigr)\text{.}\) Since \(A\) is zero, then \(B\) cannot be zero. Hence \(\cos \bigl( \sqrt{\lambda} \,
\frac{\pi}{2}\bigr) = 0\text{.}\) This means that \(\sqrt{\lambda} \,\frac{\pi}{2}\) is an odd integral multiple of \(\nicefrac{\pi}{2}\text{,}\) i.e. \((2n-1)\frac{\pi}{2} = \sqrt{\lambda_n} \,\frac{\pi}{2}\text{.}\) Solving for \(\lambda_n\) we get
\begin{equation*}
\lambda_n = {(2n-1)}^2 .
\end{equation*}
We can take \(B = 1\text{.}\) Our eigenfunctions are
\begin{equation*}
y_n(x) = \sin \bigl( (2n-1)x \bigr) .
\end{equation*}
A little bit of calculus shows
\begin{equation*}
\int_0^{\frac{\pi}{2}} {\Bigl( \sin \bigl( (2n-1)x \bigr) \Bigr)}^2 \, dx
= \frac{\pi}{4} .
\end{equation*}
So any piecewise smooth function \(f(x)\) on \([0,\nicefrac{\pi}{2}]\) can be written as
\begin{equation*}
f(x) = \sum_{n=1}^\infty c_n \sin \bigl( (2n-1)x \bigr) ,
\end{equation*}
where
\begin{equation*}
c_n = \frac{\langle f , y_n \rangle}{\langle y_n , y_n \rangle}
= \frac{\int_0^{\frac{\pi}{2}} f(x) \, \sin \bigl( (2n-1)x \bigr) \, dx
}{\int_0^{\frac{\pi}{2}} {\Bigl(\sin \bigl((2n-1)x\bigr)\Bigr)}^2 \, dx}
= \frac{4}{\pi} \int_0^{\frac{\pi}{2}} f(x) \,\sin \bigl( (2n-1)x \bigr) \, dx .
\end{equation*}
Note that the series converges to an odd
\(2\pi\)-periodic extension of
\(f(x)\text{.}\) With the regular sine series, we would expect a function with period
\(2 \, \frac{\pi}{2} = \pi\text{.}\)
Let us compute an example. Consider \(f(x) = x\) for \(0 < x < \nicefrac{\pi}{2}\text{.}\) Some calculus later we find
\begin{equation*}
c_n =
\frac{4}{\pi} \int_0^{\frac{\pi}{2}} f(x) \,\sin \bigl( (2n-1)x \bigr) \, dx
=
\frac{4{(-1)}^{n+1}}{\pi {(2n-1)}^2} ,
\end{equation*}
and so for \(x\) in \([0,\nicefrac{\pi}{2}]\text{,}\)
\begin{equation*}
f(x) = \sum_{n=1}^\infty \frac{4{(-1)}^{n+1}}{\pi {(2n-1)}^2}
\sin \bigl( (2n-1)x \bigr) .
\end{equation*}
This is different from the \(\pi\)-periodic regular sine series which can be computed to be
\begin{equation*}
f(x) = \sum_{n=1}^\infty \frac{{(-1)}^{n+1}}{n} \sin ( 2nx ) .
\end{equation*}
Both series converge to \(f(x)\) for \(0 < x < \nicefrac{\pi}{2}\text{,}\) but the eigenfunctions involved come from different eigenvalue problems.