Skip to main content
Logo image

THE GEOMETRY OF MATHEMATICAL METHODS

Section 19.5 Calculating and Visualizing a Legendre Polynomial Expansion

In Section 19.4, we found a formula (19.4.3) for the coefficients in a Legendre polynomial series for the function \(f(z)\) on the interval \(-1\le z\le 1\text{.}\) Let’s try an example. Consider the step function
\begin{equation} \varepsilon(z) = 2\,\Theta(z) - 1 = \begin{cases}+1\amp(z>0)\\-1\amp(z<0)\end{cases}\tag{19.5.1} \end{equation}
where \(\Theta\) is the Heaviside step function; note that \(\varepsilon(z)\) is an odd function of \(z\text{.}\) Using (19.4.3) leads to
\begin{align} c_\ell \amp= \left(\ell+\frac12\right) \int\limits_{-1}^1 P^*_\ell(z) \, \varepsilon(z) \, dz\notag\\ \amp= - \left(\ell+\frac12\right) \int\limits_{-1}^0 P^*_\ell(z) \, dz + \left(\ell+\frac12\right) {\int\limits}_0^1 P^*_\ell(z)\, dz\tag{19.5.2} \end{align}
and each integral in the final expression is an elementary integral of a polynomial. Furthermore, it is easily seen that these two integrals cancel if \(\ell\) is even, and add if \(\ell\) is odd, so that
\begin{equation} c_\ell = \begin{cases} 0 \amp (\ell~\text{even}) \\ \displaystyle 2\left(\ell+\frac12\right) {\int\limits}_0^1 P^*_\ell(z)\, dz \amp (\ell~\text{odd}) \end{cases}\tag{19.5.3} \end{equation}
These coefficients are easily evaluated in any good computer algebra system for as many values of \(\ell\) as desired.
Figure 19.2 below shows the \(m\)th order Legendre expansion of function of your choice. The default function is \(\varepsilon(z)\) from the example above.
Figure 19.2. This GeoGebra applet shows the \(m\)th order Legendre expansion for a function of your choice.