Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


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?


In Mathematica 10.0.2 this problem is gone.


(* 10. *)

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

(* 1. *)

share|improve this question

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
FYI the pb is gone in mathematica 10, which suggest my ContourIntegrate was not buggy :-) – chris Mar 26 '15 at 9:28

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.