Logo 
Search:

C Programming Articles

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

False Position Method or Regula Falsi Method

Posted By: Dhrubajit Sarma     Category: C Programming     Views: 19793

#include<stdio.h>
#include<conio.h>
#include<math.h>
float f(float x)
{
return (x*x*x-5*x+1);
}
int main()
{
clrscr();
int itr=0, maxitr;
float x1,x2,x3,x4,aerr;
printf("\nProgram to find Root of an Equation by Regula falsi Method\n\n");
printf("\nEnter value of x0, x1, allowed error and maximum iteration\n");
scanf("%f %f %f %d", &x1, &x2, &aerr, &maxitr);
x3=((x1*f(x2))-(x2*f(x1)))/(f(x2)-f(x1));
printf("\n\nIn iteration %d, Value of x3 =\t%f",itr+1,x3);
do
{
if (f(x1)*f(x3)<0)
x2=x3;
else
x1=x3;
x4=x3;
x3=((x1*f(x2))-(x2*f(x1)))/(f(x2)-f(x1));
itr++;
printf("\nIn iteration %d Value of x=\t%f", itr+1,x3);
if (fabs(x4-x3)<aerr)
{
printf("\n\nAfter %d iteration, Root= %f", itr,x4);
getch();
return 0;
}
}
while (itr<maxitr);
printf("\n\nSolution does not converge Iteration not sufficient");
getch();
return 1;
}
  
Share: 


Didn't find what you were looking for? Find more on False Position Method or Regula Falsi Method Or get search suggestion and latest updates.

Dhrubajit Sarma
Dhrubajit Sarma author of False Position Method or Regula Falsi Method is from United States.
 
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!