Search:

Submit Article

MILE SIMPSON METHOD

Posted By: Owen Bouchard     Category: C Programming     Views: 5277

Code for MILE SIMPSON METHOD in C Programming

```#include<stdio.h>
#include <math.h>
#include<conio.h>
#define F(x,y)  1 + (y)*(y)
void main()
{
double y0,x0,y1,y[10],n,h,f,sum=0;
int j;
clrscr();
printf("\nEnter the value of x0: ");
scanf("%lf",&x0);
printf("\nEnter the value of y0: ");
scanf("%lf",&y0);
printf("\nEnter the value of h: ");
scanf("%lf",&h);
printf("\nEnter the value of X for finding Y(x): ");
scanf("%lf",&n);
for(x0,j=0; x0<n; x0=x0+h,j++)
{
printf("\nEnter the value of Y(%.2lf): ",x0);
scanf("%lf",&y[j]);
}

f = F(x0,y[1]);
sum = sum + 2 * f;
f = F(x0,y[2]);
sum = sum - f;
f = F(x0,y[3]);
sum = sum + 2 * f;
y1 = y[0] + (4*h/3) * (sum);
printf("\n\n  Yp(%.2lf) = %.3lf ",n,y1);

sum = 0;
f=F(x0,y[2]);
sum = sum + f;
f = F(x0,y[3]);
sum = sum + 4 * f;
f = F(x0,y1);
sum = sum + f;
y1 = y[2] + (h/3) * (sum);
printf("\n\n  Yc(%.2lf) = %.3lf ",n,y1);

getch();
}

/*____________________________________         OUT PUT____________________________________Enter the value of x0: 0Enter the value of y0: 0Enter the value of h: 0.2Enter the value of X for finding Y(x): 0.8Enter the value of Y(0.00): 0Enter the value of Y(0.20): 0.2027Enter the value of Y(0.40): 0.4228Enter the value of Y(0.60): 0.6841  Yp(0.80) = 1.024  Yc(0.80) = 1.029*/```
Share:

Didn't find what you were looking for? Find more on MILE SIMPSON METHOD Or get search suggestion and latest updates.

 Owen Bouchard author of MILE SIMPSON METHOD is from Montreal, Canada. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!