%code 2.2 for lecture 2; need u_0(x), u_L(t), u_R(t)

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

    for N=2:10
   
    cc=[2 ones(1, N-1) 2];
 
    j=[0:1:N];  x=[cos(j*pi/N)];  u=epp*(x+tan(0.5*x));

     time=0.0;

    while time < T 

       guo=1+epp*time;
       u(1)=(epp/guo)*(x(1)+tan(0.5*x(1)/guo));
       u(N+1)=(epp/guo)*(x(N+1)+tan(0.5*x(N+1)/guo));
       
       rhs=codeExp_2RHS(u,N,cc,epp);

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

       time=time+dt;

    end

%exact solution

       ss1=T
       ss2=time

       guo=1+epp*T;
       exact=(epp/guo)*(x+tan(0.5*x/guo));
       error=abs(exact-u);

       error(1)=0;  error(N+1)=0;

       xx(N)=N;
       err(N)=max(error);
       ss=max(error)
       end
  
    fprintf(1,      '%9.0f          %12.8f  \n', [xx;  err]);
