I am trying to calculate the following integral using the residual method $$ \int_0^{2\pi}dx\frac{n \cos(x)(-a + 2r\cos(x))\sin(n(x+t))-(a-2)\cos(n(x+t))\sin(x)}{(a-2r\cos(x))^2} $$ where $n$ is a positive integer, $a$ is a positive real and $t \in(0,2\pi]$. The integral is done on the circle of radius 1.

Calling $z=e^{ix}$ I tried to calculate the pole contained in the circle $|z|=1$ and use the method of residuals. The poles are identified by the condition $$ (a-r(z^{-1}+z) )^2=0 $$ and that contained in the unit circle is $z_0 = \frac{a-\sqrt{a^2-4r^2}}{2r}$ with the condition $a > 2r$. How can I calculate the residue at this point?

  • 3
    $\begingroup$ Please post your code in Mathematica syntax ?. Nobody feels like retyping your code. $\endgroup$ May 21 at 10:51
  • 1
    $\begingroup$ may be the Residue command could be of use here. $\endgroup$
    – Nasser
    May 21 at 10:55
  • $\begingroup$ The integral written is not around the unit circle. So either what was written is incorrect, or the statement that this is a contour integral is incorrect. $\endgroup$ May 21 at 14:16
  • $\begingroup$ Problem is confussing (1): If integration is around circle then $x=re^{it}$, (2): The statement $t\in (0,2\pi)]$ conflicts with (1) above or else $t$ in integrand is a different $t$, (3): Integrand has no poles if $a>2r$ so integral would be zero. $\endgroup$
    – josh
    May 21 at 14:46
  • 1
    $\begingroup$ People here generally like users to post code as copyable Mathematica code instead of just images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find the meta Q&A, How to copy code from Mathematica so it looks good on this site, helpful $\endgroup$
    – Michael E2
    May 22 at 0:45

2 Answers 2


One has to use the transformation formula for residues over the sum of fractions with simple roots. But the pole is order 2, so there is no residue


But for numeric integers, with a bit of preparing sums of integrands of simple exponentials in indefinite integrals, there are results

  Itg[m_, r_, a_] := 
   Itg[m] = 
   Subtract @@ 
   (((Integrate[#, x] &) /@ 
        (1/(a -2 r Cos[x])^2  * 
            (-2 a r Cos[x]^2 Sin[m ( t + x)] + 
            2 Cos[m ( t + x)] Sin[x] - 
            a Cos[m ( t + x)] Sin[x]) )) // 
    Simplify) /. {{x -> 2 \[Pi]}, {x -> 0}})]

Here are some

   {-((I a^2 E^(-I t) \[Pi])/r^2),n==1},
   {(I a E^(-2 I t) \[Pi] (4-2 a-3 a^2+2 r^2))/(2 r^3),n==2},
   {-((I E^(-3 I t) \[Pi] (a^2 (-6+a (3+4 a))-2 (-2+a+a^2) r^2))/(2 r^4)),n==3}}

Here's an example computing integral 3 ways: (1): Numerically, (2): Using the built-in Residue command, and (3): Using the built-in Series command:

a = 3;
r = 1;
n = 3;
t = Pi/4; 
theInt = (
  n Cos[x] (-a + 2 r Cos[x]) Sin[n (x + t)] - (a - 2) Cos[
     n (x + t)] Sin[x])/(a - 2 r Cos[x])^2;

poles = x /. Solve[(a - 2 r Cos[x]) == 0, x]
poles // N

The poles are in this case $\pm\arccos(3/2)+2k\pi,\quad k\in\mathbb{Z}$ and $\pm \arccos(3/2)\approx \pm 0.962424i$ which are in the unit circle.

(1): First numerically integrate it over the unit circle via $x=e^{i\theta}$:

NIntegrate[(theInt  I Exp[I theta]) /. x -> Exp[I theta], {theta, 0, 2 Pi}]
(* 8.56637*10^-11 + 106.629 I *)

which gives approx $106.629i$ and a small residual real part.

(2): Use Residue to compute the residues at these poles and the Residue Theorem to compute the integral:

r1 = Residue[theInt, {x, -ArcCos[3/2]}] // N
r2 = Residue[theInt, {x, ArcCos[3/2]}] // N
2 Pi I (r1 + r2) // N
 (* 8.48528 - 8.53815 I
    8.48528 + 8.53815 I
    0. + 106.629 I *)

(3): Expand the integrand around each pole using Series and extract the $\displaystyle \frac{1}{x\pm \arccos(3/2)}$ terms as the residues:

series1 = Series[theInt, {x, ArcCos[3/2], 4}];
residue1 = Coefficient[series1, 1/(x - ArcCos[3/2])];
series2 = Series[theInt, {x, -ArcCos[3/2], 4}];
residue2 = Coefficient[series2, 1/(x + ArcCos[3/2])];
residue1 // N
residue2 // N

Out[94]= 8.48528 + 8.53815 I
Out[95]= 8.48528 - 8.53815 I

Your Answer

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

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