>> From: "Doc. RNDr. Pavel Hruka CSc."
>> From: Chuck Baker
| I have developed a Fourier series of the following function with a period
| of 2pie.
|
| 0, -pie < x < -pie/2
| f(x) = 1, -pie/2 < x < pie/2
| 0, pie/2 < x < pie
|
| I derived the following answer by hand:
| F(x) = 1/2 + 2/pie(cos x - 1/3 cos3x + 1/5 cos5x +....)
The following procedure evaluates the Fourier series up to n*x term:
> Fourier_series:=proc(func,xrange::name=range,n::posint)
> local x,a,b,l,k,j,p,q,partsum;
> a:=lhs(rhs(xrange));
> b:=rhs(rhs(xrange));
> l:=b-a;
> x:=2*Pi*lhs(xrange)/l;
> partsum:=1/l*int(func,xrange);
> for k to n do
# terms of Fourier series:
>
partsum:=partsum+2/l*int(func*sin(k*x),xrange)*sin(k*x)+2/l*int(func*cos(k*x),xr
ange)*cos(k*x);
> end do;
> partsum;
> end proc:
#Your function:
> f:= x->piecewise(x<-Pi/2,0,x<Pi/2,1,x<Pi,0):
# Result:
> Fourier_series(f(x),x=-Pi..Pi,6);
2 cos(x) cos(3 x) 2/5 cos(5 x)
1/2 + -------- - 2/3 -------- + ------------
Pi Pi Pi
All the best
---------------------------------------------------------
Doc. RNDr. Pavel Hruka, CSc. Tel. 5/4114 3257
Ustav Fyziky FEI VUT Fax. 5/4114 3133
Technicka 8, 616 00 Brno Zazn.5/4114 3391
---------------------------------------------------------
|