Вы находитесь на странице: 1из 8

© Sheffield Hallam Maths Group

Part 3: Computational methods


for Fourier Series
Fourier Series on Derive
The Derive file INT_APPS.MTH defines functions that automate various applications
of integration, including Fourier series. The file must first be loaded using the File,
Load, Math commands and is located in the S:\DfW\Math directory.

The function FOURIER ( y , t, t1 , t 2 , N ) simplifies to a truncated Fourier series of


expression y depending on variable t varying from t1 to t 2 . N is a nonnegative
integer, and the series is truncated to the Nth harmonic, having the form

N
 nπt  N
 n πt 
1
2 a0 + ∑
n =1
a k cos
 L 
+ ∑b
n =1
k sin 
 L 

t 2 − t1
where L = and a 0 , a1 , a 2 , ... and b1 , b2 , ... depend on the particular expression
2
f .
The following example illustrates its use.

Exercise 6.1 - Practice


Try the above example for yourself.

fourier3 - computational methods.doc 7


© Sheffield Hallam Maths Group

Piecewise Continuous Functions


In order to use the FOURIER function in Derive the function that is to be approximated must
be described over one cycle. Some functions cannot be described by a single expression over
the whole cycle. The STEP function enables us to describe piecewise continuous functions.
Consider the following example:

- x·(STEP(x + 5) - STEP(x)) + x·(STEP(x)


- STEP(x - 5))

Exercise 6.2 - Piecewise continuous functions


1. Enter the function above and use FOURIER to obtain and plot its Fourier series.

2. Go back to Exercise 6.2 and use FOURIER to obtain and plot the Fourier series
expansions of the functions in questions 1 and 2. Comment on the nature of each
function and its Fourier series, in particular noting whether the function is odd, even
or neither.

3. A fully rectified sine wave is given by

f (t ) = 10 sin( 50πt ) , 0 ≤ t < 0.02


f (t ) = f (t + 0.02)

Obtain the Fourier series approximation of this function and comment on its harmonic
content.

Illustrate the nature of the series by plotting appropriate partial sums.

fourier3 - computational methods.doc 8


© Sheffield Hallam Maths Group

Integration using Excel


We can work out approximate integrals using Excel.

Remember the trapezium rule:


Area of a trapezium = half the sum of the parallel sides times the distance in between.

1
Area = ( y1 + y2 ) h
2

So if we are trying to find the area under a periodic function from -L to L


2L
y1 y2 we can split the area into k strips, each of width and if the ordinates
k
are y0 , y1 , y2 , y3 … yk ,
h
Then the total area is approximately
1 1 1 1 1
( y 0 + y 1 )h + ( y1 + y 2 )h + ( y 2 + y 3 )h + ... + ( y k −2 + y k −1 )h + ( y k −1 + y k )h
2 2 2 2 2
= h{y 1 + y 2 + y 3 + ... + y k −1} + h{y 0 + y k }
1
2

Since it’s periodic, yk = y0 so the overall area is given by

L k −1
Area = ∫ ydx ≈ h{y 0 + y1 + y 2 + y 3 + ... + yk −1} = h ∑ ym
−L m= 0
This is something we can implement in Excel making it almost automatic.

Example
Find the Fourier series of f ( x ) = cos x

First we sketch the graph:

We note that it’s even, therefore b n = 0 for all n.

fourier3 - computational methods.doc 9


© Sheffield Hallam Maths Group

s+ 2L
1  nπx 
To find a n we know that a n =
Ls
cos x cos ∫
 L 
 dx

We decide s = 0 and we work out period = 2L = π ⇒ L = π/2.


π
2
So we need a0 =
π ∫
0
cos x dx

π
cos x cos (2nx ) dx for n > 0
2
an =
π ∫
0

These are horrid (impossible?) to integrate algebraically, so we decide on an approximation.


We will use 20 strips, across the interval, ie
k = 20
π
Therefore the strip width is h=
20
And we use
π
2 k −1 2 π 19
∑ ∑
2
a0 =
π ∫
0
cos x dx ≈ h
π m=0
fm =
π 20 m =0
cos x m

π
2 k −1 2 π 19
cos x cos (2 nx )dx ≈ ∑ ∑
2
an =
π ∫
0
h
π m= 0
fm =
π 20 m= 0
cos x m cos(2 nxm )

We set up the spreadsheet as shown on the next page.

Exercise 6.3 - Fourier series on Excel


Download the file FourierB.xls from ftp://maths.sci.shu.ac.uk/mr/ep218
Investigate how this spreadsheet works. Consider the following questions

• What does each column/row contain?


• How would you change the spreadsheet to
o include more terms of the Fourier series?
o calculate the integrals more accurately?
o calculate the Fourier series of a different function which was also even?
o calculate the Fourier series of a function which was not even?

fourier3 - computational methods.doc 10


© Sheffield Hallam Maths Group

19


1 1 19
a0 =
10 m =0
cos x m an = ∑
10 m= 0
cos x m cos(2 nx)

fourier3 - computational methods.doc 11


© Sheffield Hallam Maths Group

Discrete Fourier Analysis


One of the advantages of using something like Excel to calculate Fourier series is that we can
also use it to work with functions which cannot be integrated analytically.
One example of this is where we have some sampled data which is periodic.

Example
Samples of a sound wave with wavelength 1 are taken and the amplitudes are found to be
given by the data below. Construct the Fourier series which approximates this data.
t amplitude t amplitude t amplitude
0 10.5 0.3 1.45 0.6 -1.1
0.1 9.53 0.4 -1.64 0.7 0.6
0.2 6.25 0.5 -2.8 0.8 5.47
0.9 6.3

We can put this into the spreadsheet for Fourier analysis:

Sampled data

fourier3 - computational methods.doc 12


© Sheffield Hallam Maths Group

Which leads us to the graph of the Fourier Series:

12

10

6
Original Function
f(x)

4
Fourier series
2

0
-1 0 1 2 3
-2

-4
x

This in turn means that we could look at the size of the coefficients of each harmonic, and
assess the contribution of different frequency responses to the original signal. But this is a
whole other story best saved for another time

Exercise 6.4 - Discrete Fourier Series


Download the file FourierC.xls from ftp://maths.sci.shu.ac.uk/mr/ep218

Investigate how this spreadsheet works. Consider the following questions

• How is it different from FourierB.xls?


• What does each column/row contain?
• How would you change the spreadsheet to
o deal with a different set of sample data?
o deal with a different number of sample data points?
o calculate the Fourier series with more harmonics?

Modify the spreadsheet to find the Fourier Series of the following data sample, which is
assumed to be periodic with period 6.

t amplitude t amplitude t amplitude


2 0.1 4.0 0.21 6.0 1.24
2.5 0.6 4.5 0.34 6.5 1.15
3.0 0.6 5.0 0.56 7.0 1.01
3.5 0.3 5.5 0.89 7.5 0.51

What are the coefficients a n and b n ?

Find the graph of the partial sum of the Fourier series (a) up to the 3rd harmonic (b) up to the
10th harmonic.

fourier3 - computational methods.doc 13


© Sheffield Hallam Maths Group

Summary
The definition of Fourier series is given by

 nπx  ∞  nπx 
f ( x ) = 12 a 0 + ∑
n =1
an cos ∑
 + bn sin 
 L  n =1  L 

 πx   2πx 
= 12 a0 + a1 cos   + a2 cos  + ...
L  L 
 πx   2πx 
+ b1 sin   + b2 sin   + ...
L  L 
s+ 2 L
1  nπx 
where an =
L ∫ f ( x) cos
s
L 
dx

s+ 2 L
1  nπx 
and bn =
L ∫ f ( x) sin  L 
dx
s

The hardest bit is calculating the integrals. We can do this by


• Hand
• TI85 or similar
• Derive
• using Excel

To work out the whole Fourier series, we can


• do it by hand (using technology to help with the integrals if necessary)
• use the function FOURIER(y, x, t0, t1, n) in Derive
• use an Excel spreadsheet

Exercise 6.5 - Finishing touches


What are the pros and cons of calculating integrals
• by hand
• using TI-8*
• using Derive
• using Excel?
Will all methods work for all functions?

What are the pros and cons of finding Fourier series using
• pen and paper
• Derive
• Excel?
Again, are there times when one method is more suitable than others?

fourier3 - computational methods.doc 14

Вам также может понравиться