clear;
clf;
format short;
x0=1;
ta=1;
x(1)=x0;
alpha=2/3;
beta=1-alpha;
w2=1/(2*alpha);
w1=1-w2;
n=2;
for k=1:50
   dt=ta/n;
   x(1)=x0;
   xp(1)=x0;
   step(1)=1;
   t(1)=0;
   for i=1:n
      step(i+1)=i+1;
      t(i+1)=t(i)+dt;
      F1=dt*dfungsi(x(i),0);
		F2=dt*dfungsi((x(i)+(beta*F1)),(alpha*dt));
      x(i+1)=x(i)+(w1*F1)+(w2*F2);
      xp(i+1)=x(i)+F1;
   end
   clc
   klik=n
   xta(n)=x(n+1);
   xpa(n)=xp(n+1);
   if (abs(xta(n)-xpa(n)))<0.000001
      break
   else
      n=2*n;
   end
end
plot(t,x,t,xp), grid on
interval=n
hasil=[step']
persenerror=100*abs((x(n+1)-exp(-1))/exp(-1))