%3x_{n+1}-10x_{n}+3x_{n-1}=0
%x_{0}=1, x_{1}=1/3, x_{2}=1/9
%x_{n}=(1/3)^n

%2x_{n+1}-5x_{n}+2x_{n-1}=0
%x_{0}=1, x_{1}=1/2, x_{2}=1/4
%x_{n}=(1/2)^n



clear all;
nk=60;
zad=1;
switch zad
  case 0
x=[1,1/3.0];
xr1=1; xr2=1.0/3;
for n=1:nk
  xr=(10*xr2-3*xr1)/3.0;
  xr1=xr2;
  xr2=xr;
  x=[x,xr2];
endfor
xn=[x(nk+2),x(nk+1)];
xr1=xn(1);xr2=xn(2);
for n=nk:-1:1
  xr=(10*xr2-3*xr1)/3.0;
  xr1=xr2;
  xr2=xr;
  xn=[xn,xr2];
endfor

case 1
x=[1,1/2.0];
xr1=1; xr2=1.0/2.0;
for n=1:nk
  xr=(5*xr2-2*xr1)/2.0;
  xr1=xr2;
  xr2=xr;
  x=[x,xr2];
endfor
xn=[x(nk+2),x(nk+1)];
xr1=xn(1);xr2=xn(2);
for n=nk:-1:1
  xr=(5*xr2-2*xr1)/2.0;
  xr1=xr2;
  xr2=xr;
  xn=[xn,xr2];
endfor
endswitch