h=0.1 ; %timestep Tmax=1; tlist=linspace(0,Tmax,Tmax/h +1) ; xlist=zeros(1,length(tlist)); %initialize x0=1; xlist(1)=x0; for n=1:length(tlist)-1 xlist(n+1)=xlist(n) + h/2*xlist(n) + h/2*(xlist(n) + h*xlist(n)) ; end figure set(gca,'FontSize',16) plot(tlist,xlist,'o','MarkerSize',16); hold on tlistfine=linspace(0,Tmax,10000); plot(tlistfine,exp(tlistfine),'LineWidth',2); %exact solution x=exp(t) xlabel('t','Fontsize',20); ylabel('x(t)','Fontsize',20); legend('Heun Approx','Exact Solution')