module hesapkitap public::ikinciderece,ucuncuderece contains !****************************************** subroutine ikinciderece(a,b,c,x1,x2,delta) real,intent(in)::a,b,c real,intent(out)::x1,x2,delta real::kok_delta delta=b**2-4*a*c if (delta>=0.0) then kok_delta=sqrt(delta) x1=(-b+kok_delta)/(2*a) x2=(-b-kok_delta)/(2*a) end if end subroutine ikinciderece !****************************************** function ucuncuderece(a,b,c,d) result(x1) real,intent(in)::a,b,c,d real::x1 real::fx,turevfx,xtemp,fark real,parameter::minimum=1.0e-7 xtemp=1.0 do turevfx=3*a*(xtemp**2)+2*b*xtemp+c if (turevfx==0.0) then xtemp=xtemp+1.0 turevfx=3*a*(xtemp**2)+2*b*xtemp+c else exit end if end do do fx=a*(xtemp**3)+b*(xtemp**2)+c*xtemp+d turevfx=3*a*(xtemp**2)+2*b*xtemp+c x1=xtemp-(fx/turevfx) fark=abs(x1-xtemp) if (fark<=minimum) then x1=xtemp exit end if xtemp=x1 end do end function ucuncuderece end module hesapkitap