# How to get mathematica to work out residues of $f(z)=-\left(\frac{z-1}{z+1}\right)^2\frac{2n/z}{z^{2n}-1}$?

Using the function,

$$f(z)=-\left(\frac{z-1}{z+1}\right)^2\frac{2n/z}{z^{2n}-1}$$,

should give residues as follows:

\begin{align} \ &\left(\operatorname*{Res}_{z=0}(f(z))+\operatorname*{Res}_{z=-1}(f(z))\right) = &\left(2n-\frac23(2n^2+1)\right) \end{align}

However when I use the Mathematica Residue[] function:

Residue[-((z - 1)/(z + 1))^2 (((2 n)/z)/(-1 + z^(2 n))), {z, -1}]
Residue[-((z - 1)/(z + 1))^2 (((2 n)/z)/(-1 + z^(2 n))), {z,  0}]


I do not get the same result.

What do I have to do to get Mathematica to work out these residues?

• For me the second line, Residue[f,{z,0}] doesn't evaluate, only for particular n=1,2,.... Even computing for particular n (I get Residue[f,{z,0}]==2n), the sum doesn't seem to be correct
Apr 4, 2022 at 19:40
• That's not all the residues.
– josh
Apr 4, 2022 at 20:35
• @josh true there are many residue 1 Apr 4, 2022 at 20:40
• @onepound in the original version of my answer there was a shift in the number n which was wrong and is fixed now. Sorry for the confusion. The updated version works fine :-) You can see the exact agreement with the result in the OP. Please note, that to get that result $n>0$
– bmf
Apr 4, 2022 at 22:36

With

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


we generate data

Table[Residue[f[z] /. n -> xx, {z, -1}] +
Residue[f[z] /. n -> xx, {z, 0}], {xx, 1, 17, 1}] and then

FindSequenceFunction[{0, -2, -(20/3), -14, -24, -(110/
3), -52, -70, -(272/3), -114, -140, -(506/3), -200, -234, -(812/
3), -310, -352}, n] // FullSimplify Edit:

Discussing the minimum number of terms

The following seems to be the minimal choice

FindSequenceFunction[
Table[Residue[f[z] /. n -> xx, {z, -1}] +
Residue[f[z] /. n -> xx, {z, 0}], {xx, 1, 4, 1}], n] // FullSimplify


For {xx,1,3,1} Mathematica does not return the formula.

In V13:

Residue[-((z - 1)/(z + 1))^2 (((2 n)/z)/(-1 + z^(2 n))), {z, -1},
Assumptions -> n \[Element] Integers && n > 0]

(*  -(2/3) (1 + 2 n^2)  *)

Assuming[n \[Element] Integers && n > 0,
Simplify@
SeriesCoefficient[
Normal@
Series[-((2 n (-1 + z)^2)/(z (1 + z)^2 (-1 + z^(2 n)))), {z,
0, -1}], {z, 0, -1}]
]

(*  2 n  *)


Not sure why SeriesCoefficient fails on the given function when Series succeeds. (Bug?)

Following bmf's idea:

Total[Map[FindSequenceFunction[#, n] &,
Transpose[
Table[Map[
Residue[-((z - 1)/(z + 1))^2 (2 n)/(
z (-1 + z^(2 n))), {z, #}] &, {0, -1}], {n, 1, 17}]]]]
(*2 n - 2/3 (1 + 2 n^2)*)

• thanks for the additional contribution. Why {n, 1, 17} is this range chosen? Apr 4, 2022 at 20:52
• @onepound you need enough input data for the FindSequenceFunction command to work. There's no standard for how many terms you need and in this case the number 17 is not the minimum. For instance you can check on your machine that FindSequenceFunction[ Table[Residue[f[z] /. n -> xx, {z, -1}] + Residue[f[z] /. n -> xx, {z, 0}], {xx, 1, 4, 1}], n] /. n -> n + 1 // FullSimplify yields the right answer. f[z] is the function from the OP. See also my edit
– bmf
Apr 4, 2022 at 21:11

In version 13 on Windows 10

Residue[-((z - 1)/(z + 1))^2 (((2 n)/z)/(-1 + z^(2 n))), {z, -1},Assumptions->n\[Element] PositiveIntegers]


-2/3 (1 + 2 n^2)

Let us check it through

Table[Residue[-((z - 1)/(z + 1))^2 (((2 n)/z)/(-1 +
z^(2 n))), {z, -1}]+ 2/3*(1 + 2*n^2), {n, 1, 5}]


{0,0,0,0,0}

• yes that works on version 12 too, thanks. Not sure if anything can be done about residue at 0 other than to inspect the function visually for the answer. Apr 4, 2022 at 20:19
• Agreed. Residue[-((z - 1)/(z + 1))^2 (((2 n)/z)/(-1 + z^(2 n))), {z,0},Assumptions->n\[Element] PositiveIntegers] fails. Apr 4, 2022 at 20:21