function Ch2Example5(N,a,b)
%
% Solves the bvp y_{n+1}- 10.1y_{n} +  y_{n-1} =0
%  y_0=a, y_N=b
% 
%
fprintf('\n')
disp('_____________________________________________________________________________')
disp('     i        y_n            yclosed          abs error        rel error    ')
disp('_____________________________________________________________________________')%
N1=N+1;
ye=zeros(1,N1);
yr=zeros(1,N1);
A=(b-a*10^(-N))/(10^N-10^(-N));
B=a-A;
ye(1,1:N1)=A*10.^(0:N)+B*(1/10).^(0:N);
%
yr(1,1)=a;yr(1,N+1)=b;
rhs=zeros(N-1,1);sol=zeros(N-1,1);
rhs(1,1)=-yr(1,1);
rhs(N-1,1)=-yr(1,N+1);
M=zeros(N-1,N-1);
M=gallery('tridiag',N-1,1,-10.1,1);
sol=M\rhs;
yr(1,2:N)=sol(1:N-1,1);
%
for i=1:N1
fprintf(' %5.0f  %15.6e  %15.6e  %15.6e  %15.6e\n',i-1,yr(1,i),ye(1,i),...
    abs(yr(1,i)-ye(1,i)),abs((yr(1,i)-ye(1,i)))/abs(ye(1,i)))
end
xx=zeros(1,N1);
xx(1,1:N1)=(0:N);
plot(xx,ye,'r*',xx,yr,'b+')
xlabel('n','Fontsize',14);ylabel('y_n','Fontsize',14);
legend('Recurrence','Closed form',1)
