Adams-Moulton Method

Adams-Moulton Method

#include<stdio.h>
#include<conio.h>
#include<math.h>
#define F x*y
int main ()
{
	float x0,x1,x2,x3,x4,y0,y1,y2,y3,yc,h,f0,f1,f2,f3,f4,fc4,x,y,yp,e=1.0,yc1;
   clrscr();
   printf("Enter the valu of x0,x1,x2,x3,x4: \n");
   scanf("%f%f%f%f%f",&x0,&x1,&x2,&x3,&x4);
   printf("Enter the value of y0,y1,y2,y3:\n");
   scanf("%f%f%f%f",&y0,&y1,&y2,&y3);
   h=x1-x0;
   x=x0;
   y=y0;
   f0=F;
   x=x1;
   y=y1;
   f1=F;
   x=x2;
   y=y2;
   f2=F;
   x=x3;
   y=y3;
   f3=F;
   yp=y3+(h*(55*f3-59*f2+37*f1-9*f0)/24);
   y=yp;
   x=x4;
   f4=F;
   while(e>=0.000001)
   {
   	yc=y3+h*(19*f3-5*f2+f1+9*f4)/24;
      y=yc;
      fc4=F;
      f4=fc4;

      yc1=y3+h*(19*f3-5*f2+f1+9*f4)/24;
      y=yc1;
      fc4=F;
      f4=fc4;
      e=fabs(yc-yc1);
   }
   printf("\nRequired ans is: %f",yc);
	getch();
   return 0;
}

Related posts:

Leave a Reply

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