%% Examples from worksheet "Fourier's work, I"
%
%

syms x n

%
%% (1)

f = symsum((-1)^(n-1)*cos((2*n-1)*x)/(2*n-1),n,1,50)
F = @(x) pi/4

ezplot(f,[-pi,pi])
hold on
ezplot(F,[-pi,pi])
hold off
axis([-pi,pi,-1,1])

%
%% (2)

g = symsum((-1)^(n-1)*sin((2*n-1)*x)/(2*n-1)^2,n,1,5)
G = @(x) pi*x/4

ezplot(g,[0,pi/2])
hold on
ezplot(G,[0,pi/2])
hold off


%
%% (3)

h = symsum(sin((2*n-1)*x)/(2*n-1),n,1,50)
ezplot(h,[0,pi])

hold on
ezplot(F,[0,pi])
hold off
axis([0,pi,0,1])

%
%% (4)

k = symsum((-1)^(n-1)*sin(n*x)/n,n,1,50)
K = x/2

ezplot(k,[0,2*pi])
hold on
ezplot(K,[0,2*pi])
hold off
axis([0 2*pi -pi pi])