2
$\begingroup$

This question already has an answer here:

I want to numerically integrate the following function

$$f(p) = \frac{1}{2\pi i}\int_{\Gamma}\frac{1}{p}\exp\left(\frac{a^{2}}{2}\frac{1}{p}+\frac{b^{2}}{2}p\right)dp$$

where the contour $\Gamma$ is a circle with radius $r$ less than unity and let a and b to be unity

I wrote it like this on Mathematica, but I don't know a possible way to write the integral limits

NIntegrate[1/(2*Pi*I*p)*Exp[1/(2*p) + 1/2*p], {p, ,]
$\endgroup$

marked as duplicate by Jens, user9660, m_goldberg, MarcoB, Sjoerd C. de Vries Jun 20 '16 at 18:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ Welcome to MSE. This link may be helpful: mathematica.stackexchange.com/a/34090/1997 $\endgroup$ – ubpdqn May 19 '16 at 3:05
  • $\begingroup$ Okay, try making the substitution $p=r\exp(i t)$, and take the limits from $0$ to $2\pi$. $\endgroup$ – J. M. will be back soon May 19 '16 at 3:13
  • $\begingroup$ Thanks a lot. It's working, please add it as an answer $\endgroup$ – mostafa sayed May 19 '16 at 7:57
  • $\begingroup$ The sub-section "Applications" of the section "Examples" in NIntegrate's function page has examples on doing integrals over lines, surfaces, volumes, and regions. $\endgroup$ – Anton Antonov May 19 '16 at 15:26
  • 4
    $\begingroup$ Although this is about numerical integration, the maths is exactly the same as in Complex line integral. In particular, you can use my answer there to do the integral simply in the form f[p_]:=1/p Exp[1/(2 p)+1/2 p]; (1/(2 Pi I)) contourIntegrate[ Cos[t]+I Sin[t], f,{t,0,2 Pi}]. The answer is BesselI[0,1]. $\endgroup$ – Jens Jun 20 '16 at 5:15
3
$\begingroup$

Edit: Posted for review.. I'm not sure if this is correct.

making the substitution per comments, p=r Exp[I t] so that dp == r I Exp[I t] dt == I p dt :

With[{r = 2, a = 1, b = 1}, (1/ (2 Pi I)) NIntegrate[
   I Exp[a^2/(2 (r Exp[I t])) + b^2/2 (r Exp[I t])],
   {t, 0 , 2 Pi}]]

1.26607 + 4.24074*10^-15 I

(Note this agrees with the BesselI[0, 1] result per comments)

for the record I first though we could use the region integrate capability:

With[{r = 2, a = 1, b = 1}, 
    (1/ (2 Pi I)) NIntegrate[
       1/((x + I y))*Exp[a^2/(2*(x + I y)) + b^2/2*(x + I y)],
       Element[{x, y}, Circle[{0, 0}, r]]]]

2.82716*10^-16 - 1.13032 I

which is the same result as we get with the first sub but with dp/dt = r:

With[{r = 2, a = 1,  b = 1},
   (1/ (2 Pi I)) NIntegrate[
   1/(Exp[I t])*Exp[a^2/(2*(r Exp[I t])) + b^2/2*(r Exp[I t])],
   {t, 0 , 2 Pi}]]

7.0679*10^-17 - 1.13032 I

$\endgroup$
  • $\begingroup$ Note that BesselI[1,1] is approximately $0.565159 \approx \frac{1}{2}( 1.13032)$. So your second and third expressions are not giving the same result, probably because the two integrals aren't over the same circle ($r = 2$ for the second, $r = 1$ for the third.) $\endgroup$ – Michael Seifert May 19 '16 at 18:15
  • $\begingroup$ right, the first two run with r=1 agree with the BesselI result for r=1 ( That is they are all 3 right or all three wrong ! ) $\endgroup$ – george2079 May 19 '16 at 18:46
  • $\begingroup$ See this page for what looks to be the exact integral in question (with $a = b = 1$ in our integral and $z = 1, n = 0$ in that expression.) Note that this implies that the correct answer should be $I_0(1) \approx 1.26607$, which suggests to me that the last answer is the correct one and the first three are wrong. (Not sure why, though.) $\endgroup$ – Michael Seifert May 19 '16 at 19:03
  • $\begingroup$ On further reflection, I suspect that's what's happening here is that the integration over regions implicitly assumes a line element of the form $dl = \sqrt{dx^2 + dy^2}$ (or $dl = \sqrt{dr^2 + r^2 \, d\theta^2}$) as we integrate around the curve. But for a complex integral in the complex plane, we should be using $dl = dx + i dy$ instead (or $dl = e^{i\theta} dr + i r e^{i\theta} \, d\theta$.) $\endgroup$ – Michael Seifert May 19 '16 at 19:18
  • $\begingroup$ @MichaelSeifert i think that's right, reordered the results in the answer. $\endgroup$ – george2079 May 20 '16 at 16:53

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