0
$\begingroup$

I have a complex function defined as below

f[z_] := Cos[z]/((z + 2)*(z + I)*(z - 2*I))

And the path A is defined as the rectangular by y1=-2, y2=3, x1=-1.5 and x2=1.5. I want to deform the path to some circular paths in order to make the integration easier. So I tried to define a circle which centers at (0,0) with radius 3, I am wondering is it correct? And how can I do that in Mathematica?

$\endgroup$
2
  • $\begingroup$ Usually, one would use $z=3\exp(it)$ for a circular contour. $\endgroup$ Dec 17, 2016 at 21:52
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bbgodfrey
    Dec 18, 2016 at 5:13

1 Answer 1

2
$\begingroup$

If making the integration easier is the goal, consider using the residue theorem. First, here's how to do the integral the hard way:

By Definition of Contour Integral

We start by defining the function and the parameters of the rectangular contour. Then we calculate the path integral from the first corner of the rectangle to the second. On this path we have $dz = dx$, so it's straight forward. On the second path, we have $dz = i dy$, so we have to multiply the integral by I. The third and fourth legs are similar. We use NIntegrate, because the result provided by Integrate is messy. Here's the code, and the results.

f[z_] := Cos[z]/((z + 2)*(z + I) (z - 2 I))
{y1, y2, x1, x2} = {-2, 3, -3/2, 3/2};

{ NIntegrate[f[x + I y] /. y -> y1, {x, x1, x2}],
  I NIntegrate[f[x + I y] /. x -> x2, {y, y1, y2}],
  NIntegrate[f[x + I y] /. y -> y2, {x, x2, x1}],
  I NIntegrate[f[x + I y] /. x -> x1, {y, y2, y1}]
  } // Total

(*0.677153 - 2.61625 I *)

By The Residue Theorem

The residue theorem says for any closed path we can calculate the contour integral by adding the residues of the function at any singular points enclosed by the path and multiplying by $2\pi i$. We don't need to deform the path when we work with the residues. Our function has 3 singular points, but only two of them are enclosed by the rectangular path. Those points are $z_1$ and $z_2$ in the following code.

z1 = -I; z2 = 2 I;
r1 = Residue[f[z], {z, z1}];
r2 = Residue[f[z], {z, z2}];
2 π I (r1 + r2) // Simplify
% // N

(* (-(1/10) + I/30) π ((2 + 2 I) Cosh[1] - (2 - I) Cosh[2]) *)
(* 0.677153 - 2.61625 I *)

Here we get a closed form solution that is not too messy.

$\endgroup$
1
  • 3
    $\begingroup$ Note that Integrate[] and NIntegrate[] are both perfectly capable of traversing piecewise-linear contours on their own: NIntegrate[Cos[z]/((z + 2)*(z + I) (z - 2 I)), {z, -3/2 - 2 I, 3/2 - 2 I, 3/2 + 3 I, -3/2 + 3 I, -3/2 - 2 I}]. Just be sure to close the loop. For reference, here's the symbolic result from that approach after simplifying: $$-\frac{\pi}{60e^2}(1+3i)\left((2-2i)e\left(1+e^2\right)+(1+2i)\left(1+e^4\right)\right)$$ $\endgroup$ Dec 18, 2016 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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