Problems 297
(c) The line spectrum of the pure tonep(t)=cos( 2 πfAt) only displays one harmonic, the one
corresponding to thefA=880 Hzfrequency. How many more harmonics doess(t)have? To listen
to the richness in harmonics use the MATLAB functionsoundto play the sinusoidp(t)ands(t)(use
Fs= 2 ×880 Hzto play both).
(d) Consider a combination of notes in a certain scale; for instance, let
p(t)=sin( 2 π× 440 t)+sin( 2 π× 550 t)+sin( 2 π× 660 t)
Use the same windowingw(t), and lets(t)=p(t)w(t). Use MATLAB to plotp(t)ands(t)and to
compute and plot their corresponding line spectra. Usesoundto playp(nTs)ands(nTs)using
Fs= 1000.
4.25. Computation ofπ—MATLAB
As you know,πis an irrational number that can only be approximated by a number with a finite number
of decimals. How to compute this value recursively is a problem of theoretical interest. In this problem we
show that the Fourier series can provide that formulation.
(a) Consider a train of rectangular pulsesx(t), with a period
x 1 (t)=2[u(t+0.25)−u(t−0.25)]− 1 −0.5≤t≤0.5
and periodT 0 = 1. Plot the periodic signal and find its trigonometric Fourier series.
(b) Use the above Fourier series to find an infinite sum forπ.
(c) IfπNis an approximation of the infinite sum withNcoefficients, andπis the value given by MATLAB,
find the value ofNso thatπNis95%of the value ofπgiven by MATLAB.
4.26. Square error approximation of periodic signals—MATLAB
To understand the Fourier series consider a more general problem, where a periodic signalx(t), of period
T 0 , is approximated as a finite sum of terms,
ˆx(t)=
∑N
k=−N
Xˆkφk(t)
where{φk(t)}are orthonormal functions. To pose the problem as an optimization problem, consider the
square error
ε=
∫
T 0
|x(t)−ˆx(t)|^2 dt
and look for the coefficients{Xˆ(k)}that minimizeε.
(a) Assume thatx(t)as well asxˆ(t)are real valued, and thatx(t)is even so that the Fourier series
coefficientsXkare real. Show that the error can be expressed as
ε=
∫
T 0
x^2 (t)dt− 2
∑N
k=−N
Xˆk
∫
T 0
x(t)φk(t)dt+
∑N
`=−N
|Xˆ`|^2 T 0
(b) Compute the derivative ofεwith respect toXˆnand set it to zero to minimize the error. FindXˆn.
(c) In the Fourier series the{φk(t)}are the complex exponentials and the{Xˆn}coincide with the Fourier
series coefficients. To illustrate the above procedure consider the case of the pulse signalx(t), of period
T 0 = 1 , and a period
x 1 (t)=2[u(t+0.25)−u(t−0.25)]