Clear[FiniteDiff,a,b,alpha,beta,n];
FiniteDiff[a_,b_,alpha_,beta_,n_] :=
Module[{i,h,j,t,a0,b0,c0,d0,X0},
  h  = (b-a)/(n)//N;
  t = Table[a+j*h,{j,n-1}];
  a0 = Table[0,{n-2}];
  c0 = Table[0,{n-2}];
  d0 = Table[1,{n-1}];
  b0 = Table[0,{n-1}];
    For[j=1,j<=n-2,j++,
        a0[[j]] = -1 - h/2 p[t[[j+1]]];  
        c0[[j]] = -1 + h/2 p[t[[j]]]; ]; 
    For[j=1,j<=n-1,j++,
        d0[[j]] = 2 + h^2 q[t[[j]]];  
        b0[[j]] = - h^2 r[t[[j]]]; ]; 
        b0[[1]]  = b0[[1]]  +(1 + h/2 p[t[[1]]]) alpha;
        b0[[n-1]]= b0[[n-1]]+(1 - h/2 p[t[[n-1]]])beta;
  Clear[X0];
  X0 = Table[0,{n-1}];
    For[k=2,k<=n-1,k++,
      Module[{},
        tem = a0[[k-1]]/d0[[k-1]];
        d0[[k]] = d0[[k]] - tem c0[[k-1]];
        b0[[k]] = b0[[k]] - tem b0[[k-1]] ]];
      X0[[n-1]] =  b0[[n-1]]/d0[[n-1]];
    For[k=n -2,1<=k,k--,
      X0[[k]] = (b0[[k]] - c0[[k]] X0[[k+1]])/ d0[[k]] ];
   sol = Table[{0,0},{n+1}];
   For[i=1,i<=n-1,i++, 
      sol[[i+1]] = {t[[i]],X0[[i]]}; ];
      sol[[1]]   = {a,alpha};
      sol[[n+1]] = {b, beta};
  Return[sol]; ]; 
On[General::spell1];

Clear[p,q,r,t];
p[t_] = 0;
q[t_] = 1; 
r[t_] = 0;

Clear[pts]; 
pts = FiniteDiff[0,1,0,1,25];
ListPlot[pts, AxesLabel->{"t","x"}];

ss=DSolve[{x''[t] - x[t] ==0, x[0]==0, x[1]==1},x[t],t];
xx[t_]= x[t] /. First[ss];

Plot[xx[t], {t,0,1}]

Error = Table[pts[[i,2]]-xx[(i-1)/25] //N, {i,1,26}];
Max[Abs[Error]]

Clear[p,q,r,t];
p[t_] = -1/t; 
q[t_] = -(1-1/(4t^2));
r[t_] = Sqrt[t] Cos[t];

Clear[pts]; 
pts = FiniteDiff[1,6,1.0,-0.5,100]; 
ListPlot[pts, PlotRange->{{0,6.2},{-3.2,1.2}},
        AxesLabel->{"t","x"}];

f[t_]=(t Cos[t] +t^2 Sin[t] -4 C Sin[t] +4 C1 Cos[t])/ 
      (4 t^(1/2));
xx[t_] = f[t]/.{C->-2.960284381/4,C1->0.2354853843/4}

Error1 = Table[pts[[i,2]]-xx[1+5(i-1)/100] //N, {i,1,101}];
Max[Abs[Error1]]