Regular Falsi Method Using C Programming:


#include<stdio.h>
#include<math.h>
#define f(x) (2*x-(log(x)/log(10))-7)
int main()
{
    float a,b,xn,x;
    int i,p;
    printf("Enter the value of A and B");
    scanf("%f %f",&a,&b);
    printf("Enter the Number of Iteration");
    scanf("%d",&p);
    for(i=1;i<=p;i++)
    {
     xn=((a*f(b))-(b*f(a)))/(f(b)-f(a));
    printf("\nOutput is : %f ",xn);
    if(f(a)>0)
    {
       if(f(xn)>0)
            {a=xn;
            b=b;}
       else
            {b=xn;
            a=a;}

    }
     if(f(a)<0)
    {
       if(f(xn)<0)
            {a=xn;
            b=b;}
       else
            {b=xn;
            a=a;}
    }}

    return 0;
}

Comments

Popular posts from this blog

Newton Backward Interpolation Formula