program aaa
        real a,b,fa,fb,fc,x1,x2,ss,fn,c
!        integer n
        ham(x9)=log(x9)-2*x9+0.5*x9*x9-5
        c(a1,b1,fa1,fb1)=a1-(fa1*(a1-b1))/(fa1-fb1)
        print*, 'nhap a,b'
1       read*, a,b
        fa=ham(a)
        fb=ham(b)
        if (fa*fb.ge.0.0) then
                print*, 'nhap lai a,b'
                go to 1
        endif
        x2=-99999.0
        n=1
        print*, 'ham la log(x9)-2*x9+0.5*x9*x9-5'
2       x1=c(a,b,fa,fb)
        ss=abs(x1-x2)
        print *,n,a,x1,b,fa,fc,fb,ss
!       format (f2.0,5x,f10.5,2x,f10.5,2x,f10.7,2x,f10.5,2x,f10.7)
        if (ss.le.0.00001) then
                go to 19
        endif
        fc=ham(x1)
        if (fa*fc.le.0.0) then
                b=x1
                fb=fc
        else
                a=x1
                fa=fc
        endif
        x2=x1
        n=n+1
        goto 2
19      print 3, 'nghiem la :',x1,'+- 10^-5'
3       format (a10,f9.5,a10)

end

