Algebraic and Transcendental Equations

(To Download Exercise 2 Document Click Here) 

Objective : - To find out the roots of an Algebraic & Transcendental Equations Using Bisecting Method 

Theory : - 

Direct Methods or Closed Form formulas exist up to the polynomials of degree up to Four, For polynomials of degree more than four, no general formula exists for finding roots. 

 Numerical methods are used to find out the roots. The numerical methods for the root finding problem are iterative in nature.

 The idea behind the iterative method is, 

1.      Start with an initial approximation (X0)

2.      Construct a sequence of iterates using an iteration formula (Xk)

3.      Until the sequence converges to a root of f(X) = 0

Two important aspects of the iterative methods are, 

·         Convergence Formulation

·         Stopping Criteria 

Bisection Method

            The bisection method is based on the repeated bisection of an interval containing the root. This method can be applied for solving nonlinear equations like f(x) = 0. 

·  Suppose f(x) = 0 is known to have a real root x = ε, in a interval [a,b]. 

·  Bisect the interval [a,b] and let c = (a+b)/2 be the midpoint of [a,b].

·  If c is the root then f(c) = 0, then the process is completed and c is the root. 

·  Otherwise the root is in one of the intervals [a,c] or [c,b].

·  Check the value of f(c).f(a) < 0 , the root is in between [a,c], else the root is between [c,b]. 

Continue the process of bisection until the accuracy level of the root is reached. 

After every iteration, the width of the interval, which is known to bracket the root, is halved. In general, after n iterations, we would be in the interval [an,bn]  and its width would be, 

   After n Iteration the approximation of the root will be Cn = (bn - an)/2. The sequence of Numbers  C0, C1, C2, C3 ……… are successive approximations to the root of the equation and each successive iteration is closer to the desired root of the equation. 

Advantages of bisection method 

·The bisection method is always convergent. Since the method brackets the root, the method is guaranteed to converge.

· As iterations are conducted, the interval gets halved. So one can guarantee the error in the solution of the equation.

 Drawbacks of bisection method 

· The convergence of the bisection method is slow as it is simply based on halving the interval.

· If one of the initial guesses is closer to the root, it will take larger number of iterations to reach the root.

Program:

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

#include<math.h>

 

 double f(double x);   //Declaration of the Function

 double f(double x)

   {

    double m=pow(x,6)-x-3;//Enter Your Single Variable Function Here

    return m;

   }

 

 void main( )

 {

   clrscr( );

   double a,b,c,e;

   int i=1;

   cout<<"\n Enter the Initial and Final Limits: ";

   cin>>a>>b;

   cout<<"\n Enter the Number of accuracy: ";

   cin>>e;

   if((f(a)*f(b))>0)

    {

     cout<<"\n Please Change the Search Intervals ";

     }//Checking if the Root Exists in the Given Limits

    else if(f(a)==0)

       {

           cout<<"\n The Root is : "<<a;

       }

     else if(f(b)==0)

       {

          cout<<"\n The Root is : "<<b;

      }

     else

       {

          do

          {

           c=(a+b)/2;

           if(f(c)==0)

           {

            cout<<"\n The Root is :"<<c;

           }

           else

           {

             (f(a)*f(c)>0) ? a=c : b=c;

             cout<<"\n"<<i<<" "<<c<<" "<<setprecision(20)<<f(c);

           }

           i=i+1;

          }while(fabs(a-b)>e);

       }

  getch();

}

Output:

 

Function 1: x6 – x – 3

a.       Find the Root of the above function using the C++ Code and Verify it

b.      Does the Root exist between the Interval of 3 to 10

c.       Find the Number of Iterations for search interval between -10 to +10 with the accuracy of 10-7 

 

Find the Roots of the below Functions by using the C++ Code & Verify Them

·         x3 – 10x – 2x2 +10

·         (x-1)2 – 0.01x4

·         2(x - 2)exp(x - 2) - (x+3)2

·         exp(x) - x3

·         2x - x3 - 5x2 - 2exp(0.01x)