**Warning**: count(): Parameter must be an array or an object that implements Countable in

**/srv/users/serverpilot/apps/eken/public/e/wp-content/themes/jnews/class/Single/SinglePost.php**on line

**1081**

Evaluating ordinary differential equations by RK-4 or classical method both order first and second

//To compute ordinary differential equations by RK-4 or classical method for order first

#include

#include

#include

void main()

{

cout<<“\t first order R-K 4th Classical Method\t”<

double h,n,m1,i,m2,m3,m4,x[100],y[100];

cout<<“Number of intervals “;

cin>>n;

cout<

cout<<“Enter the value of h”<<<“h = “;

cin>>h;

cout<<“Enter the value of x0″<<<“x0 = “;

cin>>x[0];

cout<<“Enter the value of y0″<<<“y0 = “;

cin>>y[0];

cout<

for(i=0;i<=n;i++)

{

x[i+1]=x[i]+h;

m1=h*.5*(1+x[i])*(y[i]*y[i]);

m2=h*.5*(1+(x[i]+.5*h))*(y[i]+m1*.5*h)*(y[i]+m1*.5*h);

m3=h*.5*(1+(x[i]+.5*h))*(y[i]+m2*.5*h)*(y[i]+m2*.5*h);

m4=h*.5*(1+(x[i]+h))*(y[i]+m3*h)*(y[i]+m3*h);

y[i+1]=y[i]+(m1+2.0*m2+2.0*m3+m4)/6;

cout<<“x”<<<“= “<<

cout<<“y”<<<“= “<<

cout<

}

getch();

}

// To compute ordinary differential equations by RK-4 or classical method for order second

#include

#include

#include

void main()

{

cout<<“\t 2nd order order R-K 4th Order Method\t”<

double h,n,m1,i,m2,m3,m4,p1,p2,p3,p4,x[100],y[100],z[100];

cout<<“Number of intervals “;

cin>>n;

cout<

cout<<“Enter the value of h”<<<“h = “;

cin>>h;

cout<<“Enter the value of x0″<<<“x0 = “;

cin>>x[0];

cout<<“Enter the value of y0″<<<“y0 = “;

cin>>y[0];

cout<<“Enter the value of z0″<<<“z0 = “;

cin>>z[0];

cout<

for(i=0;i<=n;i++)

{

x[i+1]=x[i]+h;

m1=h*z[i];

p1=h*(6*x[i]+3*y[i]-2*z[i]);

m2=h*(z[i]+.5*p1);

p2=h*(6*(x[i]+.5*h)+3*(y[i]+m1*.5)-2*(z[i]+.5*p1)) ;

m3=h*(z[i]+.5*p2);

p3=h*(6*(x[i]+.5*h)+3*(y[i]+m2*.5)-2*(z[i]+.5*p2)) ;

m4=h*(z[i]+.5*p3);

p4=h*(6*(x[i]+.5*h)+3*(y[i]+m3*.5)-2*(z[i]+.5*p3)) ;

y[i+1]=y[i]+(m1+2.0*m2+2.0*m3+m4)/6;

z[i+1]=z[i]+(p1+2.0*p2+2.0*p3+p4)/6;

cout<<“x”<<<“= “<<

cout<<“y”<<<“= “<<

cout<<“z”<<<“= “<<

cout<

}

getch();

}

To evaluate ordinary differential equations by RK-4 (Classical) Method in C++ Programming Language for Numerical Methods for Engineering Students