! 2.11a.f90 ! $Id: 2.11a.f90 1.1 2014/02/15 08:42:51 s Exp $ ! program ex2_11a implicit none integer :: i real(8) :: c,eps,irr,left,mid,right i=1 eps =1.0e-3 left =0.0 right=1.0 mid=(left+right)/2.0 do while(abs(f(mid))>eps) if(f(mid)>0.0) then right=mid else left=mid end if mid=(left+right)/2.0 i=i+1 end do c=mid irr=1.0/c-1.0 write(*,*) 'c= ', c write(*,*) 'f(c)= ', f(c) write(*,*) 'i= ', i write(*,*) 'irr=1/c-1= ', irr stop contains function f(c) implicit none real(8) :: f real(8) :: c,x(0:5) x(0)=-100.0 x(1)= 30.0 x(2)= 30.0 x(3)= 30.0 x(4)= 30.0 x(5)= 30.0 f=x(0) +x(1)*c +x(2)*c**2 +x(3)*c**3 +x(4)*c**4 +x(5)*c**5 return end function f end program ex2_11a ! end