f[t_,y_]:=y^3*t-y*t^3
(*f[t_,y_]:=y*Exp[-(t-3)^2]*)
α=1.;
tA=0.0; tB=1.2;
n=20;
h=(tB-tA)/n;
t[0]=tA;
t[n]=tB;
Do[t[i+1]=t[i]+h,{i,0,n-1}]
w[0]=α;

(* EULERO *)
Do[w[i+1]=w[i]+h*f[t[i],w[i]],{i,0,n-1}];

sol=Table[{t[i],w[i]},{i,0,n}];
solnum=NDSolve[{y'[t]==f[t,y[t]],y[tA]==α},y[t],{t,tA,tB}][[1]];
soltrue=DSolve[{y'[t]==f[t,y[t]],y[tA]==α},y[t],t][[1]]
trange={tA,tB};
yrange={0,10};
pl0=Plot[y[t]/.soltrue,{t,tA,tB},PlotRange->{trange,yrange}];
pl1=ListPlot[sol,PlotRange->{trange,yrange}];
pl2=Plot[y[t]/.solnum,{t,tA,tB},PlotRange->{trange,yrange}];
(*pl3=Plot[y[t]/.soltrue,{t,tA,tB},PlotRange->{trange,yrange},PlotStyle->RGBColor[1,0,0]];*)
Show[pl0,pl1,pl2]

w[n]

ynum[t_]=y[t]/.solnum;
err=Table[{t[i],Abs[ynum[t[i]]-sol[[i+1]][[2]]]},{i,0,n-1}];
pleu=ListPlot[err,PlotStyle->{RGBColor[0,0,0],PointSize[0.02]}];

(* RK2 *)
Do[k1=f[t[i],w[i]];k2=f[t[i]+0.5*h,w[i]+0.5*h*k1];w[i+1]=w[i]+h*k2,{i,0,n-1}];
sol=Table[{t[i],w[i]},{i,0,n}];
solnum=NDSolve[{y'[t]==f[t,y[t]],y[tA]==α},y[t],{t,tA,tB}][[1]];
(*soltrue=DSolve[{y'[t]==f[t,y[t]],y[tA]==α},y[t],t][[1]]*)
trange={tA,tB};
yrange={0,10};
pl1=ListPlot[sol,PlotRange->{trange,yrange}];
pl2=Plot[y[t]/.solnum,{t,tA,tB},PlotRange->{trange,yrange}]
(*pl3=Plot[y[t]/.soltrue,{t,tA,tB},PlotRange->{trange,yrange},PlotStyle->RGBColor[1,0,0]];*)
Show[pl1,pl2]

ynum[t_]=y[t]/.solnum;
err=Table[{t[i],Abs[ynum[t[i]]-sol[[i+1]][[2]]]},{i,0,n-1}];
plrk2=ListPlot[err,PlotStyle->{RGBColor[0,0,1],PointSize[0.02]}]

(* RK4 *)
Do[k1=f[t[i],w[i]];
k2=f[t[i]+0.5*h,w[i]+0.5*h*k1];
k3=f[t[i]+0.5*h,w[i]+0.5*h*k2];k4=f[t[i]+h,w[i]+h*k3];
w[i+1]=w[i]+h*(k1+2*k2+2*k3+k4)/6.,{i,0,n-1}];
sol=Table[{t[i],w[i]},{i,0,n}];
solnum=NDSolve[{y'[t]==f[t,y[t]],y[tA]==α},y[t],{t,tA,tB}][[1]];
(*soltrue=DSolve[{y'[t]==f[t,y[t]],y[tA]==α},y[t],t][[1]]*)
trange={tA,tB};
yrange={0,10};
pl1=ListPlot[sol,PlotRange->{trange,yrange}]
pl3=Plot[y[t]/.solnum,{t,tA,tB},PlotRange->{trange,yrange}];
(*pl3=Plot[y[t]/.soltrue,{t,tA,tB},PlotRange->{trange,yrange},PlotStyle->RGBColor[1,0,0]];*)
Show[pl1,pl3]

ynum[t_]=y[t]/.solnum;
err=Table[{t[i],Abs[ynum[t[i]]-sol[[i+1]][[2]]]},{i,0,n-1}];
plrk4=ListPlot[err,PlotStyle->{RGBColor[1,0,0],PointSize[0.02]}]

plerr20=Show[pleu,plrk2,plrk4]

Show[plerr10,plerr20]