function gibbs_anim

     nn = 1000;
     m = 10;

     x = [0.8:0.2/nn:1];

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

     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

        if (i==m) 
           h = plot(x,S,'b-');
           set(h,'LineWidth',2);
        else
           h = plot(x,S,'b--');        
           set(h,'LineWidth',1);
        end

        [SS ii] = max(S);
        h=plot(x(ii),S(ii),'m*');
        set(h,'LineWidth',4);
        h=plot(x(3*nn/4),S(3*nn/4),'rd');
        set(h,'LineWidth',4);

        pause;
     end

     h=plot(x,1.175*x,'k--');
     set(h,'LineWidth',2);
     hold off;
     
     