1
$\begingroup$

L = (1/.197)10; p = Table[i, {i, 1, 50}];

Roots of spherical bessel function

ap = Table[N[BesselJZero[3/2, i]], {i, Length[p]}];

Integration of spherical bessel function

NP = Table[ Integrate[SphericalBesselJ[1, (ap[[i]] x)/L]^2x^2, {x, 0, L}], {i, Length[p]}];

$\endgroup$
3
  • 1
    $\begingroup$ Use NIntegrate ? $\endgroup$
    – Syed
    Feb 26 at 6:44
  • $\begingroup$ OK now it works but why? $\endgroup$ Feb 26 at 7:11
  • 1
    $\begingroup$ Related post on Math SE regarding integration of Bessel functions. There will be other posts like this for sure. If an expression/integral etc fails to return an analytical solution, a numerical solution is the next thing to try. $\endgroup$
    – Syed
    Feb 26 at 7:28

1 Answer 1

5
$\begingroup$

I am using

"12.0.0 for Linux x86 (64-bit) (April 7, 2019)"

We have:

L = (1/.197) 10;
p = Table[i, {i, 1, 50}];
ap = Table[N[BesselJZero[3/2, i]], {i, Length[p]}]

First we do the numerical integration

NP = Table[
   NIntegrate[
    SphericalBesselJ[1, (ap[[i]] x)/L]^2 x^2, {x, 0, L}], {i, 
    Length[p]}];

Now we integrate analytically

analytics = 
  Table[Integrate[SphericalBesselJ[1, (ap[[i]] x)/L]^2 x^2, {x, 0, L},
     PrincipalValue -> True], {i, Length[p]}];

Finally we compare the results

NP - analytics // Chop

and we get

{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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0}
$\endgroup$
2
  • 1
    $\begingroup$ I understood. Thank you very much for your help $\endgroup$ Feb 26 at 8:36
  • 1
    $\begingroup$ @AnshulBokade glad I helped $\endgroup$
    – kcr
    Feb 26 at 18:18

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.