The script will manipulate module.exports if available (e.g. in a CommonJS
require context). This is not always desirable. To prevent the behavior,
define DO_NOT_EXPORT_BESSEL
Usage
In all cases, the relevant function takes two arguments (value, order).
The return value is a JS number. NaN signals an error in calculation.
BESSEL.besselj(x, n) computes J_{n}(x)
BESSEL.bessely(x, n) computes Y_{n}(x)
BESSEL.besseli(x, n) computes I_{n}(x)
BESSEL.besselk(x, n) computes K_{n}(x)
For example:
// var BESSEL = require('bessel'); // uncomment this line if in node
BESSEL.besselj(1.5,0) // 0.5118276712499389
BESSEL.bessely(1.5,0) // 0.38244892476502895
BESSEL.besseli(1.5,0) // 1.6467232021476754
BESSEL.besselk(1.5,0) // 0.2138055693236539
var Y = BESSEL.bessely
Y(Math.PI, 5) + Y(Math.PI, 3) - (2 * 4 / Math.PI) * Y(Math.PI, 4) // 0
Testing
make test will run the nodejs-based test.
To generate the excel.tsv test cases, make a 6-column Excel Sheet:
x
n
BESSELI
BESSELJ
BESSELK
BESSELY
x
n
BESSELI(A1,B1)
BESSELJ(A1,B1)
BESSELK(A1,B1)
BESSELY(A1,B1)
To generate the mma.tsv test cases, use the Mathematica Bessel Functions:
bessel
Pure-JS implementation of Bessel functions J,Y,I,K (for the browser and nodejs). Emphasis on correctness and performance for integer order.
The standard notation is used here:
Jis the Bessel function of the first kindYis the Bessel function of the second kindIis the modified Bessel function of the first kindKis the modified Bessel function of the second kindInstallation
With npm:
In the browser:
The browser exposes a variable
BESSELThe script will manipulate
module.exportsif available (e.g. in a CommonJSrequirecontext). This is not always desirable. To prevent the behavior, defineDO_NOT_EXPORT_BESSELUsage
In all cases, the relevant function takes two arguments (
value,order).The return value is a JS number.
NaNsignals an error in calculation.BESSEL.besselj(x, n)computesJ_{n}(x)BESSEL.bessely(x, n)computesY_{n}(x)BESSEL.besseli(x, n)computesI_{n}(x)BESSEL.besselk(x, n)computesK_{n}(x)For example:
Testing
make testwill run the nodejs-based test.To generate the
excel.tsvtest cases, make a 6-column Excel Sheet:BESSELIBESSELJBESSELKBESSELYBESSELI(A1,B1)BESSELJ(A1,B1)BESSELK(A1,B1)BESSELY(A1,B1)To generate the
mma.tsvtest cases, use the Mathematica Bessel Functions:Note: Each function follows Excel semantics
(value, order). Other platforms like Mathematica reverse the argument order.License
Please consult the attached LICENSE file for details. All rights not explicitly granted by the Apache 2.0 License are reserved by the Original Author.
Badges