Bug fix: Residue returns 0

The function residue computes the residue of an analytic function at a pole of the function.

> residue(sin(z)/z^2,z=0);

1

In some cases residue returns an incorrect answer of 0.

> f:= x/(1+x^7): p:= cos(Pi/7)+I*sin(Pi/7):
residue(f,x=p);

0

> pr:= RootOf(1+Z^7);
residue(f,x=pr);

pr := RootOf(1+_Z^7)

0

This is usually due to the series command not recognizing that the denominator is 0 at the given point.

> series(f,x=p,1);

series((cos(1/7*Pi)+I*sin(1/7*Pi))/(1+(cos(1/7*Pi)+...

> series(f,x=pr,1);

series(RootOf(1+_Z^7)/(1+RootOf(1+_Z^7)^7)+O((x-Roo...

Sometimes this problem can be helped by using a different representation of the point p . In this case using complex exponentials instead of sines and cosines would work.

> residue(f,x=convert(p,exp));

-1/7*(-1)^(2/7)

Another possibility which sometimes works is to change the environment variable Testzero , whose value is the procedure used in series to determine when the leading coefficient is 0. By default this uses Normalizer , another environment variable whose default value is normal . Since residue and series have the remember option, we must use forget to remove results obtained using Normalizer from their remember tables.

> Testzero:= proc(O) evalb(simplify(O)=0) end:
forget(series);
forget(residue);
residue(f,x=pr);

1/7*1/(RootOf(1+_Z^7)^5)

However, this does not work in the case of our p .

> residue(f,x=p);

0

Another way this problem can arise is when you have a floating-point approximation to a singularity rather than an actual singularity.

> pf:= evalf(p);

pf := .9009688678+.4338837393*I

> residue(f,x=pf);

0

In this case it's arguably not Maple's fault: the given point pf is not actually a singularity of f , but only an approximation of a singularity. At pf itself, f has a finite (though large) value.

> eval(f,x=pf);

-253500626.6+633790750.9*I

If you know that f should have a simple pole at the given point, you may be able to calculate the residue "by hand". For example:

> eval(numer(f)/diff(denom(f),x),x=p);

1/7*1/((cos(1/7*Pi)+I*sin(1/7*Pi))^5)

> eval(numer(f)/diff(denom(f),x),x=pf);

-.8906997184e-1-.1116902117*I

See also: convert[exp] , Exact vs floating-point computations , forget , Normalizer , residue , series , Testzero

Maple Advisor Database, R. Israel 2000