10

Context

Following this question on path integrals in the complex plane, having defined again a numerical and symbolic integrator along a path as

 ContourIntegrate[f_, par : (z_ -> g_), {t_, a_, b_}] := 
   Integrate[Evaluate[(f /. par) D[g, t]], {t, a, b}]

and

 NContourIntegrate[f_, par : (z_ -> g_), {t_, a_, b_}] := 
   NIntegrate[Evaluate[D[g, t] (f /. par) /. t -> t1], {t1, a, b}]

when I try on this path

ParametricPlot[Cos[t] + I (Sin[t] + Cos[2 t]/2) // {Re[#], Im[#]} &, {t, 0, 2 Pi}]

Mathematica graphics

I get numerically (note that I divide by $2\pi \imath$)

NContourIntegrate[1/x, x -> (Cos[t] + I (Sin[t] + Cos[2 t]/2)), {t, 0, 2 Pi}]/(I 2 Pi) 

(* 1. *)

and symbolically (after a couple of minutes)

ContourIntegrate[1/x, x -> Cos[t] + I (Sin[t] + Cos[2 t]/2), 
    {t, 0, 2 Pi}]/(I 2 Pi) // N // Chop

(* 1.57088 *)

which suggests a branch cut problem in the symbolic solution(?) I have evaluated numerically the result of the above integration as it is a couple of pages long. Mathematica graphics

Note interestingly that this result is only equal to $\pi/2$ up to 4 digits!

Question

Could anyone please reproduce what seems to be a bug?

chris
  • 22,860
  • 5
  • 60
  • 149

2 Answers2

9

The numeric result ($2π \cdot i$) is correct by the residue theorem, since

In[25]:= Residue[1/x, {x, 0}]
Out[25]= 1

and your curve's winding number is 1, so

$$∮_{C} \frac{1}{z} \mathrm{d} z = 2π \cdot i \cdot \mathrm{Res}(1/z; z=0) = 2π \cdot i$$

So it looks like your symbolic ContourIntegrate is buggy.

Mechanical snail
  • 2,422
  • 1
  • 16
  • 35
1

In Mathematica 10.0.2 this problem is gone.

$VersionNumber

(* 10. *)

ContourIntegrate[1/x, 
    x -> Cos[t] + I (Sin[t] + Cos[2 t]/2), {t, 0, 2 Pi}]/(I 2 Pi) // 
  N // Chop

(* 1. *)

chris
  • 22,860
  • 5
  • 60
  • 149