Engineering

Solve Runge-Kutta Second Order using a Program

The fundamental method in obtaining the solution of differential equation is extrapolation. And Runge-Kutta method is the most accurate.
So in this post we will learn how to solve Runge-Kutta Second order method using a C++ Program.

The following video demonstrates how:

VIDEO TUTORIAL

 

Anuncio publicitario

CODE


 #include 
 #include 
 #include 
 
 using namespace std;
 
 int repeat()
 {
 int ch;
 cout
cin>>ch;
 if(ch==1)
 {
 return 1;
}
 else
 {
 return 0;
 }
}
int main()
 {
 int option;
 float x,y,h;
 float k1,k2,k=0;
 label:
 cout>x;
 cout>y;
cout>h;
 system("cls");
 cout
cout>option;
switch(option)
 {
 case 1:
 k1=(float) h*(x+y); // KI CALCULATED
 cout
k2=h*(x+h+y+k1);
 cout
k=(k1+k2)/2;
 cout
if(repeat()==1)
 {
 system("cls");
 goto label;
 }
 else
 {
 exit(0);
 }
 break;
case 2:
 k1=(float) h*(x*y); // KI CALCULATED
 cout
if(repeat()==1)
 {
 system("cls");
 goto label;
 }
 else
 {
 exit(0);
 }
break;
case 3:
k1=(float) h*((x*x)+(x*y)); // KI CALCULATED
 cout
cout
if(repeat()==1)
 {
 system("cls");
 goto label;
 }
 else
 {
 exit(0);
 }
 break;
default:
 cout
}//end switch
 }

ARTÍCULOS RELACIONADOS

Engineering

Function prototyping is one of the key improvements added to the C++ functions. When a function call is encountered, the compiler checks the function...

Engineering

If we want two computers to communicate over a network, then the protocols on each layer of OSI model in the sending computer should...

Engineering

When virtual functions are created for implementing late binding, there are some basic rules that satisfy the compiler requirements: The virtual function must be...

Engineering

In assembly language programs, small sequence of codes of the same pattern are repeated frequently at different places which perform the same operation on...

Doctor Caos 2011 - 2021

Salir de la versión móvil