You are on page 1of 2

RUNGE KUTTA 2ND ORDER

Table of Contents
INPUT .............................................................................................................................. 1
PROGRAM & RESULT ...................................................................................................... 1
SOLVER ........................................................................................................................... 1

Name: Shubham Chapparghare Roll no.: 351013

INPUT
SC_RK2(@(x,y)x+y,0,1,2,0.5)

PROGRAM & RESULT


function[]=SC_RK2(fun,x0,y0,xn,h)

n=(xn-x0)/h;
for i=1:1:n
s1=h*feval(fun,x0,y0);
s2=h*feval(fun,x0+h,y0+s1);
s=(s1+s2)/2;
y0=y0+s;
x0=x0+h;
end
fprintf('The value obtained is: %f\n',y0);

The value obtained is: 10.945801

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.0000
1.7974
3.4366

1
RUNGE KUTTA 2ND ORDER

6.4634
11.7781

Published with MATLAB® R2017a

You might also like