If you learn well,you will earn well.

Program to find the root of a linear equation using Bisection Method.

08.. Write a program to find the root of a linear equation using Bisection Method. (xex = 1 )

Answer:


#include<stdio.h>
#include<math.h>
main()
{
   double a,b,fa,t,fb,ft,ac=0.0001;//ac is the accutacy of the prigram
   printf("Enter two value of a  and b as if  the  equation f(a) and f(b) are opposite sign");
   scanf("%lf%lf",&a,&b);

   fa=(a*exp(a))-1;
   fb=(b*exp(b))-1;
   if((fa*fb)<0)
   {
       do
       {
           t=(a+b)/2;
           ft=(t*exp(t))-1;
           if((ft*fa)<0)
           {
               b=t;
               if(ft<0)
               ft=-(ft);
           }
           else if((fa*ft)>0)
           {
           a=t;
           if(ft<0)
           ft=-(ft);
           }
           else if((fa*ft)==0)
           printf("The root of the function=%4lf",t);
           }
           while(ft>=ac);
           printf("The root of the function=%4lf",t);
   }
   else
   printf("There is no root between %lf  and%lf",a,b);



}

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

Hello Guys This is my profile. Powered by Blogger.

Popular Posts

Subscribe Via Email

Subscribe to our newsletter to get the latest updates to your inbox. ;-)

Your email address is safe with us!

Email Newsletter

Subscribe to our newsletter to get the latest updates to your inbox. ;-)


Your email address is safe with us!

Scroll To Top