# Finding residues of multi-dimensional complex functions

Say I have a function $f$ of $n$ complex variables, $\{ z_i \}_{i=1}^{i=Nc}$. And then I want to contour integrate the expression such that for each $z_i$ its an integration on an unit circle about the origin in the complex plane:

$$\oint_{\cal C}\cdots \oint_{\cal C} f(z_1,\cdots, z_n) d z_1 .. d z_n$$

I would guess that in some sense this should pick out the "residue" of the n-dimensional complex function $f$. (...I am not exactly sure of a residue interpretaton for such contour integrations on the complex plane...)

I would like to know how to set this up in Mathematica (..hopefully as a residue finding problem..)

-
There's Residue[] for starters, but it can only do one variable at a time... – J. M. Oct 27 '12 at 3:36
@J.M Can one use the Residue function on multivariable integrations? – user6818 Oct 27 '12 at 4:51
Like I said, it can only do one variable at a time... – J. M. Oct 27 '12 at 7:36
The generalization of the CIF is the Bochner-Martinelli formula. One integrates over a 2n-1 real dimensional boundary. – Daniel Lichtblau Feb 4 '13 at 16:01

Let us use the ContourIntegrate function which I think I pinched this function somewhere on this site

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


Let's check it

ContourIntegrate[1/x, x -> Exp[I t], {t, 0, 2 Pi}] - 2 Pi I Residue[1/x, {x, 0}]
(* 0 *)


or just for fun on this path

 ParametricPlot[Exp[I t] (1 + Exp[12 I t]/4) // {Re[#], Im[#]} &, {t, 0, 2 Pi}]


 ContourIntegrate[1/(x - 1/2), x -> Exp[I t] (1 + Exp[12 I t]/4), {t, 0, 2 Pi}]

(* 2I Pi *)


As @J.M. mentions, you can chain contours, but you must proceed one contour at a time

ContourIntegrate[ContourIntegrate[1/(x u), x -> Exp[I t],{t, 0, 2 Pi}],u ->Exp[I t], {t, 0, 2 Pi}]

(* -4Pi^2 *)


and so on...

  ContourIntegrate[ContourIntegrate[ContourIntegrate[1/(x u v), x -> Exp[I t],{t, 0, 2 Pi}],
u ->Exp[I t], {t, 0, 2 Pi}],v ->Exp[I t], {t, 0, 2 Pi}]

(* -8I Pi^3 *)


EDIT

Since I am (personally) interested in a numerical solution, let's see how it can be done numerically as well. Let's define

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


so that

 NContourIntegrate[1/x, x -> Exp[I t], {t, 0, 2 Pi}] - 2 Pi I Residue[1/x, {x, 0}]

(* 0. *)


Or, to consider a wikipedia example, let us integrate $\frac{1}{(z^2+1)^2}$ over the path

 pw[t_] = Piecewise[{{2 Exp[I t], t < Pi}, {-2 + 4 (t - Pi)/Pi, t > Pi}}];
ParametricPlot[pw[t] // {Re[#], Im[#]} &, {t, 0, 2 Pi}]


 NContourIntegrate[1/(x^2 + 1)^2, x -> pw[t], {t, 0, 2 Pi}] // Chop
ContourIntegrate[1/(x^2 + 1)^2, x -> pw[t], {t, 0, 2 Pi}]//FullSimplify

(* 1.5708 and Pi/2 *)


Finally, moving to the multivariate case, if I define

 Clear[h]; h[u_?NumberQ] := NContourIntegrate[1/x/u, x -> Exp[I t], {t, 0, 2 Pi}]


then

 NContourIntegrate[h[u], u -> Exp[I t], {t, 0, 2 Pi}]


yields correctly

  (* -39.47 =N[-4 Pi^2] *)


And more generally

 Clear[h1];h1[u_?NumberQ, v_?NumberQ] :=
NContourIntegrate[1/(x - 1/2)/(u + 1/2)/v, x -> Exp[I t], {t, 0, 2 Pi}];
Clear[h2]; h2[v_?NumberQ] :=
NContourIntegrate[h1[u, v], u -> Exp[I t], {t, 0, 2 Pi}]

NContourIntegrate[h2[v], v -> Exp[I t], {t, 0, 2 Pi}] + I 8  Pi^3

(* 0. *)

-
Thanks for the answer but this function ContourIntegrate" doesn't seem to exists per se. Can you tell me where is that to be accessed? – user6818 Oct 29 '12 at 2:59
I see a definition of your function here, mathematica.stackexchange.com/questions/13734/… . But it seems that you are actually explicitly integrating in this case - then you aren't using the residue theorem really..right? Can this be scaled to large values of $Nc$ ? – user6818 Oct 29 '12 at 3:08
@user6818 the function ContourIntegrate is defined in my answer on the first line ContourIntegrate[f_, par : (z_ -> g_), {t_, a_, b_}] := Integrate[Evaluate[(f /. par) D[g, t]], {t, a, b}]. – chris Oct 31 '12 at 8:59