Zeros of the derivative of the Bessel function in Javascript

Javascript is the language in browser. It is a smart way to store and evaluate some physical formulas in browser. However the build-in Math library is limited to a few functions. The Bessel functions are very useful in electromagnetic in cylindrical coordinate. The eigen modes in the circular wave guide depend on the zeros of the Bessel function or its derivative. There are two ways to find the zeros of the derivative of the Bessel function in Javascript.

No.1 re-realize the algorithm for Bessel functions in Javascript. There is already a such library called Math.js. All mathematical functions are exposed in the global context in that library. I think it is very easy to use and it also support the complex numbers. Here is the example

besselJZero( n, m ) — mth zero of the Bessel function of the first kind of positive order n

besselJZero( n, m, true ) — mth zero of the first derivative of the Bessel function of the first kind of positive order n

There is a special case besselJzero(0,1,true) returns 0 rather than 3.83. It is different from most mathmatical textbook. Use if condition to correct it as

if(m==0){besselJZero(m,n+1,true);}else{besselJZero(m,n,true);}

No.2 use dictionary. It is quick enough for the math.js to find zeros of the Bessel functions. Sometimes a lot of zeros are required frequently in a program. It is better to use dictionary for deficiency. I use mathmatica to generate the 2d dictionary for the Bessel function. There is an old library in mathmatica called NumericalMath`BesselZeros. BesselJPrimeZeros[m, n] gives a list of the first n zeros of the derivative of the order m BesselJ function. Here is the code to generate the 50×50 dictionary:

Table[BesselJPrimeZeros[i, 50], {i, 0, 50}]

Then put the result as an 2D array in Javascript for efficient use. Here is an example the special value is obtained by math.js and the table is calculated by the dictionary.

Leave a Comment