program provaFind implicit none real(KIND=8) :: x,FindZeroNewton,xt,eps logical :: trovato real(KIND=8), EXTERNAL :: miafunz,miader,miafunz1,miader1 integer:: maxp maxp=200 eps=.00001 xt=0.3 x=FindZeroNewton(xt,eps,maxp,trovato,miafunz,miader) if(trovato)then write(6,*)'Prima Funzione X=',x else write(6,*)'Non converge' endif x=FindZeroNewton(0.3D0,.0001D0,300,trovato,miafunz1,miader1) if(trovato)then write(6,*)'Seconda Funzione X=',x else write(6,*)'Non converge' endif end program ProvaFind real(KIND=8) function FindZeroNewton(xtt,eps,maxp,trovato,f,f1) implicit none real(KIND=8), INTENT(in) :: xtt,eps integer, INTENT(in) :: maxp logical, Intent(OUT) ::trovato real(KIND=8), EXTERNAL :: f,f1 real(KIND=8) ::xc,xt integer ::i xt=xtt do i=1,maxp xc=xt-f(xt)/f1(xt) if(abs(xc-xt) < eps ) exit xt=xc enddo trovato= i <= maxp FindZeroNewton=xc end function FindZeroNewton real(KIND=8) function miafunz(x) implicit none real(KIND=8) , INTENT(IN) ::x miafunz=x**2-1 end function miafunz real(KIND=8) function miader(x) implicit none real(KIND=8) , INTENT(IN) ::x miader=2*x end function miader real(KIND=8) function miafunz1(x) implicit none real(KIND=8) , INTENT(IN) ::x miafunz1=5*x**3-10 end function miafunz1 real(KIND=8) function miader1(x) implicit none real(KIND=8) , INTENT(IN) ::x miader1=15*x**2 end function