# Fortran ~ Bisection Method - Ishwaranand

## Fortran ~ Bisection Method

• This method is used for finding an approximate solution to an equation f(x)=0 to the desired degree of accuracy.
• This method is based on a concept which states that if a function f(x) is continuous in the closed interval a<=x<=b and f(a), f(b) are of opposite signs,
• then there must exist at least one real root between x=a and x=b.
• F(X) =2.0*X**3-5.0*X-2.15 Image Source ~ Crafted With ©Ishwaranand - 2020 ~ Image by ©Ishwaranand

### Write a program to demonstrate the application of the Bisection method to locate the root of the equation.?

PROGRAM BISECT
C
C        PROGRAM TO LOCATE A ROOT OF EQUATION USING BISECTION METHOD
C
C         GIVEN EQUATION
F(X) =2.0*X**3-5.0*X-2.15
C
100      WRITE (*,*)'ENTER YOUR ESTIMATE OF ROOT (LOWER LIMIT, UPPER LIMIT)'
C         FIND IF ESTIMATES ARE CORRECT
CHK=F(XL)*F(XR)
C         ENTER DATA AGAIN IF ESTIMATES DO NOT BRACKET THE ROOT
IF (CHK.GT.0.0) GOTO 100
I=0
400     I=I+1
C        FIND ROOT POSITION USING ARITHMETIC MEAN
XM=(XL+XR)/2.0
CHK=ABS (F (XM))
C        EXIT LOOP IF ROOT FOUND
IF (CHK.LE.0.0001) GOTO 200
C        EXIT LOOPS IF UNABLE TO FIND ROOT EVEN AFTER 100+ CYCLES
IF (I.GT.100) GOTO 300
C        GET NEW LOWER AND UPPER LIMITS FOR NEXT CYCLE
CHK=F(XL)*F(XM)
IF(CHK.LT.0.0)THEN
XR=XM
ELSE
XL=XM
ENDIF
C        START NEXT CYCLE
GOTO 400
200    WRITE (*,*)'ROOT FOUND AT X=', XM
STOP