Runge-Kutta

#include<stdio.h>
#include<conio.h>
#define F(x) x*x+y*y
int main (void)
{
   int c=0;
   float i,x,y,a,b,h,m1,m2,m3,m4,Ry=0,e;
   clrscr();
   printf("Enter the value of x & y : ");
   scanf("%f%f",&x,&y);
   printf("Enter the value of h: ");
   scanf("%f",&h);
   printf("Enter the estimate value of x as Y(x): ");
   scanf("%f",&e);
   a=x;
   b=y;
   for(i=h;i<=e;i=i+h)
   {
      m1= F(x);
      x=a+h/2;
      y=b+(m1*h)/2;
      m2= F(x);
      x=a+(h/2);
      y=b+(m2*h)/2;
      m3= F(x);
      x=a+h;                                  
      y=b+m3*h;
      m4= F(x);
      Ry=Ry+((m1+2*m2+2*m3+m4)*h)/6;
      a=a+h;
      b=b+Ry;
      c++;
   }
   printf("\nNo of ittration: %d\n",c);
   printf("Required Ans: %f",Ry);
   getch();
   return 0;
}

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *