Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.


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}]


 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!


Could anyone please reproduce what seems to be a bug?

share|improve this question
add comment

1 Answer

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.

share|improve this answer
Any suggestions on how to fix it? Also, why did you turn on Community wiki? –  rcollyer Dec 1 '12 at 14:31
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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