# Paths integrals in the complex plane

I can't find how to calculate path integrals of complex functions in the complex plane.

For example: $$\oint_{\mid z \mid =2}\frac{1-e^z+z}{z^3 (z-1)^2}dz$$

-
It'll be helpful if you provide the Mathematica code you've used – Artes Nov 13 '13 at 15:49
Parametrize z = Exp[I*t] and have t vary from 0 to 2*Pi – Daniel Lichtblau Nov 13 '13 at 16:10
Are you sure this question is related to Mathematica ? – Sektor Nov 13 '13 at 16:30
Related (possibly duplicate): Complex line integral and Definite Integral over a path – Jens Aug 11 '15 at 5:02

For this function:

f[z_] := (1 - E^z + z)/(z^3 (z - 1)^2)


there are no branch cuts in the complex plane therefore we simply use Cauchy integral theorem and the related formula of the complex residue, i.e. we sum up residues of the function $f$ in the circle $\mid z \mid =2$. Let's denote $$int = \oint_{\mid z \mid =2}\frac{1-e^z+z}{z^3 (z-1)^2}dz$$ Now we have:

int = 2 Pi I Total[ Residue[f[z], {z, #}] & /@ {0, 1}] // Simplify

 I (-11 + 4 E) Pi


Alternatively we can parametrize z over the given circle z -> 2 E^(I t):

(1 - E^z + z)/(z^3 (z - 1)^2) /. z -> 2 E^(I t)

(E^(-3 I t) (1 - E^(2 E^(I t)) + 2 E^(I t)))/(8 (-1 + 2 E^(I t))^2)


and d z -> 2 I E^(I t) d t, now we have:

Integrate[(E^(-3 I t)(1 - E^(2 E^(I t)) + 2 E^(I t)))/( 8(-1 + 2 E^(I t))^2) 2 I E^(I t),
{t, 0, 2 Pi}]

I (-11 + 4 E) Pi

% // TraditionalForm


-

If a numerical answer is good enough you can just enter the path. As @Artes said it doesn't have to be the circle exactly.

NIntegrate[f[z], {z, 2 - 2 I, 2 + 2 I, -2 + 2 I, -2 - 2 I, 2 - 2 I}]
(* 0. - 0.398582 I *)


Check :

I (-11 + 4 E) Pi // N
(* 0. - 0.398582 I *)


Another suggestion from @Artes (thanks !) : one can use symbolic integration as well and

Integrate[f[z], {z, 2 - 2 I, 2 + 2 I, -2 + 2 I, -2 - 2 I, 2 - 2 I}] // FullSimplify


will reproduce his result.

-
I upvoted your answer, I think it shouldn't be deleted since as far as I know this way of computing integrals couldn't be found in documentation. – Artes Nov 14 '13 at 15:16
@Artes, FYI this usage is the third bullet point under Details and Options for NIntegrate. – chuy Nov 14 '13 at 15:29
@chuy Thanks, in fact there is it, but what about Integrate? Perhaps there is it somewhere, but couldn't find it. – Artes Nov 14 '13 at 15:34