Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12066 > unrolled thread

BesselK, BesselI, BesselJ, BesselY are unnecessarily slow

Started byyenleeloh1@gmail.com
First post2012-10-14 04:19 +0000
Last post2012-10-14 04:19 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  BesselK, BesselI, BesselJ, BesselY are unnecessarily slow yenleeloh1@gmail.com - 2012-10-14 04:19 +0000

#12066 — BesselK, BesselI, BesselJ, BesselY are unnecessarily slow

Fromyenleeloh1@gmail.com
Date2012-10-14 04:19 +0000
SubjectBesselK, BesselI, BesselJ, BesselY are unnecessarily slow
Message-ID<k5degm$se1$1@smc.vnet.net>
Dear Mathgroup readers:

I did timings on Mathematica's implementation of BesselK[n,x], BesselI, BesselJ, and BesselY[n,x] for n=0 and 0<x<10 using the following code: 

xlist = Range[0, 10, 0.0001];
nxmax = Length@xlist;
First@Timing[    BesselK[0, xlist]  ]/nxmax/10^-6 \[Mu]s //  SetAccuracy[#, 2] &
First@Timing[    BesselI[0, xlist]  ]/nxmax/10^-6 \[Mu]s //  SetAccuracy[#, 2] &
First@Timing[    BesselJ[0, xlist]  ]/nxmax/10^-6 \[Mu]s //  SetAccuracy[#, 2] &
First@Timing[    BesselY[0, xlist]  ]/nxmax/10^-6 \[Mu]s //  SetAccuracy[#, 2] &

I am using Mathematica 8.0.1.0 on Mac OS X x86 (32-bit, 64-bit kernel).  The timings were

BesselK[]  2.6 microseconds/call
BesselI[]  17.3 microseconds/call
BesselJ[]  19.0 microseconds/call
BesselY[]  144.1 microseconds/call

The implementation in R   (R 2.15.0 GUI 1.51 Leopard build 64-bit)  is much faster.  In particular, R's besselY() function is 50 times faster than Mathematica's BesselY[] function.  

besselK()   0.75 microsecs/call
besselI()   0.73 microsecs/call
besselJ()   0.75 microsecs/call
besselY()   3.04 microsecs/call

Is Mathematica's implementation really that lame, or am I missing something?  Does anyone have info on timings with GSL, Numerical Recipes, etc?  Please reply by email.  Thank you.

My R code is below:

xlist <- seq(0.0001,10,0.0001)
nxmax <- length(xlist)
sprintf ("%1$g microsecs", system.time (    besselK(xlist, 0)    )[1]/nxmax/10^-6);
sprintf ("%1$g microsecs", system.time (    besselI(xlist, 0)    )[1]/nxmax/10^-6);
sprintf ("%1$g microsecs", system.time (    besselJ(xlist, 0)    )[1]/nxmax/10^-6);
sprintf ("%1$g microsecs", system.time (    besselY(xlist, 0)    )[1]/nxmax/10^-6);



[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web