[help-gsl] Underflow in gsl_sf_bessel_Jn_array (2008-07-17)
|
From: |
Jonny Taylor <j.m.taylor@............> |
|
Subject: |
Underflow in gsl_sf_bessel_Jn_array |
|
Date: |
Wed, 16 Jul 2008 13:42:44 +0100 |
|
To: |
help-gsl@gnu.org |
Please can somebody advise on using gsl_sf_bessel_Jn_array for small z?
I need to generate Bessel functions up to some n_max (of order 50) for
arbitrary z. I run into problems for small z because the function uses
a downward recurrence to populate the array, and suffers underflow for
large n.
It is not a problem for me if underflow occurs at high n: I am
computing a sum, and if underflow occurs for some n then that will
definitely not affect the overall result.
What I presume I need to do is to determine what n (<= n_max) I need
to pass to gsl_sf_bessel_Jn_array in order to avoid underflow.
Unfortunately that doesn't seem to be trivial to compute (which is not
really surprising). The best strategies I can come up to are to use a
lookup which gives the minimum z which works for a given cutoff n, or
to just try calling gsl_sf_bessel_Jn_e for some trial n and then
reducing n if I get an error. That is not ideal, though, as I'll need
to install an error handler and I want to do this in threaded code.
Can anybody suggest a better strategy to take? It seems like this
should be a relatively simple thing to ask, but I can't come up with a
simple way of achieving it...
Thanks
Jonny