Hypergeometric 1F2

979 views
Skip to first unread message

Guido Walter Pettinari

unread,
Mar 24, 2010, 8:56:06 PM3/24/10
to mpmath
Hello world!

First of all I would like to thank Fredrik and all the contributors
for this wonderful piece of software.

Secondly, I would like to kindly ask for help. I need to compute the
hypergeometric function 1f2 in order to solve some Bessel integrals. I
know that mpmath has hyp1f2, but I would prefer to implement a similar
function by myself into my C code. It would be awesome if you could
help me by answering the following questions:

1) which convergence acceleration technique is used in hyp1f2? Do you
have any reference for that?
2) In "Generalized Hypergeometric Functions" by Lucy Joan Slater it is
mentioned that 1f2 is just the product of two confluent hypergeometric
functions, but no details on how to multiply them is provided. Do you
have any idea?
3) do you know of already available C/Fortran routines that implement
1f2?

So far I only found hypergeo1f2.c in the Cephes mathematical library,
but it just applies the defining hypergeometric series and therefore
is unstable for large values of the parameters.

Thank you very much for any help!

Cheers,

Guido

Fredrik Johansson

unread,
Mar 25, 2010, 4:42:21 PM3/25/10
to mpm...@googlegroups.com
On Thu, Mar 25, 2010 at 1:56 AM, Guido Walter Pettinari <coccoi...@gmail.com> wrote:
Hello world!

First of all I would like to thank Fredrik and all the contributors
for this wonderful piece of software.
 
Hello Guido, and thank you!
 
Secondly, I would like to kindly ask for help. I need to compute the
hypergeometric function 1f2 in order to solve some Bessel integrals. I
know that mpmath has hyp1f2, but I would prefer to implement a similar
function by myself into my C code. It would be awesome if you could
help me by answering the following questions:

1) which convergence acceleration technique is used in hyp1f2? Do you
have any reference for that?

Direct summation is used for small |z|, and an asymptotic series around infinity is used for large |z|. The formula for the asymptotic expansion can be found here:
http://functions.wolfram.com/HypergeometricFunctions/Hypergeometric1F2/06/02/03/

2) In "Generalized Hypergeometric Functions" by Lucy Joan Slater it is
mentioned that 1f2 is just the product of two confluent hypergeometric
functions, but no details on how to multiply them is provided. Do you
have any idea?

As far as I know, this could only be possible for special combinations of parameters, e.g. 1F1(a,2a,z)*1F1(a,2a,-z) = 1F2(a,a+1/2,2a,z^2/4).
 
3) do you know of already available C/Fortran routines that implement
1f2?

Unfortunately not.

Fredrik

Guido Walter Pettinari

unread,
Mar 25, 2010, 6:50:34 PM3/25/10
to mpmath
Hi Fredrik,

thank you very much for your answer! The Wolfram link you gave me is
very useful. However, I am worried about all the Gamma function that
the 1F2 asymptotic expansion involves. I need to evaluate 1F2 for high
values of the parameters (~1e3) and of the argument (~1e4). However,
Gamma(1e3) ~ 1e2500! This is way above double precision. Are you aware
of a painless way to deal with a ratio of Gamma functions that does
not involves evaluating them directly?

The function I need to evaluate is:

1F2( (1+n+m)/2; (3+n+m)/2, 3/2 + m; -x^2/4) * x^(1+n+m) / Gamma (3/2
+ m)

where 'n', 'm' are integers and 'x' is real valued and where both 'm'
and 'x' can be of order 1e3. This ugly function is the primitive of a
Bessel integral I am particularly interested into. By introducing the
variables a = (1+n+m)/2 and b = 3/2 + m, one can rewrite it as:

1F2( a; a+1, b; -x^2/4) * x^(2a) / Gamma(b) .

The above form is very similar to the example you quoted:

1F2(a,a+1/2,2a,z^2/4) = 1F1(a,2a,z)*1F1(a,2a,-z)

The argument is the same apart from the sign, which gives me hope that
also my function can be expressed as a product of 1F1. Do you know if
there is a database of such identities where I can check if my
function is listed?

Thank you again!

Guido

On Mar 25, 8:42 pm, Fredrik Johansson <fredrik.johans...@gmail.com>
wrote:


> On Thu, Mar 25, 2010 at 1:56 AM, Guido Walter Pettinari <
>

> coccoinom...@gmail.com> wrote:
> > Hello world!
>
> > First of all I would like to thank Fredrik and all the contributors
> > for this wonderful piece of software.
>
> Hello Guido, and thank you!
>
> > Secondly, I would like to kindly ask for help. I need to compute the
> > hypergeometric function 1f2 in order to solve some Bessel integrals. I
> > know that mpmath has hyp1f2, but I would prefer to implement a similar
> > function by myself into my C code. It would be awesome if you could
> > help me by answering the following questions:
>
> > 1) which convergence acceleration technique is used in hyp1f2? Do you
> > have any reference for that?
>
> Direct summation is used for small |z|, and an asymptotic series around
> infinity is used for large |z|. The formula for the asymptotic expansion can

> be found here:http://functions.wolfram.com/HypergeometricFunctions/Hypergeometric1F...

Fredrik Johansson

unread,
Mar 25, 2010, 7:08:48 PM3/25/10
to mpm...@googlegroups.com
On Thu, Mar 25, 2010 at 11:50 PM, Guido Walter Pettinari <coccoi...@gmail.com> wrote:
Hi Fredrik,

thank you very much for your answer! The Wolfram link you gave me is
very useful. However, I am worried about all the Gamma function that
the 1F2 asymptotic expansion involves. I need to evaluate 1F2 for high
values of the parameters (~1e3) and of the argument (~1e4). However,
Gamma(1e3) ~ 1e2500! This is way above double precision. Are you aware
of a painless way to deal with a ratio of Gamma functions that does
not involves evaluating them directly?

Yes, the factors can be logarithmized (this applies to the leading factors of the asymptotic series for 1F2 as well). It shouldn't be too hard to find C/Fortran routines for the log-gamma function (or implement it from scratch using Stirling's series).

The function I need to evaluate is:

1F2( (1+n+m)/2; (3+n+m)/2, 3/2 + m; -x^2/4) *  x^(1+n+m) / Gamma (3/2
+ m)

where 'n', 'm' are integers and 'x' is real valued and where both 'm'
and 'x' can be of order 1e3. This ugly function is the primitive of a
Bessel integral I am particularly interested into. By introducing the
variables a = (1+n+m)/2 and b = 3/2 + m, one can rewrite it as:

1F2( a; a+1, b; -x^2/4) * x^(2a) / Gamma(b) .

The above form is very similar to the example you quoted:

 1F2(a,a+1/2,2a,z^2/4) = 1F1(a,2a,z)*1F1(a,2a,-z)

The argument is the same apart from the sign, which gives me hope that
also my function can be expressed as a product of 1F1. Do you know if
there is a database of such identities where I can check if my
function is listed?

The Wolfram functions site is fairly good.

Fredrik

Matt Pitkin

unread,
Sep 8, 2015, 10:10:56 AM9/8/15
to mpmath
Dear Guido,

I know this is a rather old post, but I was wondering whether you did write a C-based 1F2 functions? If you were would you be happy to share it?

Regards,

Matt

Guido Walter Pettinari

unread,
Sep 9, 2015, 3:19:01 PM9/9/15
to mpmath
Hi,

Here is an update on my quest for 1F2 :-)

* I have found a code to compute any Bessel transform using discrete Fourier transforms. It is called FFTLog, and

can be found at this webpage:


http://casa.colorado.edu/~ajsh/FFTLog/


FFTLOG is a Fortran 77 code and is a bit obscure, so I have written a customised F90 driver (supporting only the sine transform) that you can find here:

https://github.com/coccoinomane/fftlog-f90

* Andrew Benson pointed me to an interesting Fortran code by Perger, Nardin and Bhalla to compute arbitrary order hypergeometrical functions:

http://www.ece.mtu.edu/faculty/wfp/codes/pfq.new.f

I have never tried it though.

Hope this helps!

Cheers,
Guido

pfq.new.f
Reply all
Reply to author
Forward
0 new messages