Group Abstract Group Abstract

Message Boards Message Boards

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

Solve integral with Bessel functions?

Posted 9 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

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

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!

Hi again,

It seems that I have solved the problem with the expression of the integral in terms of the hypergeometric series. By a detailed expansion of the second series in the symbolic formula returned by Integrate, some rearranging of the terms, and taking a limit of Sin[pi*z]/z (with z being the factor in the denominator that is zero) when z tends to zero, one obtains the tripartite formula:

F[m,n,K_]:=(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[?] * 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[Equal]n

F[m,n,K_]:=(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[?] 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

F[m,n,K_]:=F[n,m,K] /; m<n

Unfortunately, I am now surprised to see that such defined function does not get evaluated faster than the former expansion I had (at least for K < 1000). For K > 1000 both formulae are damned slow, and this is very bad news, because I need to do calculations for K > 10^4. So, perhaps the only advantage of the above formulation is that I don't have to worry about the number of terms to be summed in the expansions.

So, my new question is: Is there any method to speed up the evaluations (32 digits or more, and for K > 10^4)? Ideally, it would be nice to derive some asymptotic expansion valid for large K, and use it for calculations. However, attempts to apply a relevant Series[] command to the above expressions lead to error messages.

Leslaw

POSTED BY: Leslaw Bieniasz

Hi,

Yes, the huge time is one big problem, apart from the uncertainty how many terms to sum. But I have BAD NEWS: Your trick produces wrong results!

I have tried the calculations again, and here are some values of the integral obtained by your trick:

for m=n=1, K=10:
0.15432194794717644427531871148044089860

for m=2,n=1, K=10: 0.175921073744037741410030108109402757600

The first value is correct. But the second value is identical to what one would obtain from the fully symbolic formula after omitting the term multiplied by Sin[pi*(m-n)]. This is understandable, since as a result of your trick the infinity is reduced to a finite value, which is then multiplied by Sin[pi*(m-n)]=0, giving zero.

The correct value should be: -0.009153189573949895158506406248625

So, it seems that we are back in the starting point. Any ideas?

Leslaw

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...

Hi,

I don't see my previous message posted about two hours ago, but I have another observation. I think the problem with indeterminate results arises, because there is a coefficient 1+m-n (or 1-m+n) in the term

HypergeometricPFQ[{1/2, 1/2, 1}, {1/2 - m - n, 1 + m - n, 1 - m + n, 3/2 + m + n}, K]

The coefficient contributes to the Pochhammer symbol in the denominator of the hypergeometric series expansion. When m != n there is a possibility that the Pochhammer symbol becomes zero. Hence, the whole term becomes infinite. Later it is multiplied by Sin[pi*(m-n)], which is zero, but of course infinity * 0 is indeterminate.

I therefore think that the trick with replacing integers by reals is a bit a cheating, with a likelyhood of a numerical instability. It would be much better to obtain (if this is possible) an alternative expansion formula that avoids the problem. It is strange that MATHEMATICA cannot detect such a problem automatically, since it obtains an information that m>=0 and n>=0. Isn't this some sort of a bug?

My correct formula for the integral is:

(1/2)*Sum[(-1)^(n+m+mu) * Gamma[mu/2+1/2]^2 * (Sqrt[z])^mu/(Gamma[mu/2+n-m+1] * Gamma[mu/2-n+ m+1] * Gamma[mu/2-n-m+1/2] * Gamma[mu/2+n+m+3/2]), {mu,0,?}]

An attempt to evaluate this formula symbolically produces a yet another representation using hypergeometric series, which again turns useless because of indeterminate results. But perhaps there is some alternative method of representing the formula in such a way so that its evaluation would be fast (without the need to actually sum many terms, which is time-consuming for large K) and simultaneously accurate?

Leslaw

POSTED BY: Leslaw Bieniasz

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

So, do I understand properly that there is no way to obtain the integral values with 32 digits precision (or more)?

Sure, we can by using N[2,32]:

In[1]:= Integrate[
 BesselJ[N[2, 32]*n + 1/2, L]*
  BesselJ[N[2, 32]*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]= (Gamma[
     0.50000000000000000000000000000000 + 
      1.0000000000000000000000000000000 m + 
      1.0000000000000000000000000000000 n] HypergeometricPFQ[{1, 1/2, 
      1/2}, {0.50000000000000000000000000000000 - 
       1.0000000000000000000000000000000 m - 
       1.0000000000000000000000000000000 n, 
      1.50000000000000000000000000000000 + 
       1.0000000000000000000000000000000 m + 
       1.0000000000000000000000000000000 n, 
      1.00000000000000000000000000000000 - 
       1.0000000000000000000000000000000 m + 
       1.0000000000000000000000000000000 n, 
      1.00000000000000000000000000000000 + 
       1.0000000000000000000000000000000 m - 
       1.0000000000000000000000000000000 n}, K])/(2 Gamma[
     1.00000000000000000000000000000000 + 
      1.0000000000000000000000000000000 m - 
      1.0000000000000000000000000000000 n] Gamma[
     1.00000000000000000000000000000000 - 
      1.0000000000000000000000000000000 m + 
      1.0000000000000000000000000000000 n] Gamma[
     1.50000000000000000000000000000000 + 
      1.0000000000000000000000000000000 m + 
      1.0000000000000000000000000000000 n]) + (K^(
    0.50000000000000000000000000000000 + 
     1.0000000000000000000000000000000 m + 
     1.0000000000000000000000000000000 n)
     Gamma[-0.50000000000000000000000000000000 - 
      1.0000000000000000000000000000000 m - 
      1.0000000000000000000000000000000 n] Gamma[
     1.00000000000000000000000000000000 + 
      1.0000000000000000000000000000000 m + 
      1.0000000000000000000000000000000 n]^2 Gamma[
     1.50000000000000000000000000000000 + 
      1.0000000000000000000000000000000 m + 
      1.0000000000000000000000000000000 n] \
HypergeometricPFQ[{1.50000000000000000000000000000000 + 
       1.0000000000000000000000000000000 m + 
       1.0000000000000000000000000000000 n, 
      1.00000000000000000000000000000000 + 
       1.0000000000000000000000000000000 m + 
       1.0000000000000000000000000000000 n, 
      1.00000000000000000000000000000000 + 
       1.0000000000000000000000000000000 m + 
       1.0000000000000000000000000000000 n}, \
{1.50000000000000000000000000000000 + 
       1.0000000000000000000000000000000 m + 
       1.0000000000000000000000000000000 n, 
      2.0000000000000000000000000000000 + 
       2.0000000000000000000000000000000 m + 
       2.0000000000000000000000000000000 n, 
      1.5000000000000000000000000000000 + 0.*10^-32 m + 
       2.0000000000000000000000000000000 n, 
      1.5000000000000000000000000000000 + 
       2.0000000000000000000000000000000 m + 0.*10^-32 n}, 
     K])/(2 \[Pi] Gamma[
     1.5000000000000000000000000000000 + 
      2.0000000000000000000000000000000 m + 0.*10^-32 n] Gamma[
     1.5000000000000000000000000000000 + 0.*10^-32 m + 
      2.0000000000000000000000000000000 n] Gamma[
     2.0000000000000000000000000000000 + 
      2.0000000000000000000000000000000 m + 
      2.0000000000000000000000000000000 n])

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?

The meaning of Evaluate[] is to avoid repeated Integrate[] as you firstly Integrate[] and after Integration[] you assign the result to the function.

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?

I don't know exactly the properties of the function you investigate, but I think that it has discontinuity points which must be investigated by applying the Limit[]. When we use the approximate computations, we have the values near the discontinuity points. It's only my supposition! You must be aware of this!

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!

Hello,

Thanks. This is interesting. I have a hand-made procedure for calculating approximately the values of the integral for various m, n, and K. This is a verified procedure, and I am absolutely sure it gives correct results, but it is somewhat inconvenient in use. Therefore, I would prefer to have an analytical expression. However, the formula returned by MATHEMATICA has the following problems:

1) there is a Sin[ (m-n) * pi] / ((m - n) * pi) factor in the second term, which causes errors when m==n. This can be fixed relatively easily, by introducing a function

MySinc[x]=If[x==0,1,Sin[x]/x]

After this modification, the formula returned by MATHEMATICA gives results for m==n that are consistent with my procedure. Unfortunately, it gives indeterminate results when m != n. So, there is something wrong.

2) In former versions of MATHEMATICA (5, I think) a somewhat different formula was returned, which did not lead to indeterminate results, but numerical values were quite wrong.

If anybody knows how to obtain a correct formula, valid for any integer m >= 0 and n >= 0, and real K > 0, I would greatly appreciate a help (and the correct result !). I am providing once again the integral:

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]

Leslaw

POSTED BY: Leslaw Bieniasz

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

Example:

Say I integrate:

Integrate[x^n, x]

Giving:

x^(1 + n)/(1 + n)

However this does not cover the n = -1 case:

Integrate[x^-1, x]

Gives:

Log[x]
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