Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Numerical MethodsRSS Feeds

MILE SIMPSON METHOD

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

Write a program of MILE SIMPSON METHOD.

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: 0

Enter the value of y0: 0

Enter the value of h: 0.2

Enter the value of X for finding Y(x): 0.8

Enter the value of Y(0.00): 0

Enter the value of Y(0.20): 0.2027

Enter the value of Y(0.40): 0.4228

Enter 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
Owen Bouchard author of MILE SIMPSON METHOD is from Montreal, Canada.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!