views:

361

answers:

4

I'm looking for a bessel function in Java that matches the Excel function BESSELI, description provided:


Returns the modified Bessel function, which is equivalent to the Bessel function evaluated for purely imaginary arguments.

Syntax *BESSELI(x,n)*

X is the value at which to evaluate the function.

N is the order of the Bessel function. If n is not an integer, it is truncated.


I have found things that look close, but there are many different types of bessel function...

My other option is to try and derive an approximation but that sounds quite tough. Can anyone give me any good advice on how to represent that excel function in Java?

+1  A: 

JScience provides a class SpecialMathsUtils with modified Bessel functions.

If the Excel function is particularly important to you in it's current form/implementation, you could use Excel directly by starting up an Excel COM object, and invoking the method within Excel. I've done this before using JACOB and it works ok.

However it does depend on your use case, performance criteria and deployment scenario.

Brian Agnew
I am currently trying to move away from excel models for various reasons (including performance) but thanks for your suggestion.
David Turner
Fair enough. Just modified the above re. the JScience stuff
Brian Agnew
The JScience library only appears to offer modified Bessel functions of order 0 and 1, not N as asked for in the question.
Vinay Sajip
Ah. Noted. I wonder if it's easy to modify/enhance ?
Brian Agnew
+1  A: 

Hi

Dig out a copy of Numerical Recipes, which you'll find in Fortran, C and C++ flavours (or, if your library is very good, also in Basic and Pascal) and translate. By the usual standards of exotic functions Bessel functions are quite 'easy'. for further info, you could start at http://mathworld.wolfram.com/BesselFunction.html

Regards

Mark

High Performance Mark
+2  A: 

I image that you should be able to port one of these quite easily:

http://www.astro.rug.nl/~gipsy/sub/bessel.c

Amos Robinson
Look for bessk0, bessk1, bessk.
Vinay Sajip
Just looking at the source code now... looks promising. thanks.
David Turner
A: 

Or refer to Abramowitz and Stegun. They have very good representations of all these functions. Easy to program.

duffymo