--------------------------------------------------------------------------------------------------------------------------------------
PROGRAM bisection
IMPLICIT NONE
INTEGER::k
REAL::x,xo,a,b,e,e1,a1,x1,t1,t2
!y=x**2-e**x
DO
PRINT*,"baze [a,b] ra vared konid : "
PRINT*,"a = "
READ*,a
PRINT*,"b = "
READ*,b
t1=(a**2)-((2.71828182)**a)
t2=(b**2)-((2.71828182)**b)
IF ((t1*t2)>0) THEN
PRINT*,"dar baze [",a,",",b,"] hich javabi vojood nadarad."
PRINT*
ELSE
EXIT
END IF
END DO
xo=0
PRINT*
PRINT*,"nerkh hamgarayi ra vared konid : "
READ*,e
k=0
DO
k=k+1
x=(a+b)/2
a1=(a**2)-((2.71828182)**a)
x1=(x**2)-((2.71828182)**x)
IF ((a1*x1)>0) THEN
a=x
ELSE
IF ((a1*x1) < 0) THEN
b=x
ELSE
EXIT
END IF
END IF
e1=abs(x-xo)/ABS(x)
IF (e1 < e) THEN
EXIT
ELSE
xo=x
END IF
END DO
PRINT*,"javab dar tekrar",k," barabar : ",x
PRINT*
END