! 2.13.f90 ! $Id: 2.13.f90 1.1 2014/02/15 09:05:33 s Exp $ ! program ex2_13 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 stop contains function f(c) implicit none real(8) :: f real(8) :: c,x(0:5) x(0)= -50.0 x(1)= 12.0 x(2)= 12.0 x(3)= 12.0 x(4)= 12.0 x(5)= 12.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_13 ! end