

1==1;
# testing order of local error (rzad schematu)

#order of scheme  for a model initial value problem 
#dx/dt=x x(0)=1 solution x(t)=exp(t)

#vector field
function y=f1(x,t)
y=x;
endfunction

sol=@(x) exp(x);

#explicit Euler
tt=[0.1,1,10,100];
for t=tt,
 er=1.0; 
 h=0.5;
 for k=1:10,  
  erp=er; #previous error
  er=abs(sol(t+h)-sol(t)-h*f1(sol(t),t)); #local error
  printf("[%2d] t=%7.2g h=%8.3g Er=%10.3g RelE=%10.3g",k,t,h,er,er/sol(t));
  if (k>1) 
    printf("   ratio %g\n",erp/er);
  else printf("\n");
  endif
   h*=0.5;
 endfor
endfor 
#Please note that for large or small values of sol(t) we are really interested in
#the relative local error (the 4th column - RelE)
