% TP4
%-----
function u = corde_vib(nx,nt,c,m)
% on choisira c=10
 L = 4;
 T = 2;
 ht = 2./(nt+1);
 hx = 4./(nx+1);

 % Matrice du pb
 alpha0 = -(c*ht)^2;
 A1 = 1./L^2*Laplacien1D(nx);
 B1 = 2*speye(nx)+alpha0*A1;

% C.L.:
 u0 = zeros(nx,1);
 u1 = zeros(nx,1);
 for j = 1:nx
     u0(j) = 2*sin(3*pi*j*hx/2)*cos(j*hx*pi/2);
     u1(j) = u0(j);     
 end
 
% Calcul de Um:
 for iter = 1:m
     u = B1*u1 - u0;
     u0 = u1;
     u1 = u;
 end   
display('u(20)=:');
 u(20)
  
% r=corde_vib(159,798,10,798);
