In: Advanced Math
I study mathematics-economics in the second year of a bachelor programme: I’m one month into the course “Analysis I”. I would like to get more familiar with certain subjects. For a reasonable answer for this Q&A, I’d like a formal definition, a simple example/proof and summary of the mentioned subject.
The subject is Fourier series.
%Matlab code for Fourier Series
clear all
close all
%All time values
X=linspace(-pi,pi,1001);
%Loop for creating the function
for i=1:length(X)
if X(i)>=-pi && X(i)<0
zz(i)=-1;%(X(i)).^2;
else
zz(i)=1;%pi^2;
end
end
figure(1)
%Plotting the function
plot(X,zz)
xlabel('x')
ylabel('f(x)')
title('Plotting of Actual data')
a1=X(1); b1=X(end);
l=(b1-a1)/2;
%Fourier series of the function for finding a and b
coefficients
for j=1:200
ss1=zz.*cos(j*pi*X/l);
%all a values of the Fourier series
aa(j)=(1/l)*trapz(X,ss1);
ss2=zz.*sin(j*pi*X/l);
%all b values of the Fourier series
bb(j)=(1/l)*trapz(X,ss2);
end
%a0 value of Fourier series
aa0=(1/l)*trapz(X,zz);
X=linspace(-3*pi,3*pi,6001);
s=aa0/2;
%all an and bn terms
fprintf('Printing few terms for Fourier series\n')
for i=1:10
fprintf('\tThe value of a%d=%f and b%d=%f.
\n\n',i,aa(i),i,bb(i))
end
%Fourier series of the function
for i=1:200
s=s+bb(i)*sin(i*pi*X/l)+aa(i)*cos(i*pi*X/l);
if i==20
figure(2)
plot(X,s)
xlabel('time')
ylabel('f(t)')
title('Fourier series of
given function for 20 terms')
elseif i==200
figure(3)
plot(X,s)
xlabel('time')
ylabel('f(t)')
title('Fourier series of
given function for 200 terms')
end
end
%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%