0% found this document useful (0 votes)
47 views2 pages

Runge Kutta 4Th Order: Input Program & Result

The document describes a 4th order Runge Kutta method for solving ordinary differential equations numerically. It provides an example of using the RK4 method to solve the ODE dx/dt = x + y with initial conditions x=0, y=1 on the interval [0,2]. It also shows solving the same problem using MATLAB's ode45 solver for comparison.

Uploaded by

YASH DOSHI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views2 pages

Runge Kutta 4Th Order: Input Program & Result

The document describes a 4th order Runge Kutta method for solving ordinary differential equations numerically. It provides an example of using the RK4 method to solve the ODE dx/dt = x + y with initial conditions x=0, y=1 on the interval [0,2]. It also shows solving the same problem using MATLAB's ode45 solver for comparison.

Uploaded by

YASH DOSHI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

RUNGE KUTTA 4TH ORDER

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

Name: Shubham Chapparghare Roll no.: 351013

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

PROGRAM & RESULT


function[]=SC_RK4(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/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

fprintf('The value obtained is: %f\n',y0);

The value obtained is: 10.095462

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

Published with MATLAB® R2017a

You might also like