% randv; bandmatrismetoden, y" = (6-y)x;  y(0)=1;  y(4)=-1
  clear, clf
  xslut=4;  
  y0=1;  yslut=-1;
  subplot(2,2,1), plot([0 xslut],[0 0]), hold on
  title('y"=(6-y)x,  y(0)=1, y(4)=-1 ')
% testa ntot = 10, 20, 40, 80
  ntot=20; ntab=5;                % ntot = antal intervall
  Ytab=[];
  for nr=1:4 
    n=ntot-1;                     % antal obekanta yvarden             
    h=xslut/ntot; x=h*(1:n)';
    dia=-(2-h^2*x); 
    sup=ones(n-1,1); sub=sup;
    b=6*h^2*x; 
    b(1)=b(1)-y0; b(n)=b(n)-yslut;
    y=tridia(dia,sup,sub,b);
    X=[0; x; xslut]; Y=[y0; y; yslut]; 
    Ytab=[Ytab Y(1:ntab:ntot+1)];
    plot(X,Y), drawnow 
    ntot=2*ntot; ntab=2*ntab;
  end
  Xtab=(0:4)';
  disp('     x         n=20      n=40      n=80      n=160')  
  disp([Xtab Ytab])



