function ex4_5_anim

     nn = 1000;
     m = 6;
     
     x = [-1:1.0/nn:1];

     S = 2.0/pi * sin(pi*x);
     
     for i=1:m

        for j=2^(i-1)+1:2^i
            S = S + 2.0/pi * (-1)^(j+1)/j * sin(j*pi*x);
        end
        
        N = 2^i

        h=plot(x,x,'k-');
        set(h,'LineWidth',2);
        set(gca,'LineWidth',2);
        set(gca,'FontSize',18);
        hold on;
        h=plot(x,S,'b-');
        set(h,'LineWidth',2);
        axis([-1.0 1.0 -1.2 1.2]);
        hold off;

        pause;
     end
