%code1 for lecture 2; need u_0(x) and f(x, t)

    dt=input('  dt=  ');
    T=input(  'T=  ');

  for N=2:10
   
    cc=[2 ones(1, N-1) 2];

%initial condition 
    j=[0:1:N];  x=[cos(j*pi/N)];  u=sin(pi*x);

     time=0.0;

     while time <= T 

       rhs=codeExp_RHS(u,N,cc);

       for j=2:N
          u(j)=u(j)+dt*rhs(j);
       end

       time=time+dt;

     end
%exact solution

       exact=exp(-pi^2*time)*sin(pi*x); error=abs(exact-u);

       xx(N)=N;
       err(N)=max(error);
       
       ss=max(error)

  end
  
  fprintf(1,      '%9.0f          %15.11f  \n', [xx;  err]);
