# Residue in complex analysis Anonymous

1. is there a way to compute the residue of a meromorphic function $f(z)$ at $z=z_0$ in sage?
2. if so, I'd like to nest such method to compute residue at a flag, $$\operatorname{Res}_F f(x_1,\ldots,x_n) := \operatorname{Res}_{x_1=x_1^,\ldots,x_n=x_n^}\cdots\operatorname{Res}_{x_2=x_2^, x_1=x_1^} \operatorname{Res}_{x_1=x_1^} f(x_1,\ldots,x_n)$$ where starred values denote a numerical value (same as $z_0$ before) and the flag is $$F =([x_1=x_1^,\ldots,x_n=x_n^] \supset \cdots \supset [x_2=x_2^, x_1=x_1^] \supset [x_1=x_1^])$$ Notice the choice of order matters. For example, let $f = \frac1{(1-x_1)(1-x_1 x_2)}$ and $F = ( [x_1=1] \subset [x_2=1, x_1=1])$. Then $$\operatorname{Res}_F f(x_1,x_2) = 1$$
3. if that works, I'd like to build a function that takes as input the point $(x_1,\ldots,x_n)^*$, for various values of $n$, builds $f$ in a certain way, and gives back the residue as a function of the input: is this achievable?
edit retag close merge delete

Sort by » oldest newest most voted

Partial answer : your second question is not legible, and the third doesn't make sanse without the second.

Maxima has a residue function :

(%i2) ? residue

-- Function: residue (<expr>, <z>, <z_0>)

Computes the residue in the complex plane of the expression <expr>
when the variable <z> assumes the value <z_0>.  The residue is the
coefficient of '(<z> - <z_0>)^(-1)' in the Laurent series for
<expr>.

(%i1) residue (s/(s**2+a**2), s, a*%i);
1
(%o1)                           -
2
(%i2) residue (sin(a*x)/x**4, x, 0);
3
a
(%o2)                         - --
6

(\%o2) \mathbf{true}


which can be called via the maxima_methods() interface:

sage: (1/x).maxima_methods().residue(x,0)
1
sage: (1/x).maxima_methods().residue(x,1)
0
sage: tan(x).maxima_methods().residue(x,pi/2)
-1
sage: tan(x).maxima_methods().residue(x,0)
0


HTH,

more

For some reason my code above does not work. I noticed the residue in maxima, but it does not seem to work consistently.

var('x','t') (1/(t^2 - t + x)).maxima_methods().residue(t,(1+sqrt(1-4*x))/2) gives zero.

There's a residue method on symbolic expressions which is documented to do the thing you want, but of course you should check that it does indeed do what you want.

I think you can use:

k=3
br(x)=sqrt(x)-sqrt(1/x)
q1,q2=var('q1,q2')
X=var('x_0,x_1,x_2')
rho=[1,q1,q2]
chi=1/prod([ br(X[j])*br(q1/X[j])*X[j]*br(q2/X[j]) for j in range(k)])
[chi.residue(xi==rhoi) for xi,rhoi in zip(X,rho)]


or, if as in the example that you posted as an answer to the question here, you really want to take the residues iteratively,

for xi,rhoi in zip(X,rho):
chi = chi.residue(xi,rhoi)
print chi


it returns almost instantaneously for me. You may want to simplify the answer a bit, with something like chi.factor() or so.

more

This looks nice, thanks. Last part should have again xi==rhoi. For reference, I edited my answer below, with your suggestion and the actual function I want to use.

I write here the function I had in mind, using the solution I found:

 def br(x):
return sqrt(x)-sqrt(1/x)

import sympy as sp
k=3
q1,q2 = var('q1,q2')
X = sp.symbols('x_0:{}'.format(k))
rho = [1,q1,q2]
chi = 1/prod([ br(X[j])*br(q1/X[j])*X[j]*br(q2/X[j]) for j in range(k)])
for i in range(k):
chi = sp.residue(chi,X[i],rho[i])
chi


The problem is that even for a stupid example such as the one above, it takes forever to compute it.

Here's the same (with the actual function I need), using the above suggested answer:

k=3
br(x)=sqrt(x)-sqrt(1/x)
q1,q2,q3,m=var('q1,q2,q3,m')
# X=var('x_0,x_1,x_2')
# X=var('x_0:{}'.format(k))
X = [var("x%d" % i) for i in range(k)]
rho=[1,q1,q2]
# rho=[1,q1]
chi1 = prod([ br(X[j]/m)/(br(X[j])*X[j]) for j in range(k)])
chi2 = prod([prod([br(q1*q2*X[i]/X[j])*br(q1*q3*X[i]/X[j])*br(q2*q3*X[i]/X[j]) for i in range(k) if i != j]) for j in range(k)])
chi3 = prod([prod([br(q1*X[i]/X[j])*br(q2*X[i]/X[j])*br(q3*X[i]/X[j])*br(q1*q2*q3*X[i]/X[j]) for i in range(k) if i != j]) for j in range (k)])
chi = chi1*chi2/chi3
for xi,rhoi in zip(X,rho):
chi = chi.residue(xi==rhoi)
print chi.factor()


This gives zero (wrong) for k=3 (unless I made a stupid mistake) and it is still slow, but faster than sympy for k=2.

more

Your "stupid example" isn't stupid: finding a series for sqrt(x)) at x=0 involves Laurent series... It's more of a pathological example...