4

When I work on some physical problem I needed to know how to get all of first 100 roots of BesselJ[n,x] function -which is a quasi periodic function-, as a List. I tried this code:

FindRoot[BesselJ[0, x], {x, {2, 5, 8, 11, 14}}]

{x -> {2.40483, 5.52008, 8.65373, 11.7915, 14.9309}}

but it's so terrible because you need firstly to know the approximation root as argument, and it'll give you the exact root.

I ask if there any other direct methods.

Update from comment:

Yeah [there is BesselJZero[],] but I want to know what is the code inside this BesselJZero[]. I mean how I can construct it by myself?

[Edit notice: I (Michael E2) discovered the answer to this question, which now sits in a comment. I'd be happy to post the comment as an answer if the community thinks this question should be reopened.]

Michael E2
  • 235,386
  • 17
  • 334
  • 747
El-Mo
  • 141
  • 3

3 Answers3

6

The asymptotic form for $x\rightarrow\infty$ of $J_0(x)$ is $\sqrt{2/(\pi *x)} {\rm Cos}[x-\pi/4]$, with zeros at $x=(k-1/4)\pi$, for $k=1,2,3,...$. These values of $x$ approximate the zeros quite well.

If you want to use FindRoot so you "can construct it by myself", try

Table[FindRoot[BesselJ[0, x], {x, (k - 1/4) Pi}], {k, 1, 100}]

where k is the index of the root. The result is the same as

BesselJZero[0, Range[1.,100.]]

The asymptotic form for $J_n(x)$ is $\sqrt{2/(\pi *x)} {\rm Cos}[x-\pi/4-n \pi/2]$.

KennyColnago
  • 15,209
  • 26
  • 62
  • 1
    The asymptotic form starts to give poor starting points for the roots for small k when the order n is greater than or equal to 6. – Michael E2 Jun 30 '18 at 22:21
6

A more general result than that provided by KennyColnago

The built-in BesselJZero[n, k]

Grid[tab = Table[{n, k, BesselJZero[n, k] // N}, {n, 0, 3}, {k, 3}]]

enter image description here

While this is not the code that Mathematica uses, you can generate your own BesselJZero[n, k] values using FindRoot

Grid[tab2 = Table[
   {n, k, x /. FindRoot[BesselJ[n, x] == 0, {x, (2 k + 1) (2 n + 9)/8}]},
   {n, 0, 3}, {k, 3}]]

enter image description here

Verifying,

tab - tab2 // Chop

(* {{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, {{0, 0,
    0}, {0, 0, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}} *)
Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • 1
    Sorry, @Bob Hanlon, but {x, (2 k + 1) (2 n + 9)/8} are very bad starting values. Regard tab1 = Flatten[ Table[{n, k, BesselJZero[n, k] // N}, {n, 0, 20}, {k, 100}], 1]; and tab2 = Flatten[ Table[{0, 0, x /. First@ FindRoot[BesselJ[n, x] == 0, {x, (2 k + 1) (2 n + 9)/8}, WorkingPrecision -> 20]}, {n, 0, 20}, {k, 100}], 1]; to see, nearly all but the first 3 zeros are wrong. ListPointPlot3D[tab1 - tab2, PlotRange -> {-1000, 0}] . – Akku14 Jun 29 '18 at 07:34
2

An easy straightforward approach

NSolve[{BesselJ[0, x], 0 <= x <= 50}, x]
(*{{x -> 2.40483}, {x -> 5.52008}, {x -> 8.65373}, {x -> 11.7915}, 
{x ->14.9309}, {x -> 18.0711}, {x -> 21.2116}, {x -> 24.3525}, 
{x ->27.4935},{x  -> 30.6346}, {x -> 33.7758}, {x -> 36.9171}, 
{x ->40.0584}, {x -> 43.1998}, {x -> 46.3412}, {x -> 49.4826}}*)

evaluates all roots in the given range.

Unfortunately the possible range seems to be restricted x<55.7655 perhaps for numerical reasons. Adapting WorkingPrecision might help...

Ulrich Neumann
  • 53,729
  • 2
  • 23
  • 55