# Runge Kutta Method implementation in c

## The Runge-Kutta Method was developed by two German men Carl Runge (1856-1927), and Martin Kutta (1867- 1944) in 1901.

Carl Runge developed numerical methods for solving the differential equations that arose in his study of atomic spectra.
Today his name is associated with the Runge-Kutta methods to numerically solve differential equations. Kutta, another German applied mathematician, is also remembered for his contribution to the differential equations-based Kutta-Joukowski theory of airfoil lift in aerodynamics.

The 4th-Order Runge-Kutta method is a very common numerical method used to solve differential equations with a known initial condition.  The method starts at the initial condition and proceeds stepwise to develop successive points in the function based on the previous point and the calculated Runge-Kutta parameters. The method lends itself to spreadsheet calculations.
The code for the Runge Kutta method has been writing in c language.
CODE for Runge Kutta method in C :

#include<stdio.h>
#include<conio.h>
#include<math.h>
float fun(float x, float y)
{
return(0.1*x*x+0.1*y*y);       /* here we will give our function which to be solved*/
}
int main( )
{
int i,j,N;
float x0,y0,x,h,y,k,Y,n,p,a;
printf("\n Enter the initial value of X:");
scanf("%f",&x0);
printf("\n Enter the initial value of Y:");
scanf("%f",&y0);
printf("\n Enter the given value of X:");
scanf("%f",&x);
printf("\n Enter the value of step size h:");
scanf("%f",&h);
n=(x-x0)/h;
N=(int)n;
printf("\nNumber of iterations is:%d\n",N);
for(i=1;i<=N;i++)
{
k[i]=h*fun(x0,y0);
k[i]=h*fun(x0+0.5*h,y0+0.5*k[i]);
k[i]=h*fun(x0+0.5*h,y0+0.5*k[i]);
k[i]=h*fun(x0+h,y0+k[i]);
k[i]=(1.0/6.0)*(k[i]+2*k[i]+2*k[i]+k[i]);
x0=x0+h;
y=y0+k[i];
Y[i]=y;
y0=y;

}
printf("\nk1\t\tk2\t\tk3\t\tk4\t\tk\t\tY\n");
x0=x0-n*h;
p=h;
for(i=1;i<=N;i++)
{
for(j=1;j<=5;j++)
{
printf("%f\t",k[i][j]);
}
a=x0+h;
printf("\tY(%f)=%f",a,Y[i]);
printf("\n");
h=h+p;
}
printf("\nThe final value of Y:\t%f",y);
getch();
}

Input and Output:
If the function is 0.1*x*x+0.1*y*y then what will happen in the program is given below

APPLICATION OF RUNGE KUTTA METHOD:
Runge-Kutta methods are widely used methods for the integration of initial value problems for ordinary differential equations. They can also be used for the time integration of initial value problems for time-dependent partial differential equations by applying the so-called method of lines