Exp 1 Bisection Method
Exp 1 Bisection Method
EQUATION:BRACK
ETING
METHODS(BISECTI
ON)
BISECTION METHOD
Bisection is a bracketing method and starts with two
initial guesses say x0 and x1 such that x0 and x1
brackets the root i.e; f(x0).f(x1)<0
To find out the root of f(x)=0 , we have to consider intervals
in such a way that it satisfies intermediate value theorem.
x2 = (x0 +x1)/2
And then process is repeated untill we find the root within the desired accuracy.
ALGORITHM
1. start
2. Define function
3. Define desired accuracy e
4. Choose initial guesses x0 and x1 such that f(x0).f(x1)<0
5. Calculate new approximated root as x2=(x0+x1)/2
6. Calculate f(x0)f(x2)
a. If f(x0)f(x2)<0, then x0=x0 and x1=x2
b. If f(x0)f(x2)>0, then x0=x2 and x1=x1
7. If |f(x2)|>e then go to (5) otherwise go to (8)
8. Display x2 as root
9. Stop
C PROGRAMME FOR
BISECTION METHOD
Suppose a function f(x)= x3-9x+1 is given. We have to complie a C-
programme to find the roots of this function. So we can compile the
programme as follows:
Output :
ANALYSIS
After two initial values for which the given function satisfies the intermediate
value theorem i.e; f(x0).f(x1)<0 is given as input in the programme and thus
we see from the 1st iteration, the function value is negative and as given
condition in 2nd iteration x1 replaces x2 and x0 remains the same while, in
the 4th iteration, the function value becomes positive and x0 replaces x2 and
x1 remains the same. Thus for a desired accuracy defined e=0.001, the 9th
iteration shows the function value f2=-0.000573 which is accurate upto
three decimal points and whose absolute value that is defined by fabs in the
programme less than e. So, the function is terminated here after 9th iteration
and we get the approximated root x2=0.1113 (upto 4 decimal points).