Message Boards Message Boards

Improve speed to obtain numerical values of Bessel function?

Hi.

I would to solve an optical waveguide problem, in which I need to numerically calculate multiple times Bessel functions with complex argument. The corresponding code works, but it is quite slow since it takes Mathematica ages to numerically get the value of the Bessel function.

The following code ilustrates the problem :

Table[N[BesselJ[m, x + I]], {m, 100}, {x, 100}]; // AbsoluteTiming

This takes about 21 second, using Matlab below 1 second with identical precision. It there a way to speed this up to reasonable times (i.e., speed up the Bessel function calculation (incl. complex argument))? I found the following link, but I' m not an expert in C, so I' m not sure what to do : https://mathematica.stackexchange.com/questions/84982/how-to-improve-performance-of-besselj-to-the-level-of-gsl

Thanks in advance,

Markus

POSTED BY: Markus Schmidt
4 Replies
Posted 7 years ago

Evaluating Bessel functions for complex arguments is an expensive undertaking in general. I haven't checked yet, so does MATLAB already support fast complex evaluations of Bessel functions? (I believe their implementation was only limited to real arguments.)

In case a fast routine is really needed, can you give typical ranges for both the real and imaginary parts? A different method of evaluation is often done in the small and in the large (real or imaginary part) cases.

POSTED BY: J. M.

The range of the argument is as follows

BesselJ[m,z]

-10 < Re(z) < 10

-10 < Im(z) < 10

0 <= m <= 20

POSTED BY: Markus Schmidt
Posted 7 years ago

Is $m$ always an integer? If you're letting $m$ be real, I don't see that much hope in making something fast.

POSTED BY: J. M.

Sorry, didn't mention this. m is always an integer.

POSTED BY: Markus Schmidt
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract