Members BookmarksPolls Fresher Jobs Funny Pictures MCA Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

Advertisements


website counter




//C++ Program for newton forward interpolation formula


Posted Date: 23 Mar 2008    Resource Type: Articles/Knowledge Sharing    Category: Computer & Technology

Posted By: ashish singh       Member Level: Diamond
Rating:     Points: 2



//Program for newton forward interpolation formula

#include
#include
#include
#include
#define MAXN 100
#define ORDER 4
void main()
{
float ax[MAXN],ay[MAXN],diff[MAXN+1][ORDER+1];
float nr=1.0,dr=1.0,x,p,h,yp;
int i,n,j,k;
textcolor(GREEN);
clrscr();
cout<<"enter the value of n : ";
cin>>n;
cout<<"\nenter the values in form x,y\n";
for(i=0;i<=n;i++)
cin>>ax[i]>>ay[i];
cout<<"\nenter the value of x for which y is wanted : ";
cin>>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<=ORDER;j++)
for(i=0;i<=n;i++)
diff[i][j]=diff[i+1][j-1]-diff[i][j-1];
i=0;
while(!(ax[i]>x))
i++;
i--;
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];
}
cout<<"\n when x = "<textcolor(YELLOW);
cout<<"\n\n\a";

cout<<"\n\n";


getch();
}

output:
enter the value of n : 4
enter the values in form x,y
80 5026
85 5674
90 6362
95 7088
100 7854
enter the value of x for which y is wanted : 83
when x = 83, y = 5.41e+03




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: //C++ program for newton backward interpolation formula
Previous Resource: C++ Program to solve linear equation (3 variable) by gauss elimination method
Return to Discussion Resource Index
Post New Resource
Category: Computer & Technology


Post resources and earn money!
 
Related Resources


Contact Us    Privacy Policy    Terms Of Use   

SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.