Professional Documents
Culture Documents
a r t i c l e
i n f o
a b s t r a c t
Article history:
Received 18 February 2010
Received in revised form 19 August 2010
Accepted 17 November 2010
Available online 26 November 2010
Keywords:
Spherical Bessel functions of rst kind
Spherical Bessel function of second kind
Spherical Hankel functions
Complex arguments
Recurrence
In this short paper, problems with existing algorithms for computing spherical Bessel functions of complex arguments are reported. As a remedy, a revised algorithm based on the recurrence is proposed. The
upper and lower limits for the starting order that can be used in the backward recurrence to reach a
desired accuracy are given. The proposed algorithm is stable and is capable of computing a wide range
of arguments approaching machine accuracy.
2010 Elsevier B.V. All rights reserved.
1. Introduction
Spherical Bessel functions of various kinds, including the Hankel functions, are often used in analyses for wave phenomena
in three-dimensional spaces, such as scattering, propagation, radiation problems of acoustic, electromagnetic and elastic waves.
Bessel functions of complex arguments are needed in such problems that involve attenuation or absorption of various forms.
The literature is rather extensive for the computation of cylindrical Bessel functions of complex arguments. But it is very limited
on their spherical counterparts. This is probably because the rst
few orders spherical Bessel functions have exact yet simple analytical expressions, which removes one of signicant challenges of
the task.
Despite being limited, the literature contains a complete set of
algorithms for the computation of spherical Bessel functions of
various kinds. Shafai, Towaij and Hamid [1] provided algorithms
(hereafter referred to as the STH algorithms) for spherical Bessel
functions of both the rst kind, jn ( z), and the second kind, yn ( z),
based on the recurrence relations of spherical Bessel functions
Forward: bn+1 ( z) =
2n + 1
b n ( z ) b n 1 ( z )
z
2n + 1
Backward: bn1 ( z) =
b n ( z ) b n +1 ( z )
z
(1)
For all the discussions that follow, denote the complex argument as z = re . For jn ( z), the STH j-algorithm uses the forward
recursion up to n [r ], where the square brackets denote the
largest integer not exceeding the enclosed value. The seeds are
j 0 ( z) and j 1 ( z), computed from their respective analytical expressions
(2)
j 0 ( z) =
where bn ( z) is a spherical Bessel function of any kind. Hankel functions can be computed from their denitions using Bessel functions. Boston [2] proposed using a pair of real-valued alternative
recurrences to circumvent the slow complex division in the original complex-valued recurrence.
However, serious aws in the STH algorithms may lead to erroneous results in some circumstances. The investigation to identify
the aws and their remedies prompted this short paper.
Another algorithm is briey discussed in Zhang and Jin [3]. The
idea is to use the backward recurrence to compute jn ( z); use analytical expressions to compute y 0 ( z) and y 1 ( z); then, the Wronskian relation between jn ( z) and yn ( z) is used as an alternative
form of recursion for computing yn ( z). This process works well
for jn ( z) and yn ( z); but when they are combined to obtain Hankel functions, signicant error would occur. The problem for the
case of cylindrical Bessel functions has been discussed in detail by
Heckmann and Dvorak [4].
sin z
z
j 1 ( z) =
sin z
z2
cos z
z
(3)
It then switches to the backward recursion, which starts from order M, with seeds j M ( z) = 0 and j M 1 ( z) set to a rough estimate.
The backward recursion stops at order n = [r ], where it overlaps
with the forward recursion. The results at the overlapped order are
used to determine the factor for normalizing the backward recursion series. Approximations for the starting order M and J M 1 ( z)
664
Fig. 1. The FoM for computed jn (rei ) using the STH j-algorithm with given starting order M for magnitude of argument r ranges from 1 to 500 at three different phase
angles = 0 (left), 0.5 (center) and 1.5 (right). The color scale to the right represents the mapping between FoM values and colors in the images. The magenta area is not
computed, and the black area signies over- or under-ow. (For interpretation of the references to colors in this gure legend, the reader is referred to the web version of
this article.)
Fig. 2. Comparison of log10 | jn (100ei /6 )| computed by the STH j-algorithm with the correct result produced by the proposed algorithm.
y 0 ( z) =
cos z
z
y 1 ( z) =
cos z
z2
sin z
z
(4)
| A1|
FoM = log10
1
| A2|
(5)
are carried out, and the FoM is computed from the resulting series.
The resulting FoM for r ranging from 1 to 500 are shown in Fig. 1
for three different phase angles = 0, 0.5 and 1.5 radians. In this
set of gures, the magenta color signies M < r where the backward recursion is not used; and the black color signies under- or
over-ow. It can be seen that the STH j-algorithm generally works
for real arguments. But, with the increase of the phase angle, the
performance dramatically deteriorates. In the case of = 1.5, the
algorithm is unable to produce results of 10 or more signicant
gures for r > 10; and increasing M does not help.
To further illustrate the problem, log10 | jn (100ei /6 )| is computed for results using the STH j-algorithm and compared with
the correct result, produced by the proposed algorithm. The comparison is shown in Fig. 2. In the segment of forward recursion
(r 100), the STH curve deviates from the correct result after
n > 65. Consequently, the results from the backward recursion is
normalized by a wrong scaling factor, off by approximately an order of 1020 .
It becomes clear that the source of errors in the STH j-algorithm is the forward recursion. It is well known [5] that the recurrence should only be used in the direction of increasing amplitude.
As | jn ( z)| decreases monotonically with n, the forward recursion
should not be used. Unfortunately, STH y-algorithm is also awed
for the same reason. As n increases, | yn ( z)| decreases initially until
665
Fig. 3. Starting order M for the backward recursion to achieve desired 13 signicant gures for spherical Bessel function of all orders up to 50.
n [r ], then it swings to monotonic increasing. A forward recursion will also cause signicant errors. A similar example was
discovered by de Toit [6] in the algorithm for cylindrical Bessel
function of the second kind deployed in an early version (v1.2) of
Wolframs Mathematica: Y n ( z), has the correct value in the order
of 108 , but the software gave a result of 1028 , off by an order of
1020 .
3. The proposed algorithm
To remedy the situation, the following general characteristics of
the spherical Bessel functions of complex arguments and integer
orders are observed rst:
h0
( z) =
ieiz
z
(1),(2)
h1
( z) =
1
z
(1),(2)
i h0
( z) (6)
yn ( z) =
(1 )
i [ jn ( z) hn ( z)]
(2 )
i [ jn ( z) hn ( z)]
when { z} 0
when { z} < 0
(7)
(1 )
hn ( z ) = 2 j n ( z ) + hn ( z )
(1 )
(2 )
or hn ( z) = 2 jn ( z) hn ( z) (8)
In the recursions, the complex division by z is replaced by complex multiplication by 1/ z, for which the complex division is only
performed once, outside the recursion. This gives more eciency
benet than the alternative recurrences proposed by Boston [2].
4. Properties of the proposed algorithm
4.1. Accuracy and starting order
The accuracy of the computed Bessel function can be assessed
by using Wronskian relations between jn ( z) and hn ( z) [9]:
(1),(2)
(1),(2)
( z) =
(9)
z2
The number of signicant gures at the n-th order can be estimated according to
(10)
666
Fig. 4. Starting order M for the backward recursion to achieve desired 14 signicant gures for spherical Bessel function of all orders up to 50.
Fig. 5. Starting order M for the backward recursion to achieve desired 15 signicant gures for spherical Bessel function of all orders up to 50.
In theory, the larger the starting order for the backward recursion, the more accurate the result at the end of the recursion
will be [5]. In practice, it is desirable to use as small as possible a
starting order for a desired accuracy. To determine this starting order M, the following search is performed: starting from M = N + 1,
where N is the maximum order of the Bessel function needed. The
recursions are carried out. Then NSF N is computed according to
Eq. (10), and compared with the target NSF, denoted as NSFt . The
process is repeated while M is increased until NSF N = NSFt .
For NSFt = 13, N = 50, and in the range r 200, Fig. 3 shows
the starting order M as determined by this process, for a series of
phase angles = 0, /6, /4, /3, and /2. It can be approximated by
0.33
+ 9(1
sin ) (11)
667
Fig. 6. Starting order M for the backward recursion to achieve desired 15 signicant gures using remedied algorithm to counter the loss of signicant gure in j 0 ( z).
Fig. 7. Maximum computable starting order for the backward recursion without causing overow. These curves correspond to the following 4 phase angles: 0,
/2.
/6, /3 and
of the two spikes for the case of NSFt = 14, and the removal of
many spikes, but not all, for the case of NSFt = 15, as shown in
Fig. 6. The remaining spikes are caused by the instances of closeto-zero values of jn ( z) during the recursion. It can be remedied by
monitoring the entire recursion process: when | jn ( z)| is detected
to be signicantly smaller than | jn+1 ( z)|, then, in the next step of
recursion computing jn1 ( z), an alternative backward recurrence
using jn+1 ( z) and jn+2 ( z) is used. However, this is a rather costly
proposition for a relatively small gain. After all, an NSFt of 15 is
approaching the limit of the double-precision oating numbers of
a computer; and an NSFt of 14 is sucient for most applications.
of the usual unity. But this does not prevent the overow entirely.
To determine the maximum order the backward recursion can be
used without causing an overow at the end, the following series
of tests is performed. For a selected starting order, the backward
recursion is run without the normalization, and | j 0 ( z)| is monitored. The smallest starting order that causes | j 0 ( z)| to exceed
10300 is denoted as the maximum starting order M max . The test
results for a wide range of r are shown in Fig. 7 for a series of
phase angles: = 0, /6, /4, /3, and /2. It can be seen that
M max decreases as increases, and that a pure imaginary argument has the smallest M max , which can be approximated by
M max = 235 + 50 | z|
Since the backward recursion progresses in the direction of increasing amplitude, an overow may occur before it reaches the
end. To delay the overow, the starting seed is set as 10305 (or
the smallest oating number the computer can represent) instead
(12)
668