Contoh Program Mencari Solusi Persamaan
Differensial, diketahui dx(t)/dt=f(x(t),t)
dan x(0)=xo, dicari x(T)
Di sini dx(t)/dt = f(x(t),t) diletakkan
di function dfungsi. x(0)=1 dan T=1.
x(T) dicari dengan membagi n interval.	n	x(i)	
clear;
clf;
%Mencari x(1) dengan diketahui
%Persamaan differensial dx(t)/dt= f(x(t),t)
% yang ada pada file dfungsi.m
% dan keadaan awal tertentu
k(1)=1;
% Dari Keadaan awal pembagian 1 interval:
x(1)=1+1*dfungsi(1,0);
for n=2:1000
   dt=1/n;
   xd(1)=1;
   td(1)=0;
   for i=1:n
      td(i+1)=td(i)+dt;
      xd(i+1)=xd(i)+dt*dfungsi(xd(i),td(i));
   end
   k(n)=n;
   x(n)=xd(n+1);
   if (abs(x(n)-x(n-1)))<0.000001
    break
   end
end
N=k
X=x
plot(k,x), grid on   
% Fungsi-nya
function df=dfungsi(x,t)
df=-0.5*x;	1	0.5000	
	2	0.5625	
	3	0.5787	
	4	0.5862	
	5	0.5905	
	6	0.5933	
	7	0.5953	
	8	0.5967	
	9	0.5978	
	10	0.5987	
	11	0.5995	
	12	0.6001	
	13	0.6006	
	14	0.6010	
	...	.........	
	...	.........	
	...	..........	
	271	0.6063	
	272	0.6063	
	273	0.6063	
	274	0.6063	
	275	0.6063	
	276	0.6063	
	277	0.6063	
	BREAK	

0.5000    
0.7500    
0.6944    
0.6699    
0.6561    
0.6472    
0.6410

0.6365    
0.6330    
0.6302    
0.6280    
0.6262    
0.6246    
0.6233

0.6070    
0.6070    
0.6070    
0.6070    
0.6070    
0.6070    
0.6070

Columns 267 through 273 

    0.6062    0.6062    0.6062    0.6062    0.6063    
0.6063    
0.6063
0.6063    
0.6063    
0.6063    
0.6063
Columns 1 through 7 

0.5000    
0.5625    
0.5787    
0.5862    
0.5905    
0.5933    
0.5953

  Columns 8 through 14 

0.5967    
0.5978    
0.5987    
0.5995    
0.6001    
0.6006    
0.6010

  Columns 15 through 21 

    0.6014    0.6017    0.6020    0.6023    0.6025    0.6027    0.6029

  Columns 22 through 28 

    0.6030    0.6032    0.6033    0.6035    0.6036    0.6037    0.6038

  Columns 29 through 35 

    0.6039    0.6040    0.6041    0.6041    0.6042    0.6043    0.6043

  Columns 36 through 42