Professional Documents
Culture Documents
By
Distributed by
i nfoClearinghouse.com
Fourier Analysis 33
Fourier series 33
Fourier sine series 34
Fourier cosine series 37
Fourier Series 45
A user-defined SCILAB function to calculate Fourier series 46
Applications of function fourierseries 47
Fourier series for a piecewise periodic function 49
Calculating Fourier series coefficients with Filon’s sine-cosine formulae 52
An alternative for calculating the coefficients of the Fourier series is to use function filonquad, defined
earlier for calculating integrals of the form 52
Use of Fourier series in ordinary differential equations 55
Fourier series for a trapezoidal pulse 55
Solution to the damped oscillator equation with trapezoidal pulse and wave excitation 57
Fourier series for other periodic shapes 58
Solving the damped oscillator equation with a different periodic trapezoidal pulse 59
Fourier transforms 60
Fourier analysis of discrete data 61
SCILAB functions for discrete Fourier transform (DFT) and fast Fourier transform (FFT) 62
Scilab’s dft function 62
Exercises 74
∫
b
(gn, gm ) = g n ( x ) ⋅ g m ( x ) ⋅ dx = 0 ,
a
for n ≠ m. The notation (gn,gm) is used when defining linear vector spaces to indicate the
inner or dot product of two vectors, thus, for vectors u and v, (u,v) = u• v. If vectors u and v
are orthogonal (in the Euclidean sense), (u,v) = u• v = 0. By similarity with vectors, we can
state that if (gn,gm) = 0 for a set of functions gn(x), then functions gn and gm are orthogonal.
where a and b are real constants, is known as the Cauchy or Euler equation. A solution to the
Cauchy equation can be found by assuming that
y(x) = xn.
Replacing this function into the differential equation and simplifying results in an auxiliary
algebraic equation:
n 2 + (a − 1) ⋅ n + b = 0.
If the equation has two different roots, say n1 and n2, then the general solution of this
equation is
If b = (1-a)2/4, then the equation has a double root n1 = n2 = n = (1-a)/2, and the
solution turns out to be
y(x) = (K1 + K2⋅ln x)xn.
Legendre’s equation
An equation of the form
where n is a real number, is known as the Legendre’s differential equation. Any solution for
this equation is known as a Legendre’s function. When n is a nonnegative integer, the solutions
are called Legendre’s polynomials. Legendre’s polynomial of order n is given by
M
(2n − 2m)!
Pn ( x) = ∑ (−1) m ⋅ ⋅x n− 2 m
m=0 2 ⋅ m!⋅(n − m)!⋅(n − 2m)!
n
where M = n/2 or (n-1)/2, whichever is an integer. The first six Legendre polynomials are
P0(x) = 1.0,
P1(x) = x,
P2(x) = (3x2-1)/2,
P3(x) =(5x3-3x)/2,
P4(x) =(35x4-30x2+3)/8,
P5(x) =(63x5-70x3+15x)/8.
∞
Γ(α ) = ∫ e −t t α −1 dt ,
0
gammaln(x) = ln[Γ(x)].
Related to the log-gamma function is the di-gamma function, defined as the derivative of the
log-gamma function:
ψ(z) = d[ln Γ(z)]/dz = Γ’(z)/ Γ (z),
if n == 0 then
cc = [1];
elseif n == 1 then
cc = [0 1];
else
if modulo(n,2) == 0 then
M = n/2
else
M = (n-1)/2
end;
cc = zeros(1,M+1);
for m = 0:M
k = n-2*m;
cc(k+1)=...
(-1)^m*gamma(2*n-2*m+1)/(2^n*gamma(m+1)*gamma(n-m+1)*gamma(n-2*m+1));
end;
end;
pL = poly(cc,var,'coeff');
The following SCILAB statements generate the first 10 Legendre polynomials as elements of a
column vector p.
-->getf('legendrepol')
-->p = zeros(10,1);
-->for nn = 1:10
--> p(nn) = legendrepol(nn,'x');
-->end;
-->p
p =
! x !
! !
A plot of Legendre polynomials P1(x), P2(x), P3(x), P4(x), and P5(x), is produced using the
following SCILAB commands. A matrix pp of five columns stores the values of the polynomials,
one per column, corresponding to a vector of values of x, xx.
-->getf('legendrepol')
-->xx = [-1:0.01:1];
-->n = length(xx)
n = 201.
-->for j = 1:5
--> pp(:,j) = horner(p(j),xx');
-->end;
-->plot2d([xx',xx',xx',xx',xx'],[pp(:,1),pp(:,2),pp(:,3),pp(:,4),pp(:,5)],...
-->[1:1:5],'111','n=1@n=2@n=3@n=4@n=5',[-1 -1 1 1 ])
-->xtitle('Legendre polynomials','x','Pn(x)')
Bessel’s equation
The ordinary differential equation
If ν = n, an integer, the Bessel functions of the first kind for n = integer are defined by
∞
(−1) m ⋅ x 2 m
J n ( x) = x n ⋅ ∑ 2m+n
.
m =0 2 ⋅ m!⋅(n + m)!
y(x) = K1⋅Jν(x)+K2⋅J-ν(x).
For integer values, the functions Jn(x) and J-n(x) are linearly dependent, since
Jn(x) = (-1)n⋅J-n(x),
therefore, we cannot use them to obtain a general function to the equation. Instead, we
introduce the Bessel functions of the second kind defined as
x −n n −1
(n − m − 1)! 2 m
− ⋅∑ ⋅x
π m =0 2
2 m− n
⋅ m!
1 1 1
γ = lim[1 + + + ... + − ln r ] ≈ 0.57721566490...,
r →∞ 2 3 r
For the case n = 0, the Bessel function of the second kind is defined as
2 x ∞
(−1) m−1 ⋅ hm 2 m
Y0 ( x) = ⋅ J 0 ( x) ⋅ (ln + γ ) + ∑ 2 m ⋅x .
π 2 m=0 2 ⋅ (m!) 2
With these definitions, a general solution of Bessel’s equation for all values of ν is given by
y(x) = K1⋅Jν(x)+K2⋅Yν(x).
Hn(1)(x) = Jν(x)+i⋅Yν(x),
and
Hn(2)(x) = Jν(x)−i⋅Yν(x),
These functions are also known as the first and second Hankel functions of order ν.
In some applications you may also have to utilize the so-called modified Bessel functions of
the first kind of order ν defined as Iν(x)= i-ν⋅Jν(i⋅x), where i is the unit imaginary number.
These functions are solutions to the differential equation
• besselj: Bessel functions of the first kind [Jν(x)], with general call:
y = besselj(nu,x)
• bessely: Bessel functions of the second kind [Yν(x)], with general call:
y = bessely(nu,x))
• besseli: modified Bessel functions of the first kind [Iν(x)], with general calls:
y = besseli(nu,x)
• besselk: modified Bessel functions of the second kind [Kν(x)], with general calls:
y = besselk(nu,x)
y = besselk(nu,x,s)
In the calls to functions besselj, bessely, besseli, and besselk, the parameter nu represents the
order of the function ν, and x is a single non-negative value or vector of non-negative values
where the function is to be evaluated. The calls of functions besseli and besselk may include
the parameter s whose default value is 1. When the value of s is 2, the so-called exponentially
scaled Bessel functions are calculated.
To see a plot of the functions Jn(x), for n = 0,1,2,3,4, use the following SCILAB commands:
n =
101.
m =
5.
-->bb = zeros(n,m);
-->for j = 1:m
--> bb(:,j) = besselj(nu(j),xx);
-->end;
-->plot2d([xx',xx',xx',xx',xx'],[bb(:,1),bb(:,2),bb(:,3),bb(:,4),bb(:,5)],...
-->[1,2,3,4,5],'111','nu=1@nu=2@nu=3@nu=4@nu=5',[0,-0.6,10,1])
n = 0, 1, … are called Chebyshev polynomials of the first and second kind, respectively. The
polynomials Tn(x) are solutions of the differential equation
In SCILAB, the function chepol generates the Chebyshev polynomial of the first kind of order n,
given a value of n > 0. The general call to the function is
[Tn]=chepol(n,var)
where n is the order of the polynomial, and var is a SCILAB polynomial variable.
Un(x) = sin(n⋅arccos(x))/sin(arccos(x)).
The first four Chebyshev or Tchebycheff polynomials of the first and second kind are:
The polynomials of the first kind can be obtained using SCILAB function chepol as follows:
-->T0 = chepol(0,'x')
T0 =
1
-->T2 = chepol(2,'x')
T2 =
2
- 1 + 2x
-->T3 = chepol(3,'x')
T3 =
3
- 3x + 4x
-->T4 = chepol(4,'x')
T4 =
2 4
1 - 8x + 8x
Plots of the Chebyshev polynomials of the first kind for n = 0, 1, 2, 3, 4, are shown below:
-->xx = [-1:0.01:1];
-->y0 = horner(T0,xx);y1 = horner(T1,xx);y2 = horner(T2,xx);
-->y3 = horner(T3,xx);y4 = horner(T4,xx);
-->plot2d([xx',xx',xx',xx',xx'],[y0',y1',y2',y3',y4'],...
-->[1,2,3,4,5],'111','T0@T1@T2@T3@T4',[-1,-1,1,1])
-->xtitle('Chebyshev polynomials','x','T_n(x)')
Laguerre’s equation
Laguerre’s equation is the second-order, linear ODE of the form
e x d n (x n ⋅ e−x )
L0 ( x) = 1, Ln ( x) = ⋅ , n = 1,2,...
n! dx n
are solutions to Laguerre’s equation. Laguerre’s polynomials can also be calculated with:
n
(−1) m n n(n − 1) 2 (−1) n n
Ln ( x ) = ∑ ⋅ ⋅ x m = 1 − n ⋅ x + ⋅ x − ... + .... + ⋅x .
m =0 m! m 4 n!
The term
n n!
= = C (n, m)
m m!(n − m)!
is the m-th coefficient of the binomial expansion (x+y)n. It also represents the number of
combinations of n elements taken m at a time.
The Laguerre polynomials can be generated in SCILAB through the following user-defined
function, laguerrepol:
if n == 0 then
c = [1];
else
c = [];
for m = 0:n
c = [c (-1)^m*gamma(n+1)/((gamma(m+1))^2*gamma(n-m+1))];
end;
end;
Lp = poly(c,var,'coeff');
-->getf('laguerrepol')
-->L0 = laguerrepol(0,'x')
L0 =
1
-->L1 = laguerrepol(1,'x')
L1 =
1 - x
-->L2 = laguerrepol(2,'x')
L2 =
-->L3 = laguerrepol(3,'x')
L3 =
2 3
1 - 3x + 1.5x - .1666667x
-->L4 = laguerrepol(4,'x')
L4 =
2 3 4
1 - 4x + 3x - .6666667x + .0416667x
The following is the plot of the functions L0(x), L1(x), L2(x), L3(x) and L4(x):
-->x = [-2:0.01:6];
-->y0 = horner(L0,x); y1 = horner(L1,x); y2 = horner(L2,x);
-->y3 = horner(L3,x); y4 = horner(L4,x);
-->plot2d([x',x',x',x',x'],[y0',y1',y2',y3',y4'],...
-->[1,2,3,4,5],'111','L0@L1@L2@L3@L4',[-2,-5,6,5])
-->xtitle('Laguerre polynomials','x','L_n(x)')
d2y/dx2+(n+1/2-x2/4)y = 0,
y(x) = exp(-x2/4)H*(x/√2),
dx n
To calculate Hermite polynomials in SCILAB we will use the following recurrence equation
H*n+1(x) = 2xH*n(x)-2nH*n-1(x)
with H0*(x) = 1, H1*(x) = 2x. A user-defined function to produce the Hermite polynomials is
listed below:
H = zeros(1,n+1);
H(1) = poly([1],var,'coeff');
H(2) = poly([0 2],var,'coeff');
for j = 2:n
H(j+1) = poly([0 2],var,'coeff')*H(j)-2*(j-1)*H(j-1);
end;
Hn = H(n+1);
//end function hermitepol
The following are the first five Hermite polynomials:
-->getf('hermitepol')
-->H0 = hermitepol(0,'x')
H0 =
1
-->H1 = hermitepol(1,'x')
H1 =
2x
-->H2 = hermitepol(2,'x')
H2 =
2
- 2 + 4x
-->H3 = hermitepol(3,'x')
H3 =
3
- 12x + 8x
-->H4 = hermitepol(4,'x')
H4 =
2 4
12 - 48x + 16x
-->plot2d([x',x',x',x',x'],[y0',y1',y2',y3',y4'],...
-->[1,2,3,4,5],'111','H0@H1@H2@H3@H4',[-3,-30,3,20])
-->xtitle('Hermite polynomials','x','H_n(x)')
Gaussian quadrature
The idea of Gaussian quadrature for the numerical calculation of integrals consists in
identifying a discrete number of points xi, i = 1,2,…,n, and a corresponding number of
constants, Ai, i = 1,2,…,n, so that the integral is estimated as
n
f ( x)dx ≈ ∑ Ai f ( xi ) .
b
∫a
i =1
The figure below illustrates the meaning of the coefficients Ai as the base of rectangles whose
heights are given by f(xi). The sum of the areas of the rectangles approximates the integral.
n
f ( x)dx ≈ ∑ Ai f ( xi ) = A1 f ( x1 ) + A2 f ( x 2 ), n = 2
1
∫−1
i =1
exactly for the cases f(x) = 1, f(x) = x, f(x) = x2, f(x) = x3. Replacing these polynomials for f(x)
will produce four equations from which we can solve for the four unknowns, x1, x2, A1, and A2.
The equations produced are:
1
For f ( x) = 1 ⇒ ∫−1
1 ⋅ dx = 2 = A1 + A2 ,
1
For f ( x) = x ⇒ ∫ −1
x ⋅ dx = 0 = A1 x1 + A2 x 2 ,
1 2
For f ( x) = x 2 ⇒ ∫
−1
x 2 ⋅ dx =
3
= A1 x12 + A2 x 22 ,
1
For f ( x) = x 3 ⇒ ∫ −1
x 3 ⋅ dx = 0 = A1 x13 + A2 x 23 .
x1 = -1/√3, x2 = 1/√3, A1 = 1, A2 = 1.
1 1
∫
1
f ( x)dx ≈ f (− )+ f( ).
−1
3 3
The integral calculated with this formula will be exact if f(x) = 1, x, x2, or x3, and approximate
for any other function. If we want to calculate an integral of function f(x) in the interval [a,b]
we introduce the following change of variable
2x − a − b
t= ,
b−a
b 1 1 b−a b+a
∫ a
f ( x)dx =
2
(b − a ) ⋅ ∫ f (
−1 2
⋅t +
2
)dt
1 b−a b+a 1 n
b−a b+a
)dt ≈ (b − a ) ⋅ ∑ Ai ⋅ f (
b 1
∫a
f ( x)dx =
2
(b − a ) ⋅ ∫ f (
−1 2
⋅t +
2 2 i =1 2
⋅ xi +
2
).
n
f ( x)dx ≈ ∑ Ai f ( xi ) .
1
∫−1
i =1
For values of n>2, the values xi and Ai are calculated by solving the 2n equations of the form
∑Ax
1
i
k
i = ∫ x k dx, i = 1,2,..., n, k = 0,1,2,...,2 ⋅ n − 1.
−1
i =1
It can be shown that the values of xi, i=1,2,…,n, are the roots of the Legendre polynomial Pn(x),
while the coefficients Ai, i = 1,2,…,n, are related to the derivative of the n-th Legendre
polynomial, P’n(x) = dPn/dx, by
2
Ai = .
(1 − x )[ Pn ' ( xi )] 2
2
i
Legendre’s polynomial of order n are the solutions to the Legendre’s ordinary differential
equation
(1-x2)⋅(d2y/dx2)-2⋅x⋅ (dy/dx)+n⋅ (n+1) ⋅y = 0,
To illustrate the use of function gaussquad we will use it to integrate the function f(x) =
ex/(1+x2)2 for n = 2, 3, 4, 5, 6, 7, 8 , 9, 10, 12, 14, 16, 18, and 20. A plot of the function in the
range of integration is presented below.
-->deff('[y]=f(x)','y=exp(x)./(1+x^2)^2')
-->x=[0:0.05:10];y=f(x);plot(x,y,'x','y','f(x)=exp(x)/(1+x^2)^2')
-->Res = [ ];
-->for j=1:length(nn)
--> Res=[Res; [nn(j),gaussquad(0,10,f,nn(j))]];
-->end;
n Int
! 2. 4.7168792 !
! 3. 5.7578069 !
! 4. 5.9621965 !
! 5. 5.8817127 !
! 6. 5.8034783 !
! 7. 5.7774564 !
! 8. 5.778712 !
! 9. 5.7846526 !
! 10. 5.7877236 !
! 12. 5.7879883 !
! 14. 5.7876393 !
! 16. 5.787655 !
! 18. 5.7876657 !
! 20. 5.7876644 !
Improper integrals
Improper integrals is the name given to definite integrals that have infinite limits, for example:
1 dx ∞ dx 1 dx
I1 = ∫ , I = ∫0 x 2 , I = ∫− ∞ 1 + x 2 .
−∞ 1 + x 2
2 2
Gauss-Laguerre formulae can be used to numerically evaluate integrals of the form shown
below through a procedure similar to Gaussian quadrature:
∞ n
∫ e − x g ( x)dx ≈ ∑ Ai ⋅ g ( xi ).
0
i =1
The values of xi, i=1,2,…,n, are the roots of the Laguerre polynomial on order n, Ln(x), and the
coefficients Ai, i=1,2,…,n, are calculated from
xi 1
Ai = = .
(n + 1) [ Ln+1 ( x)]
2 2
xi ⋅ [ L' n ( xi )]2
n
(−1) m n n(n − 1) 2 (−1) n n
Ln ( x ) = ∑ ⋅ ⋅ x m = 1 − n ⋅ x + ⋅ x − ... + .... + ⋅x .
m =0 m! m 4 n!
where
n n!
= = C (n, m)
m m!(n − m)!
is the binomial coefficient.
To calculate an improper integral of a general function, f(x), we will use the following formula:
∞ ∞ n
∫ f ( x)dx = ∫ e − x {e x f ( x)}dx ≈ ∑ Ai ⋅ e xi ⋅ f ( xi ).
0 0
i =1
Of course, the indefinite integral shown can be evaluated only if the integrand decreases
quickly towards zero as x grows without bound. The integral in this case is said to be
convergent.
xr = roots(p);
A=[];
for i = 1:n
A = [A xr(i)/((n+1)^2*(horner(pnp1,xr(i)))^2)];
end;
I = A*(exp(xr).*f(xr));
if n == 0 then
c = [1];
else
c = [];
for m = 0:n
c = [c (-1)^m*gamma(n+1)/((gamma(m+1))^2*gamma(n-m+1))];
end;
end;
Lp = poly(c,var,'coeff');
∞ dx
I1 = ∫ .
01+ x2
The following SCILAB commands define the function to be integrated, f(x) = 1/(1+x2). A plot of
the function is shown next.
-->deff('[y]=f(x)','y=(1+x^2)^(-1)')
-->x=[0:0.1:10];y=f(x);plot(x,y,'x','y','f(x)=1/(1+x^2)')
-->getf('laguerrequad')
-->disp(Res)
! 2. 1.493257 !
! 4. 1.5011895 !
! 6. 1.5188948 !
! 8. 1.53376 !
! 10. 1.5425763 !
! 12. 1.5478021 !
! 14. 1.5512373 !
! 16. 1.5537377 !
! 18. 1.555679 !
! 20. 1.5572394 !
! 22. 1.558519 !
! 24. 1.5595837 !
! 26. 1.5604823 !
! 28. 1.5612765 !
! 30. 1.567911 !
-->%pi/2
ans =
1.5707963
Gauss-Hermite formulae can be used to numerically evaluate integrals of the form shown below
through a procedure similar to Gaussian or Gauss-Laguerre quadrature:
∞ n
∫ e − x g ( x)dx ≈ ∑ Ai ⋅ g ( xi ).
2
−∞
i =1
The values of xi, i=1,2,…,n, are the roots of the Hermite polynomial on order n, Hn(x), and the
coefficients Ai, i=1,2,…,n, are calculated from
d n − x2
H 0 = 1, H n ( x) = (−1) n e x (e ), n = 1,2,...
2
dx n
To calculate an improper integral of a general function, f(x), we will use the following formula:
∞ ∞ n
∫ f ( x)dx = ∫ e − x {e x f ( x)}dx ≈ ∑ Ai ⋅ e xi ⋅ f ( xi ).
2 2 2
−∞ −∞
i =1
Earlier in the chapter we defined function hermitepol to generate Hermite polynomials. The
following function, hermitequad, which incorporates function hermitepol, is used to calculate
the improper integral shown above.
We use function hermitequad to calculate the integral of the function f(x) = exp(-|x|). A plot
of the function is shown next:
-->deff('[y]=f(x)','y=exp(-abs(x))')
-->getf('hermitequad')
-->Res=[]; for j = 2:2:30, Res=[Res; [j, hermitequad(f,j)]]; end;
-->Res
Res =
! 2. 1.4408859 !
! 4. 1.730544 !
! 6. 1.8420198 !
! 8. 1.8963115 !
! 10. 1.9264848 !
! 12. 1.9447991 !
! 14. 1.9566605 !
! 16. 1.9647431 !
! 18. 1.9704841 !
! 20. 1.9747063 !
! 22. 1.9779055 !
! 24. 1.9803932 !
! 26. 1.9823717 !
! 28. 1.9839769 !
! 30. 1.9853024 !
xn
∫ x0
f ( x) ⋅ cos(kx)dx = ∆x ⋅ [α{ f ( x n ) sin( kx n ) − f ( x0 ) sin( kx0 )} + β ⋅ κ e + γ ⋅ κ o ],
xn
∫x0
f ( x) ⋅ sin( kx)dx = ∆x ⋅ [α{ f ( x 0 ) cos(kx0 ) − f ( x n ) cos(kx n )} + β ⋅ σ e + γ ⋅ σ o ],
with
∆x = (xn-x0)/n, θ = k⋅∆x,
n− 2
1
κ e = { f ( x0 ) cos(kx0 ) + f ( x n ) cos(kxn )} +
2
∑ f ( x ) cos(kx ),
i = 2 , 4 , 6 ,...
i i
n −1
κo = ∑ f ( x ) cos(kx ),
i =1, 3, 5 ,...
i i
n− 2
1
σ e = { f ( x0 ) sin(kx0 ) + f ( x n ) sin(kxn )} +
2
∑ f ( x ) sin(kx ),
i = 2 , 4 , 6 ,...
i i
and
n −1
σo = ∑ f ( x ) sin(kx ).
i =1, 3, 5 ,...
i i
The values of xi, i=0,1,2,…,n, are calculated using xi = x0+i⋅∆x. Values x0 and xn are the limits
of integration, and n is required to be an even number.
The following function, filonquad, can be used to calculate the integrals involving sine or
cosine function as described above. The first argument in the function call indicates which
type of trigonometric function, sine (‘sin’) or cosine (‘cos’), is to be used in the integral. The
other arguments are the lower and upper limits of integration, x0 and xn, the name of the
function, f, and the number of (even) sub-intervals, n:
The following SCILAB commands are used to generate tables of the integrals calculated through
Filon’s integral formulae with function filonquad. The function f(x) in the integrals is f(x) =
exp(-x), and it is integrated between x0 = 2 and xn = 4.5. The parameter k in sin(kx) or
cos(kx) takes values k = 1,2,3,4,5, one value of k for each column of the tables, while the
number of sub-intervals takes values n = 4,6,…,20, corresponding to each row in the tables.
The first table corresponds to integrals involving sine functions while the second table
corresponds to integrals containing cosine functions.
-->for i = 1:mn
--> for j = 1:mk
--> Res(i,j) = filonquad('sin',kk(j),x0,xn,nn(i),f);
--> end;
-->end;
-->Res
Res =
-->for i = 1:mn
--> for j = 1:mk
--> Res(i,j) = filonquad('cos',kk(j),x0,xn,nn(i),f);
--> end;
-->end;
-->Res
Res =
∫
b
(gn, gm ) = g n ( x ) ⋅ g m ( x ) ⋅ dx = 0 ,
a
for n ≠ m.
If n = m, then the resulting integral represents the square of a quantity, ||gn||, known as the
b
|| g n || 2 = ( g n , g n ) = ∫ [ g n ( x)]2 ⋅ dx ≠ 0.
a
norm of gn(x):
Example 1 -- For the functions gn(x) = sin(nπx) on the interval (0,1), you can check that the
integral
1
⌠
sin( n π x ) sin( m π x ) dx
⌡
0
evaluates to
−n cos( n π ) sin( m π ) + m sin( n π ) cos( m π )
−
π ( −n + m ) ( n + m )
This latter expression is equal to zero for n ≠ m (n and m integers), and it is not defined if m =
n. For the case m = n, we can calculate the value of the integral by using:
1
∫ sin (nπx)dx
2
0
which evaluates to
1 −cos( n π ) sin( n π ) + n π
2 nπ
-->deff('[ff]=f1(x)','ff=sin(n.*%pi.*x).*sin(m.*%pi.*x)')
Next, we calculate the integrals of f1(x) for combinations of values of n and m, verifying that
the integrals are zero (i.e., nearly zero, for numerical integrals) for n ≠ m, and equal to ½ for n
= m:
-->m=2;n=5;intg(0,1,f1,0.01)
ans = 8.951E-17
-->m=3;n=2;intg(0,1,f1,0.01)
ans = 4.339E-18
-->m=3;n=3;intg(0,1,f1,0.01)
ans = .5
-->m=4;n=4;intg(0,1,f1,0.01)
ans = .5
over the interval a < x < b, then we can use the property of orthogonality to obtain the
coefficients Cn of the series as follows:
∞
f ( x) ⋅ g m ( x) = ∑ C n ⋅ g n ( x) ⋅ g m ( x).
n =1
Integrate the resulting expression over the interval a < x < b, i.e.,
∞
f ( x) ⋅ g m ( x) ⋅ dx = ∑ C n ⋅∫ g n ( x) ⋅ g m ( x) ⋅ dx.
b b
∫a
n =1
a
Because all integrals in the summation in the right-hand side of the expression above are
zero, except for m = n, the expression simplifies to:
b b
∫ a
f ( x) ⋅ g m ( x) ⋅ dx = C m ⋅∫ [ g m ( x)] 2 ⋅ dx
a
Cn =
∫ a
f ( x) ⋅ g n ( x) ⋅ dx
=
( f , gn )
⋅
b
∫ [g
a
n ( x)]2 ⋅ dx || g n ||
Example 2 -- For the orthogonal functions gn(x) = sin(nπx), 0<x<1, the corresponding series is a
Fourier sine series, i.e.,
∞
f ( x) = ∑ C n ⋅ sin( nπx),
n =1
and,
1 1
Cn =
∫
0
f ( x) ⋅ sin( nπx) ⋅ dx
=
∫ 0
f ( x) ⋅ sin( nπx) ⋅ dx 1
= 2 ⋅ ∫ f ( x) ⋅ sin( nπx) ⋅ dx.
1
∫ sin (nπx) ⋅ dx 1/ 2
2 0
0
Suppose that we want to find a few coefficients for the series expansion of the function f(x) =
x2 for the orthogonal functions gn(x) = sin(nπx), 0<x<1, we can use the following SCILAB
commands. First, we define the function f(x):
-->deff('[y]=f(x)','y=x^2')
-->deff('[gg]=g(x)','gg=f(x)*sin(n*%pi*x)')
-->deff('[CC]=C(n)','CC=2*intg(0,1,g,0.01)')
The following vector represents the first five coefficients of the series:
Orthonormal functions
A set of normal functions φn(x) on an interval a < x < b is said to be orthonormal if
0, when m ≠ n
(φ n , φ m ) = ∫ g n ( x) ⋅ g m ( x) ⋅ dx =
b
a
1, when m = n
First, to verify that the set of functions given is orthogonal, check that the integral
1
⌠
cos( n π x ) cos( m π x ) dx
⌡
0
1
⌠
cos( n π x ) 2 dx
⌡
0
You can check that the latter integral evaluates to ½. Thus, ||gn||2 = ½, and ||gn|| = 1/√2.
The orthonormal functions will be defined, therefore, as
∫
b
p ( x ) ⋅ g n ( x ) ⋅ g m ( x ) ⋅ dx = 0 .
a
b
|| g n || 2 = ∫ p ( x) ⋅ [ g n ( x)]2 ⋅ dx ≠ 0.
a
∞
f ( x) = ∑ C n ⋅ g n ( x),
n =1
C n=
∫
a
p ( x) ⋅ f ( x) ⋅ g n ( x) ⋅ dx
=
1 b
⋅ ∫ p( x) ⋅ f ( x) ⋅ g n ( x) ⋅ dx ⋅
b
∫ a
p ( x) ⋅ [ g n ( x)] 2 ⋅ dx || g n || a
Example 1 -- The Chebyshev polynomials T1(x) = x, T2(x) = 2x2-1, on the interval –1 < x < 1, are
orthogonal with respect to the weight function p(x) = (1-x2)-1/2, which can be demonstrated by
calculating the integral
1
⌠
2
x (2 x − 1)
dx
1−x
2
⌡
-1
You can check that the integral evaluates to zero by using SCILAB as follows. First, we define a
function ff(x) representing the integrand in the previous integral.
Next, we generate points in the interval (-1,1), not including the extremes of the interval, i.e.,
x = -1 and x = 1, where the integrand goes to infinity.
-->xx=[-0.99:0.01:0.99]; yy = f(xx);
-->inttrap(xx,yy)
ans =m- 9.021E-17
d dy
r ( x) ⋅ + [q ( x) + λ ⋅ p ( x)] y = 0,
dx dx
to be solved in the interval a < x < b, and subject to the boundary conditions
α1⋅y(a) + β1⋅y’(a) = 0,
and
α2⋅y(b) + β2⋅y’(b) = 0.
By selecting the values of the functions r(x), p(x), and q(x), as well as the constants α1, α2, β1,
and β2, we can generate, out of the general ODE shown above, the Bessel equation, Laguerre’s
equation, etc. The solutions to the Sturm-Liouville ODE are given in terms of different values
of the parameter λ, known as the eigenvalues of the problem, while the solutions themselves
are known as the eigenfunctions.
Fourier Analysis
Fourier analysis involves the expansion of periodic functions into infinite series of sine and
cosines. In general, any continuous function can be expanded into a series of sine functions
(Fourier sine series), cosine functions (Fourier cosine functions), or a series combining sine and
cosine functions (Fourier series). Expansion of functions into Fourier series finds applications
in areas related to any type of wave propagation, be it electromagnetic waves or surface waves
in waters.
In practice, we evaluate Fourier series using only a finite number of sine and/or cosine
functions representing a discrete number of frequencies. Fourier analysis can be extended to a
continuous frequency domain through the use of Fourier transforms. Fourier transforms have
applications in the analysis of periodic and non-periodic signals such as communication signals,
turbulence velocity variations, etc. Most measured signals include a finite number of
(typically) equally spaced data points suitable for analysis through discrete Fourier transforms.
Sine and cosine functions belong to a family of so-called orthogonal functions. Properties of
such functions are presented in the following section.
Fourier series
Fourier series are series involving sine and cosine functions that are typically used to expand
periodic functions. A function f(x) is said to be periodic of period L if f(x+L) = f(x). For
-->deff('[y]=f(x)','y=2.*sin(2.*%pi.*x)-3.*cos(%pi.*x)')
To verify that the function is indeed periodic, we try the following evaluations:
-->f(0),f(2),f(4)
ans = - 3.
ans = - 3.
ans = - 3.
iπx jπx
Because the sine functions sin and sin are orthogonal, i.e.,
L L
L
⌠
sin i π x sin j π x d x = 0 , for i ≠ j ,
L L
⌡0
then
L L
⌠ ⌠ 2
f( x ) sin n π x d x = b nπx L bn
sin
L d x = ,
L
n
2
⌡0 ⌡0
for n = 1, 2, 3,....
Consider the function f( x ) = x − x . This function is obviously not periodic, as shown in the
2
figure below.
-->deff('[y]=f(x)','y=x-x^2')
-->x=[-2:0.1:3];y=f(x);
-->plot(x,y,'x','y','y=x-x^2')
However, we can assume that it is periodic with period, say, L = 2, for the purpose of
expanding the function in a Fourier sine series. The next SCILAB commands are used to
calculate a Fourier sine series for the function. Notice that we define two functions, first a
function g(x) which represents the integrand f(x)sin(nπx/L), and then a function b(n) that
calculates the coefficient bn for the Fourier sine series that approximates f(x).
-->deff('[w]=g(x)','w=f(x)*sin(n*%pi*x/L)')
-->deff('[bb]=b(n)','bb=(2/L)*int(0,L,g)')
We use the following for…end loop to generate the first 20 coefficients for the Fourier
expansion (i.e., n = 0, 1, 2, …, 19).
-->c
c =
column 1 to 6
column 7 to 11
column 17 to 20
To calculate the values for the series expansion we will use the following function fouriersine.
m = length(c); n = length(x);
y = [];
for i = 1:n
yy = 0;
for j = 1:m
yy = yy + c(j)*sin((j-1)*%pi*x(i)/L);
end;
y = [y yy];
end;
-->getf('fouriersine')
-->x=[-2:0.01:3];y=f(x);yf=fouriersine(c,x,L);
-->plot2d([x' x'],[y' yf'],[1,-1],'011',' ',[-2 -6 3 6])
-->xtitle('Fourier sine series for y = x-x^2','x','y')
The plot shows the original function (continuous line) and the approximation through 20 terms
of the Fourier sine series (crosses). The approximation is somewhat acceptable in the range 0
< x < L, which corresponds to the artificial period L = 2 that we imposed on the Fourier series.
Still, the sinusoidal character of the fitting is impossible to eliminate, at least with the 20
components shown. Notice that the Fourier sine series fitting makes the resulting function
The following graph represents the Fourier series for the function y = x-x2 using 40 components
in the series. Obviously, the fitting is much better than when using 20 components only. The
Gibbs phenomenon is still present at x = 2, but up to that value the Fourier sine series fitting is
excellent for this case.
The following SCILAB commands are used to produce graphs of the original function as well as
the Fourier sine series fitting corresponding to 5, 10, 20, 30, and 40 components.
iπx jπx
Because the cosine function cos and cos are also orthogonal, i.e.,
L L
L
⌠
cos i π x cos j π x d x = 0 , for i ≠ j ,
L L
⌡0
then
L L
⌠ ⌠ 2
f( x ) cos n π x d x = a n π x dx
L an
sin
= ,
L
n L 2
⌡0
⌡0
from which it follows that
L
⌠
2 f( x ) cos n π x dx
an =
L
L
⌡0
As an example, to determine the coefficient of the cosine series that fits the function f(x) = (1-
x)(x+1)(x+2) assuming that it is periodic with period L = 1, use the following SCILAB commands:
-->deff('[y]=f(x)','y=(1-x).*(x+1).*(x-2)')
-->deff('[y]=g(x)','y=f(x)*cos(n*%pi*x/L)')
-->deff('[aa]=a(n)',...
['if n==0 then';'aa=intg(0,L,f)/L';'else';'aa=(2/L)*intg(0,L,g)/L';'end'])
-->c
c =
column 1 to 5
column 6 to 10
column 11 to 15
column 16 to 20
column 21 to 25
column 26 to 30
column 31 to 35
column 36 to 40
Function fouriercosine, listed below, is used to calculate the Fourier series given the
coefficients c, a vector of values of x, and the period of the function L.
m = length(c); n = length(x);
y = [];
for i = 1:n
yy = c(1);
for j = 2:m
yy = yy + c(j)*cos((j-1)*%pi*x(i)/L);
end;
y = [y yy];
end;
A plot of the original function and the Fourier cosine series for 5, 10, 20, 30, and 40
components are shown in the following plot. The graph shows the original function and the
different Fourier series to be practically indistinguishable from each other in the range 0 < x <
1.
-->c5=c(1:5);yf5=fouriercosine(c5,x,L);
-->c10=c(1:10);yf10=fouriercosine(c10,x,L);
-->c20=c(1:20);yf20=fouriercosine(c20,x,L);
-->c30=c(1:30);yf30=fouriercosine(c30,x,L);
-->c40=c(1:40);yf40=fouriercosine(c40,x,L);
-->plot2d([x' x' x' x' x' x'],[y' yf5' yf10' yf20' yf30' yf40'],...
-->[1,2,3,4,5,6],'011',' ',rect)
-->xtitle('Fourier cosine series - 5,10,20,30,40 components','x','y')
-->c40=c(1:40);yf40=fouriercosine(c40,x,L);
_________________________________________________________________________________
NOTE: If you have a function that is defined in the interval (-L/2, L/2), where L is the period of
the function, the formulas to use for the coefficients of the cosine and sine functions are:
L
L 2
2
⌠
a0 =
1 ⌠
f( x ) d x , an =
2 f( x ) cos 2 n π x dx ,
L
⌡ L L
L
−
2
⌡ L
−
2
and
____________________________________________________________________________
For example, a sine series fitting of the function f(x) = x3 in the interval [-1,1] (i.e., L=2), is
shown below. The following SCILAB commands are used to define the function y = x3, and the
functions necessary to calculate the coefficients of the corresponding Fourier sine series
expansion:
-->deff('[y]=f(x)','y=x^3')
-->deff('[y]=g(x)','y=f(x)*sin(2*n*%pi*x/L)')
-->deff('[bb]=b(n)','bb=(2/L)*intg(-L/2,L/2,g)')
The function fouriersine2 is a modified version of fouriersine to account for the case in which
the function is fitted in the interval [-L/2,L/2]:
m = length(c); n = length(x);
y = [];
for i = 1:n
yy = 0;
for j = 1:m
yy = yy + c(j)*sin(2*j*%pi*x(i)/L);
end;
y = [y yy];
end;
The next commands produce a plot of the original function, y = x3, and of the Fourier sine
series:
The figure shows that the fitting is excellent except near the extremes of the interval, i.e.,
near x = -L/2 and near x = L/2.
The next example shows a cosine series fitting in the interval [-1,1], L = 2, for the function f(x)
= 1 − x . First, we define functions f(x) and g(x) and the generic coefficient of the Fourier
2
cosine series an = a(n). Next, we calculate the first 40 coefficients in the series.
-->deff('[y]=f(x)','y=1-x^2')
-->deff('[y]=g(x)','y=f(x)*cos(2*n*%pi*x/L)')
-->deff('[aa]=a(n)'...
-->,['if n==0 then';'aa=intg(-L/2,L/2,f)/L';'else';...
-->'aa=(2/L)*intg(-L/2,L/2,g)';'end'])
m = length(c); n = length(x);
y = [];
for i = 1:n
yy = c(1);
for j = 2:m
yy = yy + c(j)*cos(2*(j-1)*%pi*x(i)/L);
end;
y = [y yy];
end;
The following plot shows the original function and the corresponding Fourier cosine series:
-->plot2d([x',x',x',x',x',x'],[y',y5',y10',y20',y30',y40'],...
-->[1:1:6],'011',' ',[-1.5 -0.2 1.5 1.1])
As in the case of the previous example for the sine series, the fitting of this cosine series is
excellent throughout the whole interval [-L/2,L/2] except very close to the extremes of the
intervals. The Gibbs phenomenon is not evident in this case.
______________________________________________________________________________
The last two examples used a series expansion in the interval [-L/2,L/2]. Alternatively, you
could use as interval of integration [-L,L], i.e., an interval encompassing two periods of the
function, to obtain
L L
1 ⌠ ⌠
L
a0 =
1 ⌠
f( x ) d x , a n = f( x ) cos n π x dx , and b = 1 f( x ) sin n π x dx ,
L ⌡−L L
L
n L
L
⌡−L ⌡−L
for n = 1,2,3, ...
The sine and cosine series will be calculated as:
a0 ∞ ∞
n π x nπx
f( x ) = + ∑ a n cos
and f ( x ) = ∑ bn sin L .
2 n =1 L n=1
_______________________________________________________________________________
For example, the function f(x) = tan(x) can be expanded as sine series using the period L = 1 as
follows. First, we define the functions that are used to produce the coefficients of the Fourier
sine series, followed by the calculation of the first 20 coefficients (including a0):
-->deff('[y]=f(x)','y=tan(x)')
Next, we produce a plot of the original function and the Fourier sine series for 5, 10, and 20
components:
-->x=[-2.5:0.01:2.5];y=f(x);
-->c5 = c(1:5); y5 = fouriersine(c5 ,x,L);
-->c10= c(1:10);y10 = fouriersine(c10,x,L);
-->c20= c(1:20);y20 = fouriersine(c20,x,L);
-->plot2d([x' x' x' x'],[y' y5' y10' y20'],[-1,1,2,3],'011',' ',[-1.5 -2 1.5 2])
In the following example, we use a cosine series to fit the function f(x) = (1-x2)1/2 in the
interval [-1,1], i.e., L = 1.
-->deff('[y]=f(x)','y=sqrt(1-x^2)')
-->deff('[y]=g(x)','y=f(x)*cos(n*%pi*x/L)')
-->deff('[aa]=a(n)',...
-->['if n==0 then';'aa=intg(-L,L,f)/(2*L)';'else';...
--> 'aa=intg(-L,L,g)/L';'end'])
-->x=[-1:0.01:1];y=f(x);yf=fouriercosine(c,x,L);
-->plot2d([x',x'],[y',yf'],[1,-1])
a0 ∞
2πnx 2 π n x
f( x ) =
2
+ ∑ an cos + b n sin
n=1 L L
L
L 2
2
⌠
a0 =
2 ⌠
f( x ) d x , an =
2 f( x ) cos 2 n π x dx ,
L
⌡ L L
L
−
2
⌡ L
−
2
and
L
2
⌠
bn =
2 f( x ) sin 2 n π x dx
L
L
⌡ L
−
2
c +L
c +L 0
0 ⌠ 2nπx
f( x ) cos
2 ⌠ 2
a0 = f( x ) d x , an = dx ,
L
⌡c L
L
0 ⌡c
0
and
Thus, if c0 = -L/2, we recover the first set of equations for an and bn.
The following function, fourierseries, returns the coefficients of the Fourier series and the
evaluation of the same on a range of values of x for different number of components. The
general call to the function is
where nn is a vector containing values of the components to be used, e.g., nn = [5, 10, 20], L is
the period of the function, x is a vector indicating the values of x where the Fourier series will
be evaluated, and tol is a tolerance for convergence used in function intg (see --> help intg).
The integrals defining an and bn are calculated in the interval [c0,c0+L]. The function returns
values a0, a, b, and y, where a0 is the coefficient a0 in the series, a and b are vectors
containing the coefficients of the cosine and sine series, respectively, i.e., an and bn for
n=1,2,…, and y is a matrix with the same number of columns as in vector x and the number of
rows equal to the number of elements in vector nn. Thus, the i-th row of matrix y contains the
values of the Fourier series with the number of components indicated by the i-th component of
nn.
deff('[gg1]=g1(xi)','gg1=f(xi)*cos(2*nn*%pi*xi/L)');
deff('[gg2]=g2(xi)','gg2=f(xi)*sin(2*nn*%pi*xi/L)');
deff('[aaa]=a1(nn)','aaa=(2/L)*intg(c0,c0+L,g1,tol)');
deff('[bbb]=b1(nn)','bbb=(2/L)*intg(c0,c0+L,g2,tol)');
a0 = (2/L)*intg(c0,c0+L,f,tol);
Example 1 - The following example shows the fitting of the function f( x ) = 1 + x in the
2
interval [-1,1] using function fourierseries with the option itype = ‘right’. The Fourier series
are calculated for 5, 10, 20, and 40 components. A plot of the original figure and of the
Fourier series with different number of components is also produced.
-->deff('[y]=f(x)','y=sqrt(1+x^2)')
-->getf('fourierseries')
-->L = 2; x=[-1:0.01:1]; y = f(x);
-->[a0,a,b,yy]=fourierseries('right',[5,10,20,40],-L/2,L,x,f,1e-5);
-->plot2d([x' x' x' x' x'],[y' yy(1,:)' yy(2,:)' yy(3,:)' yy(4,:)'])
-->xtitle('Fourier series for y = sqrt(1+x^2) with 5,10,20,40 components',...
-->'x','y')
-->deff('[y]=f(x)','y=log(x+2)')
-->getf('fourierseries')
The fitting of the Fourier series is excellent except near the extremes of the interval where
strong Gibbs phenomenon deviations are observed. Also, the fitting improves as the number of
components in the Fourier series increases.
Notes:
[1] Even if a function is not periodic, you can fit a certain section of the function (say, between
x = 0 and x = L, or between -L/2 and L/2) using Fourier series. Of course, the resulting
trigonometric series will be so that it represents a periodic function of period L.
[2] For any given function you can fit sine, cosine, or full Fourier series. It is recommended,
however, that you plot the original as well as the resulting expansion(s) to determine how well
the Fourier series expansion(s) works.
Example 3 - In the next example we produce the Fourier series for the function g(x) = exp(x),
x in [0,π], i.e., with period L = π.
-->deff('[y]=f(x)','y=exp(x)')
-->getf('fourierseries')
-->[a0,a,b,yy]=fourierseries([5,10,20,40],c0,L,x,f,1e-5);
The following graphs shows the Fourier series developed above in the interval [-2π,2 π] to
demonstrate the fact that the Fourier series produces a periodic function even though the
original function was not periodic. By calculating the Fourier series coefficients in the interval
[0, π] we generates a periodic function of period π.
-->getf('fourierseries')
The following graphs shows the original function (single square pulse) and the periodic function
generated by the corresponding Fourier series using the interval -3 < x < 3. This result
demonstrates how we can generate a square wave out of a single square pulse.
To be able to calculate coefficients for n>10, we can use the definitions for the coefficients an
and bn corresponding to the function h(x) defined earlier. These coefficients are:
and
2 L/2 nπ x 2 1/ 3 nπ X
bn = ∫
L −L / 2
h( x) ⋅ sin
L
⋅ dx = ∫ 3 ⋅ sin
2 −1 / 3 L
⋅ dx = 0.
Also,
2 L/2 2 1/ 3
a0 =
L ∫− L / 2
h( x) ⋅dx = ∫ 3 ⋅ dx = 2.0.
2 −1 / 3
-->deff('[aa]=a(n)','aa=6*sin(n*%pi/3)/(n*%pi)')
-->c = [1]; for j=1:40, c=[c a(j)]; end;
Notice that the first term in the vector of coefficients, c, is equal to 1, i.e., a0/2. Next, we
generate data from the original function (defined earlier):
-->x=-1:0.01:1;y=f(x);
To produce the Fourier series we use function fouriercosine3, which is a modified version of
function fouriercosine, introduced earlier.
To calculate values for the Fourier series with 40 components of cosine we use:
-->getf('fouriercosine3')
-->yy = fouriercosine3(c,x,L);
A plot of the original function and the corresponding Fourier series with 40 components is
shown next:
xm xm
∫x0
f ( x) ⋅ sin( kx)dx, ∫
x0
f ( x) ⋅ cos(kx)dx
For Fourier series coefficients the following values apply: k=2π/L, x0 = c0, xn=c0+L, and the
integrals are to be multiplied by (2/L). Care must exercised when using Filon’s integral
formulas for the function f(x) used must be continuous in the full interval [x0,xn]. Filon’s
integral formulae use a parameter m (referred to as n when the formulae where first
introduced earlier in the Chapter) which must be an even number larger than or equal to 4.
Thus, to calculate the coefficients of the cosine terms we will use
an = (2/L)*filonquad(‘cos’,2*n*%pi/L,x0,xn,m,f),
bn = (2/L)*filonquad(‘sin’,2*n*%pi/L,x0,xn,m,f).
For example, to calculate the first five coefficients of the Fourier series corresponding to f(x) =
exp(-x), using Filon’s sine-cosine quadrature formulae for m = 4,6,8,…,30, we prepare the
following table. Columns represents values of n = 1,2,3,4,5, and rows represent values of m =
4,6,8,…,30:
-->deff('[y]=f(x)','y=exp(-x)');x0=-1;xn=1;L=2;
-->kk=[1:1:5];mk=length(kk);nn=[4:2:40];mn=length(nn);
-->ResCos = zeros(mn,mk);
-->for i = 1:mn
--> for j = 1:mk
--> ResCos(i,j)=(2/L)*filonquad('cos',2*%pi*kk(j)/L,x0,xn,nn(i),f);
--> end;
-->end;
-->ResCos
ResCos =
-->ResSin = zeros(mn,mk);
-->for i = 1:mn
--> for j = 1:mk
--> ResSin(i,j)=(2/L)*filonquad('sin',2*%pi*kk(j)/L,x0,xn,nn(i),f);
--> end;
-->end;
-->ResSin
ResSin =
For the case of the piecewise continuous function that produces the single rectangular pulse,
namely, h(x) = 3, -1/3 < x < 1/3, and h(x) = 0 elsewhere, we can use Filon’s sine-cosine
quadrature formulae to calculate the coefficients for the Fourier series by using x0 = -1/3 and
xn = 1/3, since the function is zero in the remaining ranges of the interval (-1,1). The period is
still taken as L = 2. The following SCILAB commands will produce the Fourier series coefficients
for the cosine and sine components for n = 1,2,3,4,5, and m = 4,6,8,…,30:
-->deff('[y]=f(x)','y=3');x0=-1/3;xn=1/3;L=2;
-->ResCos
ResCos =
-->ResSin = zeros(mn,mk);
-->for i = 1:mn
--> for j = 1:mk
--> ResSin(i,j)=(2/L)*filonquad('sin',2*%pi*kk(j)/L,x0,xn,nn(i),f);
--> end;
-->end;
-->ResSin
ResSin =
! 0. 0. 0. 0. 0. !
! 0. 0. 0. 0. 0. !
! - 8.651E-17 - 9.985E-17 - 1.471E-16 - 2.321E-17 3.258E-17 !
! 2.935E-17 0. 0. - 6.795E-17 - 6.210E-17 !
! - 1.480E-16 - 8.417E-17 - 9.729E-17 5.351E-17 9.501E-17 !
! - .0650665 - .0966290 - .0772903 - .0151104 .0587416 !
! 1.355E-16 1.230E-16 8.613E-17 - 6.320E-17 - 8.416E-17 !
! 0. - 4.398E-17 - 3.772E-17 2.146E-17 0. !
! 0. 1.383E-16 5.777E-17 - 3.214E-17 - 4.877E-17 !
! - 2.871E-16 - 3.412E-16 - 1.219E-16 1.072E-16 1.111E-16 !
! - .0426227 - .0550420 - .0281511 .0194482 .0540867 !
! 2.354E-16 2.053E-16 6.136E-17 - 2.430E-16 - 7.683E-17 !
! - 1.550E-16 - 9.129E-17 2.827E-17 1.233E-16 1.891E-16 !
! - 2.369E-16 - 1.058E-16 9.830E-17 2.560E-16 2.373E-16 !
! - 1.850E-16 - 1.850E-16 - 6.451E-17 1.243E-16 1.295E-16 !
! - .0313185 - .0378327 - .0142622 .0208907 .0397693 !
! 1.261E-16 1.643E-16 - 2.211E-17 - 1.201E-16 - 1.692E-16 !
! - .0282896 - .0335690 - .0114548 .0201849 .0355957 !
! 1.036E-16 0. 5.427E-17 0. - 1.184E-16 !
As found earlier, the coefficients for the sine components are all zero (nearly zero from the
numerical results). The coefficients for the cosine components are very consistent for most
∂ ∂
2
m 2 y( x ) + β y( x ) + k y( x ) = F( x )
∂x ∂
x
The function F(x) in the right-hand side of the equation represents the excitation or driving
force, i.e., an external effect that activates or affects the oscillating system. If the function
F(x) happens to be a periodic function, the expression for F(x) can be replaced by its Fourier
series expansion G(x), before obtaining a solution to the ODE.
.
3 x, 0 < x < 1/ 3
1, 1/ 3 < x < 2 / 3
f ( x) = 2
1 − 3 x − 3 , 2 / 3 < x < 1
0, elsewhere
represent the excitation function in the solution of the differential equation for an oscillating
mass. In the solution, we will use both the original pulse function f(x) and the Fourier series
expansion of f(x), G(x), as illustrated below.
Fourier series for a trapezoidal pulse
To obtain the Fourier series of the trapezoidal pulse, first, we define function f(x):
Next, we generate data for plotting the function in the range 0 < x < 1:
-->x=0:0.01:1;
-->y=[]; for j=1:length(x), y=[y f(x(j))]; end;
The following statements generate the coefficients of a Fourier series with 10 components:
-->L=1;c0=0;[a0,a,b,yy]=fourierseries(10,c0,L,x,f,1e-5);
Next, we produce a plot of the original function and the Fourier series:
Next, we calculate the Fourier series generated by using the trapezoidal pulse f(x) in the range
0 < x < 5 to demonstrate the periodicity of the Fourier series:
-->x=0:0.01:5;L=1;c0=0;[a0,a,b,yy]=fourierseries(10,c0,L,x,f,1e-5);
Next we will solve the second-order differential equation using as driving signals the original
trapezoidal function (a single trapezoidal pulse) and the corresponding Fourier series (a
periodic trapezoidal wave). To solve the problem, we use the variables u1 = y(x) and u2 =
dy/dx, to form the vector function u(x) = [u1;u2], and transform the equation into
In the latter expression we first replace the function F(x) with the original trapezoidal pulse
f(x), and then with the Fourier series G(x). We will use as initial conditions u1(0) = u2(0) = 0
and solve the ODE in the range 0 < x < 20 with an increment ∆x = 0.1.
Following we list the SCILAB commands for solving the ODE. The function f(x) describing the
trapezoidal pulse was defined earlier. Also, the coefficients a0, a, and b of the Fourier series
are available from the call to function fourierseries. The next step is to define a function G(x)
that calculates the Fourier series:
-->deff('[w]=G(x)',['n=length(a)';'w=a0/2';'for j=1:n';...
--> 'w=w+a(j)*cos(2*j*%pi*x/L)+b(j)*sin(2*j*%pi*x/L)';'end'])
Next, we define functions f1(x,u) and f2(x,u) representing the function ff(x,u), i.e., the right-
hand side in the equation du/dx = ff(x,u). Function f1(x,u) involves the trapezoidal pulse
function f(x) while function f2(x,u) involves the Fourier series function G(x) as indicated below:
-->deff('[w]=f1(x,u)','w=[u(2),(f(x)-k*u(1)-beta*u(2))/m]')
-->deff('[w]=f2(x,u)','w=[u(2),(G(x)-k*u(1)-beta*u(2))/m]')
The next step is to define the parameters of the problem and of the solution:
-->k=10;m=5;beta=1;
The solutions to the ODE for the two cases is calculated using function ode as follows:
-->y1=ode(y0,x0,x,f1);
-->y2=ode(y0,x0,x,f2);
Thus, we have demonstrated how to use Fourier series to generate a periodic function
representing almost any type of shape. All we need to get started is a single pulse with the
basic shape that needs to be repeated. Thus, Fourier series can be used to produce periodic
functions such as those illustrated in the figure below:
Even when using the same basic function, e.g., f(x) in the examples above, to generate a
Fourier series, you can change the shape of the resulting periodic signal by changing the period
of the function. In the example worked out above, we used a period L = 1.0, thus, the basic
shape (the trapezoid) repeats one after another in the Fourier series. If we want to add some
space between consecutive trapezoids we can change the period to L = 1.5. The following
SCILAB commands show how to generate such signal.
Solving the damped oscillator equation with a different periodic trapezoidal pulse
With the signal shown above as the excitation to the system represented by the damped
oscillator equation, the solution to the ODE is presented in the following plot:
-->deff('[w]=G(x)',['n=length(a)';'w=a0/2';'for j=1:n';...
--> 'w=w+a(j)*cos(2*j*%pi*x/L)+b(j)*sin(2*j*%pi*x/L)';'end'])
-->deff('[w]=f2(x,u)','w=[u(2),(G(x)-k*u(1)-beta*u(2))/m]')
-->k=10;m=5;beta=1;x=[0:0.1:20];x0=0;y0=[0;0];
-->y3=ode(y0,x0,x,f2);
n = 1,2, …, where T is the period of the function, f0 = 1/T is the fundamental frequency, and ω0
= 2π/T = 2πf0 is the fundamental angular frequency. The Fourier series can also be written as
2 T /2 2 T /2 2 T /2
T ∫−T / 2 T ∫−T / 2 T ∫−T / 2
a0 = f (t ) dt , a n = f (t ) cos(ϖ n t ), b n = f (t ) sin(ϖ n t ).
Plots of the Fourier coefficients an and bn vs. ωn would be similar to the ones sketched below:
In the figure, ∆ω = 2π/T represents the increment in the discrete values of the frequency ωn.
As the period of the signal, T, increases, the increment in frequency, ∆ω, becomes a
differential of frequency, dω. Using the definitions of the coefficients shown above, the signal
can be written as
a0 ∞ 2 T / 2 2 T /2
f (t ) = + ∑ ∫ f (t ) cos(ϖ n t )dt cos(ϖ n t ) + ∫ f (t ) sin(ϖ n t ) sin(ϖ n t )dt .
2 n =1 T −T / 2 T −T / 2
Using 2/T = ∆ω/π, and replacing the summations with integrals as T ! ∞, the signal is now
written as
If we define
1 ∞ 1 ∞
A(ϖ ) =
2π ∫−∞
f (t ) cos(ϖt )dt , B(ϖ ) =
2π ∫ −∞
f (t ) sin(ϖt )dt ,
The terms A( ω) and B( ω) are components of a Fourier transform, and the signal f(t) results
from an inverse Fourier transform.
The Fourier transform of the signal f(t) is the term F(ω) = A( ω)-i⋅B( ω), where i is the unit
imaginary number (i = √-1). Using Euler’s formula, e-iωt = cos(ωt)-i⋅sin(ωt), the Fourier
transform is written as
1 ∞
F (ω ) =
2π ∫
−∞
f (t ) ⋅ e −iωt dt.
∞
f (t ) = ∫ F (ϖ ) ⋅ e iωt dϖ .
−∞
The latter result assumes that a0 = 0, which can be accomplished by subtracting the original
value of ao from the original function.
Assume that the data is collected at regular intervals ∆t = T/n and consists of the n
measurements {x0, x1,x2,…,xn-1} taken at times tr = r⋅∆t. An approximation to the Fourier
transform F( ω) presented earlier, is the summation
1 n −1 1 n −1
X k = ∑ xr e −i ( 2πk / T )( r ⋅∆t )
∆t = ∑ x r e −i ( 2πkr / n ) , k = 0,1,..., n − 1 .
T r =0 n r =0
This is known as the discrete Fourier transform (DFT). The inverse discrete Fourier transform
(IDFT) provides the data values xr in terms of the coefficients Xk:
The coefficients Xk calculated with the discrete Fourier transform, namely, Xk = ak - ibk
represent coefficients of a Fourier series from which the data values xr can be obtained.
However, the coefficients Xk are only correct for frequencies below the frequency
ωk = 2πk/(n⋅∆t) = π/∆t,
i.e., for k = 0, 1, 2, …, n/2. Also, if the signal contains frequencies above π/∆t, these
frequencies introduce a distortion of the Xk -vs -ωk graph known as aliasing. If w0 is the
maximum component of frequency contained in the signal x(t), aliasing is avoided by selecting
∆t so that π/∆t > ωo, or 1/(2⋅∆t) > f0. The value 1/(2⋅∆t) is known as the Nyquist frequency,
which represents the maximum frequency that can be detected by sampling the data at
intervals ∆t.
Function dft applies to single data vectors. The general call to the function is
[xf]=dft(x,flag);
where x is an input vector which may represent signal data (xr, r = 0,1,…,n-1) or Fourier
transform coefficients (Xk, k = 0,1, …, n-1), and flag determines whether to perform a discrete
transform (flag=-1) or an inverse discrete transform (flag=1). The function returns a vector
containing either the discrete Fourier transform coefficients, Xk, if flag = -1, or the signal
values, xr, if flag = 1.
Example of DFT applications: Obtaining the discrete Fourier transform
First, we generate a set of n=101 random numbers representing discrete values yr, r = 0, 1, …,
n-1, of a signal y(t), through the use of function y = f(x) shown below. The function is a sum of
m=10 cosine components plus a couple of random terms. The coefficients in the cosine
components are random numbers generated using SCILAB function rand. The figure below
shows the signal calculated:
-->m=10;
-->k=int(100*rand(1,m));a=int(1000*rand(1,m));phi=int(2*%pi*rand(1,m));
-->deff('[w]=f(x)',...
-->['w=0';'for j=1:m';...
-->'w=w+a(j)*cos(2*k(j)*%pi*x+phi(j))+100*(rand()-0.5)-2000*(rand()-0.5)';...
-->'end'])
The discrete Fourier transform of the signal is obtained by using the following call to function
dft. Of interest to us is the magnitude of the coefficients, i.e., |Xk| = (Ak2+Bk2)1/2, which we
refer to as XfA. A plot of XfA is shown next.
There are a few frequencies that shown strong components, e.g., for k = 1, 11, 31, 41, 42, 52,
and so on. Also, notice that there is a symmetry in the figure, which results from the periodic
nature assumed for the signal in Fourier analysis. This verifies the statement made earlier that
out of the n components of the discrete Fourier transform, only those for k = 0, 1, …, n/2, are
necessary to reproduce the signal.
Example of DFT applications: Obtaining the inverse Fourier transform
In this exercise we generate twenty of complex coefficients representing the Fourier transform
of a signal, i.e., Xk, k = 0,1, …, n-1, with n=20. To visualize the Fourier transform we plot its
absolute value, |Xk|:
-->Xf2 = int(20*rand(1,20))+%i*int(10*(rand(1,20)-0.5));
-->Xf2A = abs(Xf2);
-->xset('mark',-9,1); plot2d([1:1:20]',Xf2A',-9)
-->plot2d3('onn',[1:1:20]',Xf2A')
-->xtitle('|X(w)| vs. w','w','|X(w)|')
-->xs2 = dft(Xf2,1)
xs2 =
! 11.3 - .3i !
! .3709582 + .1198511i !
! - 2.2329752 - 1.2846661i !
! 2.1378546 - .3916269i !
! - .1146755 + .0364961i !
! - .55 - 1.95i !
! - .1372551 - .7108113i !
! 1.5447692 - 1.233702i !
! 2.1785955 + 1.5250802i !
! - .2862057 + .1284268i !
! - 1.2 + .3i !
! 1.1105288 + .2007308i !
! 1.604686 - 1.0823751i !
! 1.075967 + .5249291i !
! - .0593008 + .6035164i !
! .45 + 1.35i !
! - 1.468606 + .0707988i !
! 2.1392805 + 1.176793i !
! - .870469 + .8419610i !
! 1.0068474 + .0745981i !
The resulting signal contains complex numbers. We can, therefore, obtain a signal consisting
only of the real part of xs2 (xs2R), one consisting only of the imaginary part of xs2 (xs2I), and
one formed by taking the magnitude of the elements of xs2 (xs2A). The three different signals
are plotted below.
In order to obtain a real inverse Fourier transform, the vector of Fourier transform coefficients
must satisfy certain symmetry conditions. Let X represent the vector of Fourier transform
coefficients, the first term must be a real number, representing the coefficient a0 in the
equation
If the vector contains an even number of elements n, then, the elements Xk, k=2,3, …,n in the
vector X must be such that Xn = X2, Xn-1 = X3, Xn-2 =X4,…, or, in general, Xn-j+2 = Xj , j = 2,3,
…, n/2. The termsX represents the complex conjugate of X. Finally, element Xn/2+1 must
also be a real number.
As an example, we construct the following vector of coefficients, Xf3, with n=20 elements:
-->m=10;X0 = int(200*(rand(1,m)-0.5))+%i*int(100*(rand(1,m)-0.5));
-->Xf3(n/2+1)=2.0; Xf3'
ans =
! 120. !
! 18. - 20.i !
! 36. - 20.i !
! - 85. + 9.i !
! 88. + 43.i !
! - 74. + 43.i !
! - 59. - 3.i !
! - 60. + 46.i !
! 78. + 18.i !
! - 7. + 12.i !
! 2. !
! - 7. - 12.i !
! 78. - 18.i !
! - 60. - 46.i !
! - 59. + 3.i !
! - 74. - 43.i !
! 88. - 43.i !
! - 85. - 9.i !
! 36. + 20.i !
! 18. + 20.i !
A plot of the Fourier coefficients’ magnitude is shown next. The symmetry of the coefficients
is apparent from the plot:
-->Xf3A=abs(Xf3);
-->xs3 = dft(Xf3,1)
xs3 =
! - .4 !
! 20.141905 - 2.176E-15i !
! 13.737285 - 9.770E-16i !
! - 6.6365465 - 4.885E-15i !
! - 5.0329987 + 6.040E-15i !
! 22.8 - 1.137E-14i !
! - 1.157441 + 2.469E-14i !
! - 9.2480507 + 1.226E-14i !
! - 9.98364 + 1.457E-14i !
! 10.952211 - 6.528E-15i !
! 41.2 - 5.351E-14i !
! 1.3207894 + 1.164E-14i !
! - 1.0044013 + 2.549E-14i !
! - 7.835515 - 1.679E-14i !
! - 12.637178 + 8.331E-14i !
! 26.8 - 1.272E-13i !
! 9.92104 - 1.137E-14i !
! 4.9413984 - 6.040E-15i !
! 26.357334 - 3.366E-14i !
! - 4.2361923 + 4.836E-14i !
The generated signal is made of complex numbers, however, their imaginary parts are
negligible. We will use only their real parts:
-->xs3=real(xs3);
As an example, we put together the Fourier coefficients vector Xf4 with 21 components. A plot
of the magnitude of the coefficients is shown next:
-->m=10;X0 = int(200*(rand(1,m)-0.5))+%i*int(100*(rand(1,m)-0.5));
-->n=21;Xf4 = [50 X0 zeros(1,m)];
-->for j=2:n/2+1, Xf4(n-j+2)=conj(Xf4(j)); end;
-->Xf4A = abs(Xf4);
-->nn=[1:1:21];xset('mark',-9,1);plot2d(nn',Xf4A',-9,'010',' ',[0 0 21 150])
-->plot2d3('onn',nn',Xf4A',1,'011',' ',[0 0 21 150])
-->xtitle('Symmetric Fourier coefficients - odd number','w','|X(w)|')
The signal is generated with the following call to function dft. We replace the resulting signal,
which may still contain negligible imaginary components, with its real part only, and plot the
results as follows:
SCILAB’s fast Fourier transform function fft is called in a similar manner as dft. The general
call to the function is
[xf]=fft(x,flag);
where x is an input vector which may represent signal data (xr, r = 0,1,…,n-1) or Fourier
transform coefficients (Xk, k = 0,1, …, n-1), and flag determines whether to perform a discrete
transform (flag=-1) or an inverse discrete transform (flag=1). As with function dft, the
function returns a vector containing either the discrete Fourier transform coefficients, Xk, if
flag = -1, or the signal values, xr, if flag = 1.
Note: while the FFT algorithm was developed for data sets containing 2m, m=integer, data
points, the SCILAB function fft has no restriction with respect to the size of the sample used.
The discrete Fourier transform and a graph of the magnitude of the transform coefficients is
shown next:
-->Xf1=fft(xs1,-1);
-->Xf1A=abs(Xf1);
-->plot(Xf1A,'w','|X(w)|')
To generate a real signal out of a vector of Fourier transform coefficients we use the following
approach so that the vector of coefficients presents the symmetry characteristics defined
earlier. We will use a vector of coefficients with 201 components:
-->m=100;X0 = int(200*(rand(1,m)-0.5))+%i*int(100*(rand(1,m)-0.5));
-->n=201;Xf2 = [50 X0 zeros(1,m)];
-->for j=2:n/2+1, Xf2(n-j+2)=conj(Xf2(j)); end;
-->Xf2A=abs(Xf2);
-->plot2d3('onn',[1:1:201]',Xf2A')
-->xtitle('Symmetric Fourier coefficients','k','|X(k)|')
Although the plot of the magnitude of the coefficients seems random, if you observe the graph
carefully you will see the symmetry of the coefficients about the middle point.
The following call to function fft produces the signal. A plot of the real part of the signal is
also shown:
-->xs2=fft(Xf2,1);
-->xs2=fft(Xf2,1);xs2=real(xs2);plot(xs2,'r','x(r)','Real signal from IFFT')
n1 −1 n2 −1
1 k ⋅r m⋅s
Z km =
n1 n2
∑∑y
r =0 s =0
rs exp[−i ⋅ 2π (
n1
+
n2
)],
for k=0,1,2,…,n1-1 and m=0,1,2,…,n2-1. On the other hand, the two-dimensional inverse
Fourier transform will produce the values yrs according to
n1 −1 n2 −1
k ⋅r m⋅s
z rs = ∑ ∑ Ykm ⋅ exp[−i ⋅ 2π ( + )],
r =0 s =0 n1 n2
Example of FFT applications: Obtaining the discrete Fourier transform for a two-dimensional
signal
We will generate a two-dimensional signal by defining the following function, which involves a
random component. A plot of such signal is shown next:
-->deff('[w]=f(x,y)','w=sin(x)*cos(y) + (rand()-0.5)')
-->x=[-6:0.5:6];y=x;z=feval(x,y,f);
-->plot3d(x,y,z)
-->Z = fft(z,-1);ZA=abs(Z);
-->hist3d(ZA)
The figure depicting the magnitudes of the Fourier transform coefficients show four
components that tower above the remaining set of components. There is indeed only one
major component, the one shown located closest to the origin (0,0). The other three
components are simply reflections of the major component about of lines of symmetry located
in the middle of the ranges of X and Y in the figure. This property of the two-dimensional
Fourier transform of a real signal follows, as in the one-dimensional case, from the fact that
Fourier transforms assume a certain periodicity in the independent variables of the function.
In order to obtain a real two-dimensional Fourier transform, the matrix of values Zkm must
satisfy certain symmetry conditions. For the case in which the n1× n2 matrix of coefficients for
the Fourier transform is such that both n1 and n2 are even, the values Z(1,1), Z(n1/2+1,1),
Z(1,n2/+1), and Z(n1/2+1,n2/2+1) must always be real. The remaining elements of matrix Z are
such that Z(n1-k+1,1) = Z(k,1), for k = 1,2,…,n1/2, Z(1,n2-m+1) = Z(1,m+1), for m = 1,2,…,n2,
and Z(n1-k+1,n2-m+1) = Z(k,m), for k = 1,2,…,n1, m = 1,2,…,n2, whereZ represents the
complex conjugate of Z.
n1=16;n2=16; Z=zeros(n1,n2);
for i = 1:n1
for j = 1:n2
Z(i,j) = (int(100*((rand()-0.5)+%i*(rand()-0.5))));
end;
end;
for i = 2:n1/2
Z(n1-i+2,1) = conj(Z(i,1));
end;
for j = 2:n2/2
Z(1,n2-j+2) = conj(Z(1,j));
end;
for i = 2:n1
for j = 2:n2
Z(n1-i+2,n2-j+2) = conj(Z(i,j));
end;
end;
Z(1,1) = 10; Z(n1/2+1,1) = 5.0; Z(1,n2/2+1) = 3.0;
Z(n1/2+1,n2/2+1) = 2.0;
x=[1:1:n1]; y=[1:1:n2];
xset('window',1);plot3d(x,y,abs(Z));
xtitle('Magnitude of Fourier transform coefficients');
z=fft(Z,1);
xset('window',2);plot3d(x,y,real(z));
xtitle('Real signal generated with fft');
To run the script use function exec. Thus, if the script is stored in SCILAB’s current working
directory, you would use:
-->exec(‘Zgen’)
The results are the following two graphs, the first one showing a plot of the magnitude of the
Fourier series coefficients and the second one showing the signal generated with function fft:
1 1 2 n2
∫ x ⋅ J n2 (λ ⋅ x)dx = λ + − ⋅ λ
2
n
J ' ( ) (1 ) J ( ) .
λ2
n
0 2
[2]. Verify the following formulae using Bessel functions of the second kind, Yn(x), for values of
n = 2, 3, and 4 by plotting both sides of the equations in the same set of graphs for 0<x<1.
1 dn 2
Pn ( x) = ( x − 1) n .
2 ⋅ n! dx
n n
[4]. Verify the following recurrence formula for Legendre polynomials for n = 2, 3, 4, by
plotting both sides of the equation in the same set of axes for 0<x<1.
2n + 1 n
Pn +1 ( x) = xPn ( x) − Pn −1 ( x).
n +1 n +1
For problems [5] through [14] generate a table showing the calculation of the integral of f(x)
between the limits x=a and x=b using Gaussian quadrature for values of n = 2,3,4,…,20.
For problems [15] through [19] use Gauss-Laguerre quadrature to obtain the integral of the
functions f(x) in the interval [0,∞).
For problems [20] through [24] use Gauss-Hermite to obtain the integral of the functions f(x) in
the interval (-∞,∞).
For problems [25] through [29] use Filon’s formulae to calculate the integral of the functions
f(x)⋅ cos(kx) and f(x)⋅ cos(kx) between the integration limits x=a and x=b:
[30]. Verify, using SCILAB, that Hermite polynomials satisfy the following formula:
∞ 0, m ≠ n
∫ e − x H m ( x) H n ( x)dx = n
2
−∞
2 n! π , m = n
Use values of (n,m) = (2,3) and (n,m) = (3,3).
[31]. Verify, using SCILAB, that Laguerre polynomials are orthogonal in the range [0,∞) with
respect to the function e-x ,i.e., verify that
∞
∫0
e − x Lm ( x) Ln ( x)dx = 0
[32]. (a) Verify that the second-order, ordinary differential equation, y”+λy = 0, with boundary
conditions y(0) = 0, y(1) = 0, is a Sturm-Liouville system. (b) Find the eigenvalues, λ, of the
system by first obtaining a general solution of the equation and replacing the boundary
conditions in this solution. (c) Find the corresponding eigenfunctions. (d) Verify that the
eigenfunctions are orthogonal in the interval [0,1].
[33]. Determine and plot the sine series corresponding to the following functions:
f(x) = 4, 0<x<2, and f(x) = -4, 2<x<4, period L = 4
f(x) = -x2, - 4 < x < 0, and f(x)= x2, 0 < x < 4, period L = 8
f(x) = sin(x2+x/2), 0 < x < 5, period L = 5
f(x) = 2 - x, 0 < x < 4, and f(x) = x - 6, 4 < x < 8, period L = 8
[34]. Determine and plot the cosine series corresponding to the functions of problem [33].
[35]. Determine and plot the Fourier series corresponding to the functions of problem [33].
[37]. Solve the following differential equation replacing the function f(x) with the Fourier
series of problem [16]. Plot the solution for 0 < x < 4L, where L is the period of the function as
specified in problem [16]. Use as initial conditions y(0) = 0, y’(0) = ½:
d 2 y 1 dy 1
+ + y = f ( x).
dx 2 3 dx 2
d2y
+ y = f ( x).
dx 2
[39]. Solve the following differential equation replacing the periodic signals f(t), of period T =
4, shown in the figure below with their corresponding Fourier series. Plot the solution for 0 < t
< 20. Use as initial conditions, x(0) = 1/3, x’(0) = -1:
d 2 x dx
+ + x = f (t ).
dt 2 dt
[40]. SCILAB’s function rand can be used to generate random numbers that have a uniform
distribution in [0,1]. Use the following commands to generate 1000 random numbers uniformly
distributed in [-0.5,0.5]:
-->rand(‘uniform’); dx = rand(1,1000)-0.5;
The vector dx now contains those random numbers. A plot of the signal dxk vs. k, for k =
1,2,…1000, represents what is commonly known as random noise or white noise (reference to
the frequency contents of white light in the electromagnetic spectrum).
for k = 1,2, …, 999. The signal thus generated, xk, represents what is known as a fractal
Brownian signal.
(a) Obtain and plot the magnitude of the Fourier transform coefficients, |DX(k)|, for the
white noise signal dx. What can be said about the dependence of |DX(k)|, on k, k =
1,2,…,1000?
(b) Obtain and plot the magnitude of the Fourier transform coefficients, |X( ω)|, for the
fractal Brownian signal x. . What can be said about the dependence of |DX(k)|, on k, k
= 1,2,…,1000?
[41]. Repeat problem [40] using a normally distributed set of random numbers with function
rand. Use the following SCILAB commands to generate signal dx:
-->rand(‘normal’); dx = rand(1,1000)-0.5;
[42]. Fractal signals are characterized by having Fourier transform coefficients that vary
inversely with the frequency, i.e., |X(k)| = b/k, where b = constant. Generate and plot a real
signal x(t) corresponding to 1000 Fourier transform coefficients given by |X(k)| = b/k, for k =
1,2,…,1000, and b = 100. Is the signal generated similar in shape to signal x generated in
problems [40] and [41]?
and ranges of values of [-2:0.1:2] in x and y. Obtain and plot the two-dimensional Fourier
transform using (a) a three-dimensional histogram, and (b) a surface plot.
Arora, J.S., 1985, "Introduction to Optimum Design," Class notes, The University of Iowa, Iowa City, Iowa.
Asian Institute of Technology, 1969, "Hydraulic Laboratory Manual," AIT - Bangkok, Thailand.
Berge, P., Y. Pomeau, and C. Vidal, 1984,"Order within chaos - Towards a deterministic approach to turbulence," John
Wiley & Sons, New York.
Bras, R.L. and I. Rodriguez-Iturbe, 1985,"Random Functions and Hydrology," Addison-Wesley Publishing Company,
Reading, Massachussetts.
Brogan, W.L., 1974,"Modern Control Theory," QPI series, Quantum Publisher Incorporated, New York.
Browne, M., 1999, "Schaum's Outline of Theory and Problems of Physics for Engineering and Science," Schaum's
outlines, McGraw-Hill, New York.
Farlow, Stanley J., 1982, "Partial Differential Equations for Scientists and Engineers," Dover Publications Inc., New
York.
Friedman, B., 1956 (reissued 1990), "Principles and Techniques of Applied Mathematics," Dover Publications Inc., New
York.
Gomez, C. (editor), 1999, “Engineering and Scientific Computing with Scilab,” Birkhäuser, Boston.
Gullberg, J., 1997, "Mathematics - From the Birth of Numbers," W. W. Norton & Company, New York.
Harman, T.L., J. Dabney, and N. Richert, 2000, "Advanced Engineering Mathematics with MATLAB® - Second edition,"
Brooks/Cole - Thompson Learning, Australia.
Harris, J.W., and H. Stocker, 1998, "Handbook of Mathematics and Computational Science," Springer, New York.
Hsu, H.P., 1984, "Applied Fourier Analysis," Harcourt Brace Jovanovich College Outline Series, Harcourt Brace
Jovanovich, Publishers, San Diego.
Journel, A.G., 1989, "Fundamentals of Geostatistics in Five Lessons," Short Course Presented at the 28th International
Geological Congress, Washington, D.C., American Geophysical Union, Washington, D.C.
Julien, P.Y., 1998,”Erosion and Sedimentation,” Cambridge University Press, Cambridge CB2 2RU, U.K.
Keener, J.P., 1988, "Principles of Applied Mathematics - Transformation and Approximation," Addison-Wesley
Publishing Company, Redwood City, California.
Koch, G.S., Jr., and R. F. Link, 1971, "Statistical Analysis of Geological Data - Volumes I and II," Dover Publications,
Inc., New York.
Korn, G.A. and T.M. Korn, 1968, "Mathematical Handbook for Scientists and Engineers," Dover Publications, Inc., New
York.
Kottegoda, N. T., and R. Rosso, 1997, "Probability, Statistics, and Reliability for Civil and Environmental Engineers,"
The Mc-Graw Hill Companies, Inc., New York.
Kreysig, E., 1983, "Advanced Engineering Mathematics - Fifth Edition," John Wiley & Sons, New York.
Lindfield, G. and J. Penny, 2000, "Numerical Methods Using Matlab®," Prentice Hall, Upper Saddle River, New Jersey.
Magrab, E.B., S. Azarm, B. Balachandran, J. Duncan, K. Herold, and G. Walsh, 2000, "An Engineer's Guide to
MATLAB®", Prentice Hall, Upper Saddle River, N.J., U.S.A.
McCuen, R.H., 1989,”Hydrologic Analysis and Design - second edition,” Prentice Hall, Upper Saddle River, New Jersey.
Middleton, G.V., 2000, "Data Analysis in the Earth Sciences Using Matlab®," Prentice Hall, Upper Saddle River, New
Jersey.
Newland, D.E., 1993, "An Introduction to Random Vibrations, Spectral & Wavelet Analysis - Third Edition," Longman
Scientific and Technical, New York.
Nicols, G., 1995, “Introduction to Nonlinear Science,” Cambridge University Press, Cambridge CB2 2RU, U.K.
Parker, T.S. and L.O. Chua, , "Practical Numerical Algorithms for Chaotic Systems,” 1989, Springer-Verlag, New York.
Peitgen, H-O. and D. Saupe (editors), 1988, "The Science of Fractal Images," Springer-Verlag, New York.
Peitgen, H-O., H. Jürgens, and D. Saupe, 1992, "Chaos and Fractals - New Frontiers of Science," Springer-Verlag, New
York.
Press, W.H., B.P. Flannery, S.A. Teukolsky, and W.T. Vetterling, 1989, “Numerical Recipes - The Art of Scientific
Computing (FORTRAN version),” Cambridge University Press, Cambridge CB2 2RU, U.K.
Raghunath, H.M., 1985, "Hydrology - Principles, Analysis and Design," Wiley Eastern Limited, New Delhi, India.
Recktenwald, G., 2000, "Numerical Methods with Matlab - Implementation and Application," Prentice Hall, Upper
Saddle River, N.J., U.S.A.
Rothenberg, R.I., 1991, "Probability and Statistics," Harcourt Brace Jovanovich College Outline Series, Harcourt Brace
Jovanovich, Publishers, San Diego, CA.
Sagan, H., 1961,"Boundary and Eigenvalue Problems in Mathematical Physics," Dover Publications, Inc., New York.
Spanos, A., 1999,"Probability Theory and Statistical Inference - Econometric Modeling with Observational Data,"
Cambridge University Press, Cambridge CB2 2RU, U.K.
Spiegel, M. R., 1971 (second printing, 1999), "Schaum's Outline of Theory and Problems of Advanced Mathematics for
Engineers and Scientists," Schaum's Outline Series, McGraw-Hill, New York.
Tanis, E.A., 1987, "Statistics II - Estimation and Tests of Hypotheses," Harcourt Brace Jovanovich College Outline
Series, Harcourt Brace Jovanovich, Publishers, Fort Worth, TX.
Tinker, M. and R. Lambourne, 2000, "Further Mathematics for the Physical Sciences," John Wiley & Sons, LTD.,
Chichester, U.K.
Tolstov, G.P., 1962, "Fourier Series," (Translated from the Russian by R. A. Silverman), Dover Publications, New York.
Tveito, A. and R. Winther, 1998, "Introduction to Partial Differential Equations - A Computational Approach," Texts in
Applied Mathematics 29, Springer, New York.
Urroz, G., 2000, "Science and Engineering Mathematics with the HP 49 G - Volumes I & II", www.greatunpublished.com,
Charleston, S.C.
Urroz, G., 2001, "Applied Engineering Mathematics with Maple", www.greatunpublished.com, Charleston, S.C.