mazkime
07-20-2013, 03:05 AM
Hello,
I use the function 'hypgeo(a,b,c,z)' given in section 6.12 to evaluate the hypergeometric function with complex arguments.
It works pretty well for a large range of values of the arguments, but fails for others.
For instance, with the values
a = cmplx(3.02619478964082,0.366612579197369)
b = cmplx(1.97380521035918,0.366612579197369)
c = cmplx(3.00000000000000,0.0000000000E+000)
z = cmplx(1.21104634938969,0.0000000000E+000)
I get the following answer :
Fortran : (1.1694339666388947,1.3493422205836327)
Python : (108.68967630069800,155.17225602885699)
with both f77 and f90 versions of the Numerical Recipes code.
Mathematica gives the same answer as Python, the error therefore comes from the Fortran.
I did not completely figure out what is made in NR to evaluate the function, but looking at the code I guess the error comes from the insufficient precision used for the integration performed. I tried to increase the precision with the following steps:
changing EPS=1.e-15 and hmin=1.e-15 in subroutine 'hypgeo'
--> no change
EPS=1.e-20.
--> evaluation fails : STOP stepsize smaller than minimum in odeint
hmin=1.e-20 when calling odeint
-->STOP stepsize underflow in bsstep
compilation with real*8 option
--> STOP too many steps in odeint
MAXSTP=1e7 in odeint
--> evaluation takes a very long time, but no change at the end
What else can I do to get the correct evaluation of the hypergeometric function ?
Thanks very much for your help.
I use the function 'hypgeo(a,b,c,z)' given in section 6.12 to evaluate the hypergeometric function with complex arguments.
It works pretty well for a large range of values of the arguments, but fails for others.
For instance, with the values
a = cmplx(3.02619478964082,0.366612579197369)
b = cmplx(1.97380521035918,0.366612579197369)
c = cmplx(3.00000000000000,0.0000000000E+000)
z = cmplx(1.21104634938969,0.0000000000E+000)
I get the following answer :
Fortran : (1.1694339666388947,1.3493422205836327)
Python : (108.68967630069800,155.17225602885699)
with both f77 and f90 versions of the Numerical Recipes code.
Mathematica gives the same answer as Python, the error therefore comes from the Fortran.
I did not completely figure out what is made in NR to evaluate the function, but looking at the code I guess the error comes from the insufficient precision used for the integration performed. I tried to increase the precision with the following steps:
changing EPS=1.e-15 and hmin=1.e-15 in subroutine 'hypgeo'
--> no change
EPS=1.e-20.
--> evaluation fails : STOP stepsize smaller than minimum in odeint
hmin=1.e-20 when calling odeint
-->STOP stepsize underflow in bsstep
compilation with real*8 option
--> STOP too many steps in odeint
MAXSTP=1e7 in odeint
--> evaluation takes a very long time, but no change at the end
What else can I do to get the correct evaluation of the hypergeometric function ?
Thanks very much for your help.