program ppchiadoi
       real a,b,ss,c,e,h,g,k
       integer t
       100 format(5x,i3,5x,6f10.4)
	   print*,'(a,b)='
read*,a,b
print *,'sai so ='
read*,e
if ((f(a)*f(b)).gt.0) then
  print*,'khong hop le'
else
print *,'  buoc        a         b        c         f(a)       f(c)      ss'
ss=999.
t=1
g=f(a)
k=f(b)
if (f(a).eq.0) x=a
if (f(b).eq.0) x=b
do while (ss.gt.e)
  c=(a+b)/2
  h=f(c)
  if ((k*h).lt.0) then
    print 100,t,a,b,c,g,h,ss 
    a=c
    g=h
    ss=b-a
  else if ((g*h).lt.0) then
     print 100,t,a,b,c,g,h,ss
     b=c
     k=h
     ss=b-a
  else if (h.eq.0.) then 
     ss=0.
  end if
    t=t+1
 end do
  print 99,c
  99 format('x=   ',f10.4)
end if
contains
function f(y) result (fx)
        real y
        fx = log(y**2)+2*(y**7)+6 
  end function f
end
  
