# Maple lab 4, Fourier Series. # 2. An orthogonal basis assume(m>=0,m::integer,n>0,n::integer,n != m); int(cos(m*x)*sin(n*x), x=0..2*Pi); # Orthogonal means dot product zero # Zero expected. # 3. Expressing a Vector f(x) in Terms of the Basis # The graph of f is a square wave. f:= x-> piecewise(x<=-Pi ,Pi,x<0,-Pi,x<=Pi,Pi,-Pi): 'f(x)'=convert(f(x),piecewise); plot(f(x), x=-2*Pi..2*Pi, discont=false, thickness=3); # Try plotting the first four different Fourier Sums on the same axes with f: # Fourier sum, one term plot([ f(x),4*sin(x)], x=-2*Pi..2*Pi, discont=false,color=[red,blue], thickness=[3,1]); # Fourier sum, two terms plot([ f(x),4*(sin(x)+(1/3)*sin(3*x))],x=-2*Pi..2*Pi,discont=false, color=[red,blue], thickness=[3,1]); # PROBLEM 3.1. Plot the Fourier sum with three terms # PROBLEM 3.2. Plot the Fourier sum with four terms # 4. Energy Spectrum # The kth harmonic of f(x) is the term a_k cos(kx) + b_k sin(kx). # The energy of the kth harmonic is (a_k)^2 + (b_k)^2. # An even k=2n energy is zero and an odd k=2n + 1 energy is 16/k^2. # PROBLEM 4.1. Show maple details for the first 8 energies. Statistics[ColumnGraph]([0,16/1,0,16/9,0,16/25,0,16/49], width = 0.07, distance = .93); # PROBLEM 4.2. Show maple details for the first 16 energies and remake the plot.