New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



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.

website counter



Newton's Interpolation Method


Posted Date:     Total Responses: 0    Posted By: Vikram Narayan C   Member Level: Silver   Points/Cash: 2   


#include //stdio.h
#include //conio.h
#include //stdlib.h
#include //math.h
#define maxy 10
float f[maxy],f1[maxy];
int deg,i,j,k;
float x[100];

float power(float value,int pwr)
{
int i;
float t=1;
for(i=0;i {
t = t*value;
}
return t;
}
float eval(float fun[],float val,int deg)
{
double t=0;int i=0;
for(i=0;i<=deg;i++)
{
t = t + fun[i] * power(val,i);
}
return (float)t;
}

void main()
{
/* Variable declaration */
clrscr();
printf("\nEnter the degree of the function:");
scanf("%d",°);
printf("\nEnter the coefficients:\n");
for(i=deg;i>=0;i--)
{
printf("x^%d :",i);
scanf("%f",&f[i]);
}
for(i=deg;i>=0;i--)
{
f1[i-1]=f[i]*i;
}
clrscr();
printf("\nThe function is:\n");
for(i=deg;i>=0;i--)
{
if((f[i]>0&&i>0))
printf(" + %0.2f x^%d ",f[i],i);
else
printf(" %0.2f x^%d ",f[i],i);
}
printf("\nThe differenciated function is:\n");
for(i=deg;i>0;i--)
{
if((f1[i-1]>0)&&(i>0))
printf(" + %0.2f x^%d ",f1[i-1],i-1);
else
printf(" %0.2f x^%d ",f1[i-1],i-1);
}

for(i=-50;i<50;i++)
{
float x1,x2;
x1 = eval(f,i,deg);
x2 = eval(f,(i+1),deg);
if((int)(x2*100000)==0)
{
printf("\n\nThe solution is: %d",i+1);
getch();
exit(0);
}
if((int)(x1*x2*100000)<0)
{
x[0]= (float)i+1.0/2;
break;
}
}
for(i=1;i<100;i++)
{
if(eval(f1,(float)(i-1),deg-1))
x[i] = x[i-1] - (eval(f,x[i-1],deg)/eval(f1,x[i-1],deg-1));
if((int)(x[i]*10000)==(int)(x[i-1]*10000))
break;
}
printf("\n\nThe solution is: %0.4f",x[i]);
getch();
}


Project Feedbacks


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

Post Feedback
You must Sign In to post a feedback.
Next Project: Simultaneous Equations - Gauss Seidel
Previous Project: Regular Fausse Method

Return to Project Index

Post New Project


Related Projects



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.