PROGRAM nabejayi
IMPLICIT NONE
INTEGER::k
REAL::a,b,fa,fb,x,e,c,y
!F(x)=x^2 - 2^x
PRINT*
PRINT*," F(X) = X^2 - 2^X X = ? "
PRINT*
PRINT*," Baraye baze [a,b], a & b ra vared konid : "
READ*,a,b
PRINT*," Nerkhe hamgarayi ra vared konid : "
READ*,c
x=0
k=0
DO
k=k+1
y=x
fa=(a**2)-(2**a)
fb=(b**2)-(2**b)
x=(a*fb - b*fa)/(fb-fa)
e=ABS((x-y))/ABS(x)
IF (e < c) THEN
EXIT
END IF
IF ((x*fa) > 0) THEN
a=x
ELSE
IF ((x*fa) < 0) THEN
b=x
ELSE
EXIT
END IF
END IF
END DO
PRINT*," Javab dar tekrar",k," barabar ast ba : X =",x
PRINT*
END