answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<conio.h>

#include<process.h>

#include<math.h>

void main()

{

int n;

int i,j;

float ax[10];

float ay[10];

float x;

float y=0;

float h;

float p;

float diff[20][20];

float y1,y2,y3,y4;

clrscr();

printf("\t\t!! NEWTON GRAGORY FORWARD INTERPOLATION FORMULA!!\n");

printf("\t\t By KRISHAN \t\t\n");

printf("\t\t enter the no of terms ->");

scanf("%d",&n);

printf("\n\t\t enter the value in form of x->");

for(i=0;i<n;i++)

{

printf("\n\t\t enter the value of x%d->",i+1);

scanf("%f",&ax[i]);

}

printf("\n\t\tenter the value in the form of y->");

for(i=0;i<n;i++)

{

printf("\n\t\tenter the value of y %d->",i+1);

scanf("%f",&ay[i]);

}

printf("\n\t\tenter the value of x for");

printf("\n\t\t which u want the value of y->");

scanf("%f",&x);

h=ax[1]-ax[0];

for(i=0;i<n-1;i++)

diff[i][1]=ay[i+1]-ay[i];

for(j=2;j<=4;j++)

for(i=0;i<n-j;i++)

diff[i][j]=diff[i+1][j-1]-diff[i][j-1];

do

{

i++;

}

while(ax[i]<x);

i--;

p=(x-ax[i])/h;

y1=p*diff[i-1][1];

y2=p*(p+1)*diff[i-1][2]/2;

y3=p*(p+1)*(p-1)*diff[i-2][3]/6;

y4=(p+2)*(p+1)*p*(p-1)*diff[i-3][4]/24;

y=ay[i]+y1+y2+y3+y4;

printf("\n\t\t when x=%6.4f,y=%6.8f",x,y);

printf("\n\n\n\t\t\t!! PRESS ENTER TO EXIT!!");

getch();

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

/program for newton backward interpolation formula

#include <stdio.h>

#include <conio.h>

#include <math.h>

#define pf printf

#define sf scanf

#define maxn 100

#define order 4

void main()

{

float ax[maxn+1],ay[maxn+1],diff[maxn+1]

[order+1],nr=1,dr=1,x,p,h,yp;

int n,i,j,k;

clrscr();

pf("enter the value of n\n");

sf("%d",&n);

pf("enter the values in form x,y\n");

for(i=1;i<=n;i++)

{sf("f",&ax[i],&ay[i]);}

pf("enter the value of x for which value of y is wanted\n");

sf("%f",&x);

h=ax[2]-ax[1];

for(i=n;i>=1;i--)

{diff[i][1]=ay[i]-ay[i-1];}

for(j=2;j<=order;j++)

{

for(i=n;i>j;i--)

{diff[i][j]=diff[i][j-1]-diff[i-1][j-1];}

}

i=n;

p=(x-ax[i])/h;

yp=ay[i];

for(k=1;k<=order;k++)

{

nr*=p+k-1;

dr*=k;

yp+=(nr/dr)*diff[i][k];

}

pf("when x =%f\t y= %f",x,yp);

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

//program for newton backward interpolation formula

#include <stdio.h>

#include <conio.h>

#include <math.h>

#define pf printf

#define sf scanf

#define maxn 100

#define order 4

void main()

{

float ax[maxn+1],ay[maxn+1],diff[maxn+1]

[order+1],nr=1,dr=1,x,p,h,yp;

int n,i,j,k;

clrscr();

pf("enter the value of n\n");

sf("%d",&n);

pf("enter the values in form x,y\n");

for(i=1;i<=n;i++)

{sf("f",&ax[i],&ay[i]);}

pf("enter the value of x for which value of y is wanted\n");

sf("%f",&x);

h=ax[2]-ax[1];

for(i=n;i>=1;i--)

{diff[i][1]=ay[i]-ay[i-1];}

for(j=2;j<=order;j++)

{

for(i=n;i>j;i--)

{diff[i][j]=diff[i][j-1]-diff[i-1][j-1];}

}

i=n;

p=(x-ax[i])/h;

yp=ay[i];

for(k=1;k<=order;k++)

{

nr*=p+k-1;

dr*=k;

yp+=(nr/dr)*diff[i][k];

}

pf("when x =%f\t y= %f",x,yp);

getch();

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program for newton's backward interpolation?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What does 3.78 liters equal?

It will weigh between 355.4 Newtons (at 100 deg C) and 370.8 Newtons (at 4 deg C).


What words can have a somewhat negative connotation a comparative b rabble c hack or d backward?

backward


How do you write a backward c for roman numeral?

Courtney


What is the difference between forward slash and backward slash in c?

forward slash - division operator backward slash - special character (e.g. \n - newline) in C strings


What is the name of the fashion line with a D and backward D logo?

it is actually a D and a backward C. But its called DC its a skater brand.


Features of c program?

the features of a C program


C program was introduced in the year?

c program was introduced in the year 1972 by Dennis RitchieNo, it was the C language, not the C program.


What is executive a c program?

I think it is 'execution of a C program'.


C program on left factoring in compiler design?

how to create a c program for left factoring.


Different parts of c language program?

what are the parts of C language program


Program for sin series in c language?

find the program in c-pgms.blogspot.com


Can you program games with c plus plus?

Yes, you can program games with C++.