40 subroutine zbrac( func, x1, x2, succes, funcZero )
45 real(dl),
intent(inout) :: x1
47 real(dl),
intent(inout) :: x2
49 logical ,
intent(out) :: succes
50 real(dl),
intent(in) :: funcZero
52 integer ,
parameter :: ntry = 1000
53 real(dl),
parameter :: FACTOR = 5._dl
55 real(dl) delta, temp, f1,f2
60 if ( x1.eq.x2 ) stop
'you have to guess an initial range in zbrac' 68 f1 = func(x1) -funczero
69 f2 = func(x2) -funczero
74 if ( f1*f2 .lt. 0._dl )
return 80 f1 = func(x1) -funczero
81 f2 = func(x2) -funczero
93 function zbrent(func,x1,x2,tol,funcZero,succes)
109 integer ,
parameter :: ITMAX = 2000
110 real(dl),
parameter :: EPS = 3.d-15
112 real(dl) a,b,c,d,e,fa,fb,fc,p,q,r,s,tol1,xm
119 if((fa.gt.0..and.fb.gt.0.).or.(fa.lt.0..and.fb.lt.0.))
then 126 if((fb.gt.0..and.fc.gt.0.).or.(fb.lt.0..and.fc.lt.0.))
then 132 if(abs(fc).lt.abs(fb))
then 140 tol1=2.*eps*abs(b)+0.5*tol
142 if(abs(xm).le.tol1 .or. fb.eq.0.)
then 146 if(abs(e).ge.tol1 .and. abs(fa).gt.abs(fb))
then 154 p=s*(2.*xm*q*(q-r)-(b-a)*(r-1.))
155 q=(q-1.)*(r-1.)*(s-1.)
159 if(2.*p .lt. min(3.*xm*q-abs(tol1*q),abs(e*q)))
then 172 if(abs(d) .gt. tol1)
then real(dl) function, public zbrent(func, x1, x2, tol, funcZero, succes)
Brent root finding algorithm: This is used to solve numerically the equation func=funcZero by means o...
This module contains the definitions of all the EFTCAMB root finding algorithms.
subroutine, public zbrac(func, x1, x2, succes, funcZero)
Bracketing subroutine: This subroutine does a outward search for the smallest intervall containing a ...