• Rainy Season
• World
Wednesday - July 17, 2024
#Fortran #Algorithm #Blog #C Program

# Fortran ~ Regula Falsi Method

## Fortran ~ Regula Falsi Method

• This is the oldest method for finding the real root of the equation f(x)=0. This method is similar to the bisection method.

### Write a program to demonstrate the calculation of the root of an equation using Regula-Falsi Method.?

``````PROGRAM RFALSI
C        PROGRAM TO LOCATE THE ROOT OF AN EQUATION USING THE METHOD OF FALSE
C        POSITION(Regula Falsi)
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 GEOMETRIC MEAN
XM=(XR*F(XL)-XL*F(XR))/(F(XL)-F(XR))
CHK=ABS(F(XM))
C        EXIT LOOP IF ROOT FOUND
IF(CHK.LE.0.0001)GOTO 200
C        EXIT LOOP IF UNABLE TO FIND ROOT EVEN AFTER 100+ CYCLES
IF(I.GT.100)GOTO 300
C        GET NEW LOWER AND UPPER LIMITS FOR THE 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