16.12.2012 Views

Computer Algebra Recipes

Computer Algebra Recipes

Computer Algebra Recipes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8.2. THE POWER SPECTRUM 333<br />

trum will now reveal what they are. The sampling time interval is taken to be<br />

Ts = T2=d and the sampling frequency Fs =1=Ts is calculated.<br />

> T[s]:=T[2]/d; F[s]:=1/T[s];<br />

Ts := 0:05000000000 Fs := 20:00000000<br />

The continuous function x(t) is sampled at times t = nTs with n =0toN ¡ 1.<br />

The sequence of sampled x values is then put into an array format.<br />

> x:=Array([seq(x(n*T[s]),n=0..N-1)]):<br />

The (discrete) Fourier transform of x is performed. Maple de¯nes this transform<br />

such that the kth item in FT is Xk= p N in our notation.<br />

> FT:=FourierTransform(x):<br />

The following operator will allow us to calculate S(k) foragivenk value.<br />

> S:=k->abs(FT[k])^2:<br />

A plotting point operator pt is introduced that gives the power spectrum S(k)<br />

at the frequency (k ¡ 1) Fs=N .<br />

> pt:=k->[F[s]*(k-1)/N,S(k)]:<br />

Taking the power spectrum to be zero at zero frequency, we produce the points<br />

in the power spectrum for k ranging up to N=2.<br />

> pts:=[[0,0],seq(pt(k),k=2..N/2)]:<br />

The complete power spectrum is plotted, and shown in Figure 8.9. There are<br />

clearly two frequencies present at 1 and 2 beats per second, as expected.<br />

> plot(pts,labels=["f","S"],view=[0..5,0..0.3]);<br />

300<br />

250<br />

S<br />

150<br />

100<br />

50<br />

0<br />

1 2 3 4 5<br />

f<br />

Figure 8.9: Frequencies in Frank N. Stein's heartbeat.<br />

PROBLEMS:<br />

Problem 8-8: Third Harmonic<br />

Suppose that Frank N. Stein's heartbeat also contains the term 0:1 sin(6¼t).<br />

Plotting p S, show that the presence of the third harmonic is revealed.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!