Off[General::spell1];
Clear[RungeKutt ,f0,a,b,x0,n];
RungeKutt[f0_,a_,b_,x0_,n_] :=
Module[{f,h,j,F1,F2,F3,F4,T,X},
  Set@@{f[t_,x_],f0};
  h = (b - a)/n //N;
  T = Table[0,{n+1}];
  X = Table[0,{n+1}];
  T[[1]] = a //N;
  X[[1]] = x0 //N;
  For[j=1, j<=n,j++,
    F1 = h f[T[[j]],X[[j]]] //N;
    F2=h f[T[[j]]+h/2,X[[j]]+F1/2]//N;
    F3=h f[T[[j]]+h/2,X[[j]]+F2/2]//N;
    F4=h f[T[[j]]+ h, X[[j]]+F3] //N;
    X[[j+1]] = X[[j]] + (F1 + 2 F2 +
         2 F3 + F4)/6 //N;
    T[[j+1]] = a + h j //N];
 Return[Transpose[{T,X}]] ];
On[General::spell1];

Clear[f,t,x];   
f[t_,x_] = Cos[t] - Sin[x] +t^2;

RungeKutt[f[t,x],-1,1,3,10]

Clear[pts];
pts = RungeKutt[f[t,x],-1,1,3,200];
ListPlot[pts,PlotJoined->True, AspectRatio -> 0.5];

Clear[ss];
ss=NDSolve[{x'[t]==f[t,x[t]],
    x[-1]==3},x[t],{t,-1,1}];
Plot[Evaluate[x[t]/.ss],
 {t,-1,1},AspectRatio -> 0.5];

Clear[xx];
xx[t_]= x[t] /. First[ss];
Error = Table[pts[[i,2]]-
  xx[-1+ (i-1) /100], {i,1,10}]

Error = Table[pts[[i,2]]-
  xx[-1+ (i-1) /100], {i,190,200}]

Clear[f,t,x];
f[t_,x_] = (t *x - x^2) / t^2;

Clear[pts];
pts = RungeKutt[f[t,x],1,3,2,200 ];
ListPlot[pts,PlotJoined->True, AspectRatio -> 1];

Clear[ss,xx];
ss=DSolve[{x'[t]==f[t,x[t]],x[1]==2},x[t],t];
xx[t_]= x[t] /. First[ss]

Plot[xx[t], {t, 1,3},AspectRatio -> 1]

Error1 = Table[pts[[i,2]]-
   xx[1+ (i-1) /100], {i,1,10}]//N

Error2=Table[pts[[i,2]]-
 xx[1+ (i-1) /100], {i,90,100}]//N