You are on page 1of 1

PROGRAM ON RUNGE KUTTA 4TH ORDER METHOD:

clc;
x0=input('Enter the value of x0:');
y0=input('Enter the value of y0:');
xg=input('Enter the value of xg:');
h=input('Enter the value of h:');
n=(xg-x0)/h;
for i=1:n
x1=x0+h;
k1=h*(y0);
k2=h*(y0+k1/2);
k3=h*(y0+k2/2);
k4=h*(y0+k3);
k=(k1+k4+(2*k3)+(2*k2))/6;
y1=y0+k;
x0=x1;
y0=y1;
end
fprintf('yg=%f',y1);
OUTPUT:
Enter the value
Enter the value
Enter the value
Enter the value
yg=2.442805

of
of
of
of

x0:0
y0:2
xg:0.2
h:0.1

You might also like