I'm doing some computation that requires the use of Spherical Bessel Functions of the 1st kind, at high orders and values.

So, I managed to find this, while running it over a wide range of values. I hit an unexpected 0:

In[209]:= SphericalBesselJ[210, (1/1.5)*2*Pi*1.5*1000/40] // InputForm


For explaining this, (1/1.5)*2*Pi*1.5*1000/40 is about 157.08.

That was strange to me, so I plotted it from 157 to 157.1. It looks smooth, no crazy behavior or zeros.

Trying it slightly on either side of this supposed 0:

In[212]:= SphericalBesselJ[210, (1/1.5)*2*Pi*1.5*1000/40 - .0001] // InputForm


In[213]:= SphericalBesselJ[210, (1/1.5)*2*Pi*1.5*1000/40 + .0001] // InputForm


In fact, I just realized that it does the same thing for all n (the first argument) greater than 200. I can't find anything on the Mathematica page for this function... am I missing something obvious, like I usually am?


edit: Some further poking has revealed that I can also get it to work for n = 71 (for some different values of the second argument). I'm very confused now.

SphericalBesselJ[210, (1/1.5)*2*Pi*1.5*1000/40] // InputForm


Use higher precision input

SphericalBesselJ[210, (1/1.5`20)*2*Pi*1.5`20*1000/40] // InputForm


SphericalBesselJ[210, (2/3)*2*Pi*(3/2)*1000/40] // N[#, 20] & // InputForm


SphericalBesselJ[210, Rationalize[(1/1.5)*2*Pi*1.5*1000/40, 0]] // 
  N[#, 20] & // InputForm


Plot[SphericalBesselJ[210, k], {k, 156, 158}, WorkingPrecision -> 20, 
 PlotPoints -> 51]

enter image description here

  • 2
    $\begingroup$ Maybe it's worth pointing to the documentation of SetPrecision. (+1). $\endgroup$ – Jens Apr 15 '15 at 23:15
  • $\begingroup$ Ahhh, thank you, I should have known. I've been tricked by this before, but I thought I was being careful, checking with InputForm. But I'm still a little confused, why is it going to 0? Why do we find some anomalous point like that? $\endgroup$ – YungHummmma Apr 15 '15 at 23:16
  • 1
    $\begingroup$ See reference.wolfram.com/language/tutorial/… "In most cases, built-in Wolfram Language functions will give you results that have as much precision as can be justified on the basis of your input. ... If you give higher-precision input, the Wolfram Language will use higher precision in its internal calculations, and you will usually be able to get a higher-precision result." You gave very low precision inputs and the resulting precision only justified a 0. result. $\endgroup$ – Bob Hanlon Apr 15 '15 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.