You are on page 1of 1

PROGRAM ON RUNGE KUTTA 4TH ORDER METHOD (SIMULTANEOUS EQUATIONS)

clc;
x0=input('Enter the value of x0:');
y0=input('Enter the value of y0:');
z0=input('Enter the value of z0:');
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*(x0+y0*z0);
l1=h*(x0*x0-y0*y0);
k2=h*((x0+h/2)+(y0+k1/2)*(z0+l1/2));
l2=h*((x0+(h/2))*(x0+(h/2))-(y0+(k1/2))*(y0+(k1/2)));
k3=h*((x0+(h/2))+(y0+(k2/2))*(z0+(l2/2)));
l3=h*((x0+(h/2))*(x0+(h/2))-(y0+(k2/2))*(y0+(k2/2)));
k4=h*((x0+h)+(y0+k3)*(z0+l3));
l4=h*((x0+h)*(x0+h)-(y0+k3)*(y0+k3));
k=(k1+k4+(2*k3)+(2*k2))/6;
l=(l1+l4+(2*l3)+(2*l2))/6;
y1=y0+k;
z1=z0+l;
end
fprintf('yg=%f',y1);
fprintf('\n zg=%f',z1);
OUTPUT:
Enter the value
Enter the value
Enter the value
Enter the value
Enter the value
yg=1.352724
zg=-0.775715

of
of
of
of
of

x0:0
y0:1
z0:0.5
xg:1.2
h:1.2

You might also like