Fourier Polynomials Period 2NiMlI1BpRw== over the interval [NiMsJCUjUGlHISIi, NiMlI1BpRw==]. restart:with(plots): We begin by considering the function f:=piecewise(x<-Pi/3,0,x<Pi/3,1,0); over the interval x = NiMsJCUjUGlHISIi..NiMlI1BpRw==, whose plot is below. p:=plot(f,x=-Pi..Pi,thickness=3,discont=true): display(p); We will approximate this function by Fourier polynomials of degrees 1 through 15. n:=15; We first compute the coefficient NiMmJSJhRzYjIiIh = NiMqJiIiIkYkKiYiIiNGJCUjUGlHRiQhIiI= NiMtJSRpbnRHNiQtJSJmRzYjJSJ4Ry9GKTssJCUjUGlHISIiRi0=. a:=(1/(2*Pi))*int(f,x=-Pi..Pi); Next we use a loop to compute the coefficients NiMmJSJhRzYjJSJrRw== = NiMqJiIiIkYkJSNQaUchIiI= NiMtJSRpbnRHNiQqJi0lImZHNiMlInhHIiIiLSUkY29zRzYjKiYlImtHRitGKkYrRisvRio7LCQlI1BpRyEiIkY0 and NiMmJSJiRzYjJSJrRw== = NiMqJiIiIkYkJSNQaUchIiI= NiMtJSRpbnRHNiQqJi0lImZHNiMlInhHIiIiLSUkc2luRzYjKiYlImtHRitGKkYrRisvRio7LCQlI1BpRyEiIkY0 , along with the Fourier polynomials NiMvLSYlIkZHNiMlIm5HNiMlInhHLCgmJSJhRzYjIiIhIiIiLSUkc3VtRzYkKiYmRi02IyUia0dGMC0lJGNvc0c2IyomRjdGMEYqRjBGMC9GNztGMEYoRjAtRjI2JComJiUiYkdGNkYwLSUkc2luR0Y6RjBGPEYw for NiMlIm5H = 1..15. for k from 1 to n do a[k]:=(1/Pi)*int(f*cos(k*x),x=-Pi..Pi); b[k]:=(1/Pi)*int(f*sin(k*x),x=-Pi..Pi); F[k]:=a+sum('a[i]*cos(i*x)','i'=1..k)+sum('b[i]*sin(i*x)','i'=1..k); od; Next we plot NiMtJSJmRzYjJSJ4Rw== along with each of the NiMtJiUiRkc2IyUibkc2IyUieEc= for NiMlIm5H = 1..15. for k from 1 to n do p[k]:=plot(F[k],x=-Pi..Pi,thickness=3,discont=true,color=blue): od: for k from 1 to n do k; display(p,p[k]): od; We see that the successive Fourier polynomials give better and better approximations to NiMtJSJmRzYjJSJ4Rw==. Although they may not be as accurate as Taylor polynomials near a given point, they do a better job of approximating a function over an entire interval. They are especially good for approximating periodic functions. Let's extend NiMtJSJmRzYjJSJ4Rw== by a period in each direction with NiMlInhH = -NiMqJiIiJCIiIiUjUGlHRiU=..NiMqJiIiJCIiIiUjUGlHRiU=. f:=piecewise(x<-7*Pi/3,0,x<-5*Pi/3,1,x<-Pi/3,0,x<Pi/3,1,x<5*Pi/3,0,x<7*Pi/3,1,0); We graph the extention. p:=plot(f,x=-3*Pi..3*Pi,thickness=3,discont=true): display(p); We now plot the extended NiMtJSJmRzYjJSJ4Rw== along with each of the NiMtJiUiRkc2IyUibkc2IyUieEc= for NiMlIm5H = 1..15. for k from 1 to n do p[k]:=plot(F[k],x=-3*Pi..3*Pi,thickness=3,discont=true,color=blue): od: for k from 1 to n do k; display(p,p[k]): od; Period NiMlImJH over the interval [NiMsJComJSJiRyIiIiIiIyEiIkYo, NiMqJiUiYkciIiIiIiMhIiI=]. restart:with(plots): We begin by considering the triangular wave function f:=piecewise(x<-2,0,x<-1,x+2,x<0,-x,x<1,x,x<2,2-x,0); over the interval x = -2..2 with period NiMvJSJiRyIiIw==, whose plot is below. p:=plot(f,x=-2..2): display(p); We will approximate this function by Fourier polynomials of degrees 1 through 15. n:=15; We first compute the coefficient NiMmJSJhRzYjIiIh = NiMqJiIiIkYkJSJiRyEiIg== NiMtJSRpbnRHNiQtJSJmRzYjJSJ4Ry9GKTssJComJSJiRyIiIiIiIyEiIkYxRi0=. a:=(1/2)*int(f,x=-1..1); Next we use a loop to compute the coefficients NiMmJSJhRzYjJSJrRw== = NiMqJiIiIyIiIiUiYkchIiI= NiMtJSRpbnRHNiQqJi0lImZHNiMlInhHIiIiLSUkY29zRzYjKiwiIiNGKyUjUGlHRislImtHRitGKkYrJSJiRyEiIkYrL0YqOywkKiZGM0YrRjBGNEY0Rjg= and NiMmJSJiRzYjJSJrRw== = NiMqJiIiIyIiIiUiYkchIiI= NiMtJSRpbnRHNiQqJi0lImZHNiMlInhHIiIiLSUkc2luRzYjKiwiIiNGKyUjUGlHRislImtHRitGKkYrJSJiRyEiIkYrL0YqOywkKiZGM0YrRjBGNEY0Rjg=, along with the Fourier polynomials NiMvLSYlIkZHNiMlIm5HNiMlInhHLCgmJSJhRzYjIiIhIiIiLSUkc3VtRzYkKiYmRi02IyUia0dGMC0lJGNvc0c2IyosIiIjRjAlI1BpR0YwRjdGMEYqRjAlImJHISIiRjAvRjc7RjBGKEYwLUYyNiQqJiZGPkY2RjAtJSRzaW5HRjpGMEZARjA= for NiMlIm5H = 1..15, keeping in mind that NiMvJSJiRyIiIw== here. for k from 1 to n do a[k]:=int(f*cos(Pi*k*x),x=-1..1); b[k]:=int(f*sin(Pi*k*x),x=-1..1); F[k]:=a+sum('a[i]*cos(Pi*i*x)','i'=1..k)+sum('b[i]*sin(Pi*i*x)','i'=1..k); od; Next we plot NiMtJSJmRzYjJSJ4Rw== along with each of the NiMtJiUiRkc2IyUibkc2IyUieEc= for NiMlIm5H = 1..15. for k from 1 to n do p[k]:=plot(F[k],x=-2..2,color=blue): od: for k from 1 to n do k; display(p,p[k]): od; Again, we see that the successive Fourier polynomials give better and better approximations to NiMtJSJmRzYjJSJ4Rw==.