# Runge Kutta Method Formula and C Program

## Runge Kutta Method

A Runge Kutta Method of numerically integrating ordinary differential equations by using a trial step at the midpoint of an interval to cancel out lower-order error terms. The second-order formula is ### C Code For 4th Order Runge Kutta Method

```#include<stdio.h>
#include<math.h>
#include<conio.h>
#define f(x,y) 1-2*(x)*(x)*(y)

int main(){
float x,xp,x0,y0,y,h,m1,m2,m3,m4;
printf("\n runge-Kutta Forth order\n");
printf("\nEnter initial values of x and y\n");
scanf("%f%f",&x0,&y0);
printf("\nEnter x at which function to be evaluated\n");
scanf("%f",&xp);
printf("\nEnter the step size \n");
scanf("%f",&h);
y=y0;
x=x0;
for(x=x0;x<xp;x=x+h){
m1=f(x,y);
printf("\nm1=%f",m1);
m2=f(x+h/2,y+(h*m1)/2);
printf("\nm2=%f",m2);
m3=f(x+h/2,y+(h*m2)/2);
printf("\nm3=%f",m3);
m4=f(x+h,y+h*m3);
printf("\nm4=%f",m4);
y=y+h/6*(m1+2*m2+2*m3+m4);
printf("\ny=%f",y);
}

printf("Function value at x=%f is %f\n",xp,y);
getch();
return 0;

}
```

1. 