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

%% 
syms x n
%% (1)

f = symsum((-1)^(n)*sin((2*n-1)*x),n,1,50)
F = @(x) pi/4
%%
ezplot(f,[-pi/2,pi/2])
%%
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,[-pi/2,pi/2])
hold on
ezplot(G,[-pi/2,pi/2])
hold off
axis([-pi/2,pi/2,-1.3,1.3])

%% (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,pi])
hold on
ezplot(K,[0,2])
hold off
