Group Abstract Group Abstract

Message Boards Message Boards

0
|
10.5K Views
|
25 Replies
|
1 Total Like
View groups...
Share
Share this post:

Solve integral with Bessel functions?

Posted 10 years ago

Hello,

May I ask anybody to check using MATHEMATICA whether the following integral exist?:

Integrate[BesselJ[2*n + 1/2, L]*BesselJ[2*m + 1/2, L]/Sqrt[L^2 +K], {L, 0, ?}, 
  Assumptions -> n ? Integers && n ? 0 && m ? Integers && m ? 0 && K ? Reals && K > 0]

MATHEMATICA once produced some analytical expression for this integral (a few versions back) but I am not sure with the recent versions. I currently only have an access in the batch mode to the program and cannot find out how to get any visible output, nor whether the output exists.

Leslaw

POSTED BY: Leslaw Bieniasz
25 Replies
Posted 10 years ago

Hi,

Series[function,{x,Infinity,order}]

Have you tried this for the present function before writing? This does not seem to work. There are some messages about singularities or indeterminate results. But (although I cannot yet prove it), I have reasons to believe that there should exist an asymptotic expansion, probably as a series in powers of 1/Sqrt[K].

Leslaw

POSTED BY: Leslaw Bieniasz

No but when I do, I get a result:

out=Integrate[BesselJ[2n+1/2,L]BesselJ[2*m+1/2,L]/Sqrt[L^2+K],{L,0,\[Infinity]},Assumptions->n\[Element]Integers&&n>=0&&m\[Element]Integers&&m>=0&&K\[Element]Reals&&K>0]
Series[out,{K,\[Infinity],4}]

outputs a very large expression. Note that you can not substitute values directly into the output, first you have to apply Normal to it. See the detailed documentation of Series.

POSTED BY: Sander Huisman
Posted 10 years ago

Hi,

Well, precision is one issue, but what about timings when K=10^4 or more? From my tests, I see a dramatic increase of computing times for K=10^4, compared to K= 10^3. Why actually it is so? How the hypergeometric series are evaluated internally by MATHEMATICA? If it is plain summation, then certainly there is no hope to get reasonable times.

If we now have a formula which is actually a series in powers of K, then is there any method to obtain symbolically an equivalent series in 1/K ? Then the summation could be faster for large K. Of course, I realise that this is not a trivial issue, but MATHEMATICA is supposed to encapsulate the whole current mathematical knowledge, so maybe it has some method to achieve the goal?

Leslaw

POSTED BY: Leslaw Bieniasz

Of course you can do series expansions around infinity:

Series[function,{x,Infinity,order}]

But getting any kind of precision might be tricky, you might need a lot of terms!

POSTED BY: Sander Huisman

Dear Leslaw,

The expression for m<n is not well defined. It's not clear what it must be. Nevertheless, for m>=n there are good news:

$MaxExtraPrecision = 300;
f[m_, n_, K_] := \[Piecewise] {
   {(2^(-2 (1 + m + n))*K^(1/2 + m + n)*Gamma[-(1/2) - m - n]*
        Gamma[1 + m + n]*
        HypergeometricPFQ[{1 + m + n, 1 + m + n}, {3/2 + 2 m, 
          3/2 + 2 n, 2 + 2 m + 2 n}, K])/(Sqrt[\[Pi]]*
        Gamma[3/2 + 2 m]*
        Gamma[3/2 + 2 n]) + (HypergeometricPFQ[{1/2, 1/2, 
         1}, {1/2 - m - n, 1 + m - n, 1 - m + n, 3/2 + m + n}, 
        K])/(1 + 2*(m + n)), m == n},
   {(2^(-2 (1 + m + n))*K^(1/2 + m + n) Gamma[-(1/2) - m - n]*
        Gamma[1 + m + n]*
        HypergeometricPFQ[{1 + m + n, 1 + m + n}, {3/2 + 2 m, 
          3/2 + 2 n, 2 + 2 m + 2 n}, K])/(Sqrt[\[Pi]] Gamma[
         3/2 + 2 m]*
        Gamma[3/2 + 2 n]) + (Pochhammer[1/2, 
          m - n]^2/(Pochhammer[1/2 - m - n, m - n]*
          Pochhammer[1 + m - n, m - n]*
          Pochhammer[1 - m + n, m - n - 1]*
          Pochhammer[3/2 + m + n, m - n]))*(K^(m - n))*((-1)^(m - n + 
          1))*(HypergeometricPFQ[{1/2 + m - n, 1/2 + m - n, 
          1}, {1/2 - 2*n, 1 + 2*(m - n), 1, 3/2 + 2*m}, 
         K])/((m - n)*(1 + 2*(m + n))), m > n}
  }

Manipulate[
 Plot[N[f[m, n, K], 32], {K, 0, 300}], {m, 0, 20, 1}, {n, 0, 20, 1}]

More the more, you must be aware of the properties of this function for the large values of K:

Plot[N[f[7, 0, K], 32], {K, 0, 1000}]

enter image description here

That last plot just uses machine precision, to correctly plot it use:

Plot[f[7, 0, K], {K, 0, 1000}, WorkingPrecision -> 32]

No need for N[ ], as K is numerical value anyhow...

POSTED BY: Sander Huisman

Confusion... If to apply WorkingPrecision[] the graph differs from the above! Why?

Machine Precision is not enough precision for large K (probably due to summation):

p1 = Plot[f[7, 0, K], {K, 0, 1000}, WorkingPrecision -> 32, PlotStyle -> Red];
p2 = Plot[f[7, 0, K], {K, 0, 1000}];
Show[{p1, p2, p1}]

You see that for K > 250 the error grows considerably.

So for small K, the results are roughly the same, but the larger the K, the larger the error.

POSTED BY: Sander Huisman

Nice explanation!

I have used N[] in Manipulate[] to decrease the time for graph manipulation!

Posted 10 years ago
POSTED BY: Leslaw Bieniasz
Posted 10 years ago
POSTED BY: Leslaw Bieniasz

This is a sign for a pause :)

Dear Leslaw,

If the number of problematic points is not large, then you can use Piecewise[] function to define the result of integration. So, for the problematic points you define specific values, but for the rest domain you use the exact formula obtained by Integrate[].

Sure, this formula is time consuming. I have tried it to Manipulate...

f[z_, m_, n_] := 1/2 \!\(
\*UnderoverscriptBox[\(\[Sum]\), \(\[Mu] = 1\), \(\[Infinity]\)]\(
\*SuperscriptBox[\((\(-1\))\), \(n + m + \[Mu]\)] 
\*SuperscriptBox[\(Gamma[
\*FractionBox[\(\[Mu]\), \(2\)] + 
\*FractionBox[\(1\), \(2\)]]\), \(2\)] 
\*SuperscriptBox[\((
\*SqrtBox[\(z\)])\), \(\[Mu]\)]/\((Gamma[
\*FractionBox[\(\[Mu]\), \(2\)] + n - m + 1]*Gamma[
\*FractionBox[\(\[Mu]\), \(2\)] - n + m + 1]*Gamma[
\*FractionBox[\(\[Mu]\), \(2\)] - n - m + 
\*FractionBox[\(1\), \(2\)]]*Gamma[
\*FractionBox[\(\[Mu]\), \(2\)] + n + m + 
\*FractionBox[\(3\), \(2\)]])\)\)\)

Manipulate[
 Plot[f[z, m, n], {z, 0, 150}], {m, 0, 20, 1}, {n, 0, 20, 1}]

enter image description here

Unfortunately, it requests a huge ammount of time...

Posted 10 years ago
POSTED BY: Leslaw Bieniasz
Posted 10 years ago

Hi,

So, do I understand properly that there is no way to obtain the integral values with 32 digits precision (or more)? As you say, in order to get any result without error messages, one has to insert coefficients 1.0, 2.0, etc. (that is using Machine precision), which implies that sub-expressions will be calculated also using Machine precision? Is there no way to changing this to arbitrary precision and still get the results? I notice also that the formulae returned are actually different in the fully symbolic case and when you take real coefficients. Is this a normal behaviour with Mathematica?

More questions:

You use the composition Evaluate@Integrate. Will the code work the same if I first generate the formula using Integrate (and real coefficients), and next call Evaluate? I am concerned about efficiency. Apart from high accuracy I also need fast calculations, so I suppose repeating the Integration every time I want to evaluate its value is a waste of time.

I still want to understand what is the reason of the error that occurs when evaluating the fully symbolic formula. Is there no method of finding out where the error actually arises? Some sort of tracing analysis?

Leslaw

POSTED BY: Leslaw Bieniasz

Hi Leslaw,

I try to do what I can to respond to your questions...

4) Isn't it perhaps that Evaluate@Integrate[] uses NIntegrate rather than symbolic formula evaluation?

NIntegrate[] doesn't permit Assumptions:

In[4]:= NIntegrate[
 BesselJ[2 n + 1/2, L] BesselJ[2*m + 1/2, L]/Sqrt[L^2 + K], {L, 
  0, \[Infinity]}, 
 Assumptions -> 
  n \[Element] Integers && n >= 0 && m \[Element] Integers && m >= 0 &&
    K \[Element] Reals && K > 0]

During evaluation of In[4]:= NIntegrate::optx: Unknown option Assumptions in NIntegrate[(BesselJ[2 n+1/2,L] BesselJ[2 m+1/2,L])/Sqrt[L^2+K],{L,0,\[Infinity]},Assumptions->n\[Element]Integers&&n>=0&&m\[Element]Integers&&m>=0&&K\[Element]Reals&&K>0].

Out[4]= NIntegrate[(BesselJ[2 n + 1/2, L] BesselJ[2 m + 1/2, L])/Sqrt[
 L^2 + K], {L, 0, \[Infinity]}, 
 Assumptions -> 
  n \[Element] Integers && n >= 0 && m \[Element] Integers && m >= 0 &&
    K \[Element] Reals && K > 0]

So, we can exclude at this point that result is gratia NIntegrate[]

More the more, I exposed both the results as for your initial formula and for the modified:

In[1]:= Integrate[
 BesselJ[2 n + 1/2, L] BesselJ[2*m + 1/2, L]/Sqrt[L^2 + K], {L, 
  0, \[Infinity]}, 
 Assumptions -> 
  n \[Element] Integers && n >= 0 && m \[Element] Integers && m >= 0 &&
    K \[Element] Reals && K > 0]

Out[1]= (2^(-2 (1 + m + n)) K^(1/2 + m + n)
   Gamma[-(1/2) - m - n] Gamma[
   1 + m + n] HypergeometricPFQ[{1 + m + n, 1 + m + n}, {3/2 + 2 m, 
    3/2 + 2 n, 2 + 2 m + 2 n}, K])/(
 Sqrt[\[Pi]] Gamma[3/2 + 2 m] Gamma[3/2 + 2 n]) + (
 HypergeometricPFQ[{1/2, 1/2, 1}, {1/2 - m - n, 1 + m - n, 1 - m + n, 
    3/2 + m + n}, 
   K] Sin[(m - n) \[Pi]])/((m - n) (1 + 2 m + 2 n) \[Pi])

In[3]:= Integrate[
 BesselJ[2.*n + 1/2, L]*BesselJ[2.*m + 1/2, L]/Sqrt[L^2 + K], {L, 
  0, \[Infinity]}, 
 Assumptions -> 
  n \[Element] Integers && n >= 0 && m \[Element] Integers && m >= 0 &&
    K \[Element] Reals && K > 0]

Out[3]= 1/2 ((
   Gamma[1/2 + 1. m + 1. n] HypergeometricPFQ[{1/2, 1, 1/
      2}, {1/2 - 1. m - 1. n, 3/2 + 1. m + 1. n, 1 - 1. m + 1. n, 
      1 + 1. m - 1. n}, K])/(
   Gamma[1 + 1. m - 1. n] Gamma[1 - 1. m + 1. n] Gamma[
     3/2 + 1. m + 1. n]) + (K^(1/2 + 1. m + 1. n)
       Gamma[-(1/2) - 1. m - 1. n] Gamma[1 + 1. m + 1. n]^2 Gamma[
       3/2 + 1. m + 1. n] HypergeometricPFQ[{1 + 1. m + 1. n, 
        3/2 + 1. m + 1. n, 1 + 1. m + 1. n}, {3/2 + 1. m + 1. n, 
        2 + 2. m + 2. n, 1.5 + 2. n, 1.5 + 2. m}, K])/(\[Pi] Gamma[
       1.5 + 2. m] Gamma[1.5 + 2. n] Gamma[2 + 2. m + 2. n]))

1) I can see that your instruction:

f[m, n, K_] := Evaluate@Integrate[ BesselJ[2.n + 1/2, L]BesselJ[2.*m + 1/2, L]/Sqrt[L^2 + K], {L, 0, [Infinity]}, Assumptions -> n [Element] Integers && n >= 0 && m [Element] Integers && m >= 0 && K [Element] Reals && K > 0]

allows me to generate correct values, but only with an accuracy of several digits, whereas I need to obtain a prescribed number of accurate digits, typically 32 or more. How should I modify the instruction to obtain such results?

Wolfram Language permits calculations with arbitrary precision. In the last formula displayed above, the result is with MachinePrecision.

Remark, that the correct form for the function definition is:

f[m_, n_, K_] := 
 Evaluate@Integrate[
   BesselJ[2.*n + 1/2, L]*BesselJ[2.*m + 1/2, L]/Sqrt[L^2 + K], {L, 
    0, \[Infinity]}, 
   Assumptions -> 
    n \[Element] Integers && n >= 0 && m \[Element] Integers && 
     m >= 0 && K \[Element] Reals && K > 0]

2) I completely don't understand what happens here. Is the actual formula returned by Integrate[] correct or not? Why there are factors 0*infinity detected when the formula is used in symbolically derived form, but not detected in your approach?

I think both the formulas are in the symbolical form, but numeric computing of numerical sub-expressions is done with MachinePrecision.

3) Actually I'd be more happy to first have a fully correct formula that does not cause errors, and next just evaluate its value. Is there no way to do this?

I tried to Integrate symbolically the first formula (to apply differentiation on the result), but Mma didn't return the result:

In[8]:= Integrate[
 BesselJ[2 n + 1/2, L] BesselJ[2*m + 1/2, L]/Sqrt[L^2 + K], L]

Out[8]= \[Integral](BesselJ[1/2 + 2 m, L] BesselJ[1/2 + 2 n, L])/Sqrt[
  K + L^2] \[DifferentialD]L

5) Isn't the multiplication of integers n, m by real coefficients a sort of violation of the initial assumptions? Why this helps?

I explained my understanding above in the context of exact calculus, calculus with arbitrary precision and with MachinePrecision.

Posted 10 years ago

Hello,

First my response to Sander: we have n>=0 and m>=0 here. This was assumed.

Now to Valeriu: well, thanks again, this helps a bit, but not entirely. I am confused and have more questions:

1) I can see that your instruction:

f[m, n, K_] := Evaluate@Integrate[ BesselJ[2.n + 1/2, L]BesselJ[2.*m + 1/2, L]/Sqrt[L^2 + K], {L, 0, [Infinity]}, Assumptions -> n [Element] Integers && n >= 0 && m [Element] Integers && m >= 0 && K [Element] Reals && K > 0]

allows me to generate correct values, but only with an accuracy of several digits, whereas I need to obtain a prescribed number of accurate digits, typically 32 or more. How should I modify the instruction to obtain such results?

2) I completely don't understand what happens here. Is the actual formula returned by Integrate[] correct or not? Why there are factors 0*infinity detected when the formula is used in symbolically derived form, but not detected in your approach?

3) Actually I'd be more happy to first have a fully correct formula that does not cause errors, and next just evaluate its value. Is there no way to do this?

4) Isn't it perhaps that Evaluate@Integrate[] uses NIntegrate rather than symbolic formula evaluation?

5) Isn't the multiplication of integers n, m by real coefficients a sort of violation of the initial assumptions? Why this helps?

Leslaw

POSTED BY: Leslaw Bieniasz

You completely missed my point! My point was:

The general solution (so for every m and n) might not cover all cases for m and n.

not just specifically -1 in my example, that was just to show you that a general solutions might not cover all cases!

POSTED BY: Sander Huisman

I changed a little your formulas (2 by 2.) and obtained the following result:

In[37]:= Integrate[
 BesselJ[2.*n + 1/2, L]*BesselJ[2.*m + 1/2, L]/Sqrt[L^2 + K], {L, 
  0, \[Infinity]}, 
 Assumptions -> 
  n \[Element] Integers && n >= 0 && m \[Element] Integers && m >= 0 &&
    K \[Element] Reals && K > 0]

Out[37]= 1/2 ((
   Gamma[1/2 + 1. m + 1. n] HypergeometricPFQ[{1/2, 1, 1/
      2}, {1/2 - 1. m - 1. n, 3/2 + 1. m + 1. n, 1 - 1. m + 1. n, 
      1 + 1. m - 1. n}, K])/(
   Gamma[1 + 1. m - 1. n] Gamma[1 - 1. m + 1. n] Gamma[
     3/2 + 1. m + 1. n]) + (K^(1/2 + 1. m + 1. n)
       Gamma[-(1/2) - 1. m - 1. n] Gamma[1 + 1. m + 1. n]^2 Gamma[
       3/2 + 1. m + 1. n] HypergeometricPFQ[{1 + 1. m + 1. n, 
        3/2 + 1. m + 1. n, 1 + 1. m + 1. n}, {3/2 + 1. m + 1. n, 
        2 + 2. m + 2. n, 1.5 + 2. n, 1.5 + 2. m}, K])/(\[Pi] Gamma[
       1.5 + 2. m] Gamma[1.5 + 2. n] Gamma[2 + 2. m + 2. n]))

Now, I can animate the result:

f[m_, n_, K_] := 
 Evaluate@Integrate[
   BesselJ[2.*n + 1/2, L]*BesselJ[2.*m + 1/2, L]/Sqrt[L^2 + K], {L, 
    0, \[Infinity]}, 
   Assumptions -> 
    n \[Element] Integers && n >= 0 && m \[Element] Integers && 
     m >= 0 && K \[Element] Reals && K > 0]

t = Flatten@
   Table[Plot[f[m, n, K], {K, 0, 10}], {m, 0, 20, 1}, {n, 0, 20, 1}];

enter image description here

Hope, this will help you!

Posted 10 years ago
POSTED BY: Leslaw Bieniasz
POSTED BY: Sander Huisman

It seems that all is ok but the result is not simple:

In[1]:= Integrate[
 BesselJ[2 n + 1/2, L] BesselJ[2*m + 1/2, L]/Sqrt[L^2 + K], {L, 
  0, \[Infinity]}, 
 Assumptions -> 
  n \[Element] Integers && n >= 0 && m \[Element] Integers && m >= 0 &&
    K \[Element] Reals && K > 0]

Out[1]= (2^(-2 (1 + Global`m + Global`n)) K^(
    1/2 + Global`m + Global`n)
     Gamma[-(1/2) - Global`m - Global`n] Gamma[
     1 + Global`m + 
      Global`n] HypergeometricPFQ[{1 + Global`m + Global`n, 
      1 + Global`m + Global`n}, {3/2 + 2 Global`m, 3/2 + 2 Global`n, 
      2 + 2 Global`m + 2 Global`n}, K])/(Sqrt[\[Pi]]
     Gamma[3/2 + 2 Global`m] Gamma[
     3/2 + 2 Global`n]) + (HypergeometricPFQ[{1/2, 1/2, 
      1}, {1/2 - Global`m - Global`n, 1 + Global`m - Global`n, 
      1 - Global`m + Global`n, 3/2 + Global`m + Global`n}, 
     K] Sin[(Global`m - Global`n) \[Pi]])/((Global`m - Global`n) (1 + 
      2 Global`m + 2 Global`n) \[Pi])
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard