Thursday, September 24, 2015

Write an Algorithm for the Bisection Method.

Step1:-  Decide initial values for x1 & x2 & stopping criteria, E.
Step2:-  Compute f1 = f ( x1 ) & f2 = f ( x2 ).
Step3:-  If ( f1 * f2) > 0,  x1 & x2 do not bracket any root & go to step 7.
             Otherwise continue.
Step4:-  Compute x0 = ( x2 - x1 ) / x2 & compute f0 = f ( x0 ).
Step5:-  If ( f1 = f0 ) < 0 then
                    Set x2 = x0
              else
                    Set x1 = x0
                    Set f1 = f0
 Step6:-  If absolute value of ( x2 - x1 ) /  x2 is less than error E, then
                    root = ( x2 - x1 ) / 2
                    write the value of root
                    go to step 7.
              else
                    go to step 4.
Step7:-  Stop.