Example 2. Assume
that
is periodic with period
, i.e.
, and
is defined by
for
.
Find the Fourier polynomial of degree n = 5 for the
12 equally spaced points in the
interval
.
Use the "numerical integration" method for finding the
coefficients.
Solution 2.
Enter the function using the piecewise definition.
Enter the number of subintervals n and the degree m of the Fourier polynomial.
Construct the coefficients
,
and the Fourier polynomial.
Construct the Fourier polynomial using the coefficients
and
.
We are done !
We can graph the situation for fun.
![[Graphics:../Images/FourierSeriesMod_gr_104.gif]](../Images/FourierSeriesMod_gr_104.gif)
Remark. The coefficients are
approximations to the ones found analytically using symbolic
integrations.
However, when only data points are used, the numerical integration
method must be used.
As we will see, the FFT is a more efficient way to integrate.
![[Graphics:../Images/FourierSeriesMod_gr_119.gif]](../Images/FourierSeriesMod_gr_119.gif)
Caveat. When
creating the sums which define the coefficients
,
be sure to sum up only n terms
.
Remember, "numerical integration" is being used
and [0,2L] is
subdivided into n subintervals, not n+1
subintervals.
(c) John H. Mathews 2004