Runge Kutta 4Th Order: Input Program & Result
Runge Kutta 4Th Order: Input Program & Result
Table of Contents
INPUT .............................................................................................................................. 1
PROGRAM & RESULT ...................................................................................................... 1
SOLVER ........................................................................................................................... 1
INPUT
SC_RK4(@(x,y)x+y,0,1,2,0.5)
n=(xn-x0)/h;
for i=1:1:n
s1=h*feval(fun,x0,y0);
s2=h*feval(fun,x0+(h/2),y0+(s1/2));
s3=h*feval(fun,x0+(h/2),y0+(s2/2));
s4=h*feval(fun,x0+h,s3);
s=(s1 + 2*s2 + 2*s3 + s4)/6;
y0=y0+s;
x0=x0+h;
end
SOLVER
[x,y]=ode45(@(x,y)x+y,[0:0.5:2],1)
x =
0
0.5000
1.0000
1.5000
2.0000
y =
1
RUNGE KUTTA 4TH ORDER
1.0000
1.7974
3.4366
6.4634
11.7781