• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Bessel function of the second kind in Javascript

Status
Not open for further replies.

Stojakapimp

Platinum Member
Hi all.

I'm trying to implement Bessel's function of the second kind, Y, in Javascript, but am running into problems. I found a paper that details a good way of approximating Bessel's function of the first kind, J, and have been able to successfully implement that.

But I can't find a similar method for approximating the Y function. On Wikipedia, it's stated that for non-integer a:

Ya(x) = (Ja(x)cos(a*pi) - J-a(x)) / sin(a*pi)

So it appears that I should be able to derive Y by finding J, but I think that the equation for the approximation of J is not valid for negative orders of a.

Wikipedia also states that for integer orders of a:

J-a(x) = (-1)^a*Ja(x)

So I have on equation relating Ya(x) to Ja(x) for non-integer orders of a but then another equation relating J-a(x) to Ja(x) for only integer orders. So it appears that I'm stuck.

Does anybody know of another relationship that I can use in order to either approximating Ya(x) or derive it somehow using Ja(x)?
 
You could try using one of the asymptotic series given here. Those are often a good way to compute special functions like this.

Another way may be to numerically solve the ODE it satisfies, although the log singularity of Y might get in the way. Y is essentially a different function from J only when a is an integer.
 
Bessel functions are simply infinite series, which should be very straightforward to implement. The convergence is highly dependent on the order of the function, so depending on your application, an approximate method might serve you better. If you're going to be doing much of this kind of work, I highly recommend checking out some of the links Born2bwire posted. I have a hard copy of Abramowitz and Stegun (very cheap actually) which I use fairly often. Without knowing anything about the application, it's hard to give any more specific help.

edit: MATLAB's implementation is hidden, but the references they worked from are as follows:

D. E. Amos, "A subroutine package for Bessel functions of a complex argument and nonnegative order", Sandia National Laboratory Report, SAND85-1018, May, 1985.

D. E. Amos, "A portable package for Bessel functions of a complex argument and nonnegative order", Trans. Math. Software, 1986.

These might be more than you bargained for, but they also likely have references that you could look at that would specifically address your problem.
 
We use Amos' code for calculating the Bessel functions. I tried using the code from Numerical Recipes for C++ but it was not accurate enough for my use (semi-infinite integration in the complex plane... joy). You can get a Fortran version of Amos' code from Netlib.
 
matlab2008a/toolbox/matlab/specfun

If you have matlab, their implementations of all things bessel function related is in that location. Look for the .F (fortran) files; these guys are all compiled due to the rather large number of floating point ops needed.
 
When it comes to these problems, unless I'm a super genius (which I am far from), I find that someone else has already done it... even better...
 
Status
Not open for further replies.
Back
Top