Ask Your Question

Residue calculation in Sagemath

asked 2022-05-08 07:19:30 +0200

Anupamsage gravatar image

updated 2022-05-16 09:13:28 +0200

I have done the following calculation in maple, I want to know if we can do it in Sagemath and write a code using the recursive definition. We construct a family of meromorphic function $W_{g,n}(z_1, z_2, \ldots, z_n)$. We consturct it recursively. The intial data given is the following.

$$y(z) = 2 \frac{sinh^{-1}(z/(2a)^{1/2})}{(z^2 +2a)^{1/2}}$$ where $sinh(z)$ is sine hyperbolic funciton can be defined directly in maple as it is.

$$ K(z):=\frac{1}{z(y(z) - y(-z))} \rightarrow 1/2\,{\frac {a}{{z}^{2}}}+1/6-{\frac {{z}^{2}}{90\,a}}+{\frac {{z}^{4} }{378\,{a}^{2}}}-{\frac {23\,{z}^{6}}{28350\,{a}^{3}}}+{\frac {263\,{z }^{8}}{935550\,{a}^{4}}}-{\frac {133787\,{z}^{10}}{1277025750\,{a}^{5} }}+{\frac {157009\,{z}^{12}}{3831077250\,{a}^{6}}}-{\frac {16215071\,{ z}^{14}}{976924698750\,{a}^{7}}}+{\frac {2689453969\,{z}^{16}}{ 389792954801250\,{a}^{8}}}+O \left( {z}^{18} \right) $$ $K(z)$ we define using $sinh(z)$ and take the Taylor series expansion to study the few terms.

Let $W_{0,2}(z_1, z_2): = 1/(z_1 - z_2)^2$

Having this initial data we can construct a tower of $W_{g,n}(z_1, z_2, \ldots, z_n )$ as follows. Let me give few examples that I have computed by hand in maple.

Let's give some examples of how to generate families of functions $$W_{1,1} = Res_{z =0}\, K(z)\frac{1}{z-z_1} W_{0,2}(z,-z) = 1/24\,{\frac {{{\it z1}}^{2}+3\,a}{{{\it z1}}^{4}}} $$ Taking residue at $z =0$ means collecting the $1/z$ ceofficients. $$W_{0,3}(z_1, z_2 , z_3) = Res_{z =0}\, K(z)\frac{1}{z-z_1} \left(W_{0,2}(z_1,-z)W_{0,2}(z_2,z) + W_{0,2}(z_2,-z)W_{0,2}(z_1,z)\right)= {\frac {a}{{{\it z2}}^{2}{{\it z3}}^{2}{{\it z1}}^{2}}} $$

$$W_{1,2}(z_1 , z_2) =Res_{z =0}\, K(z)\frac{1}{z-z_1} \left( W_{0,3}(z,-z,z_2) + W_{0,2}(z,z_2)W_{1,1}(-z)+ W_{0,2}(-z,z_2)W_{1,1}(z)\right)= \ 1/8\,{\frac { \left( 2\,a{{\it z1}}^{2}+5\,{a}^{2} \right) {{\it z2}}^ {4}+ \left( 2\,a{{\it z1}}^{4}+3\,{a}^{2}{{\it z1}}^{2} \right) {{\it z2}}^{2}+5\,{a}^{2}{{\it z1}}^{4}}{{{\it z1}}^{6}{{\it z2}}^{6}}} $$ So let's define $W_{g,n}(z_1 , z_2, \ldots, z_n)$ in general by taking the residue of $$W_{g_1,n_1}(z,\ldots)W_{g_2 , n_2}(-z,\ldots) + W_{g-1 , n+1}()\tag{*}$$ along with the product $ K(z)\frac{1}{z-z_1}$. $W_{g_1,n_1}(z_1 , z_2, \ldots, z_{n_1})$ represent meromorphic functions in $n_1$ variables. And the sum is taken over all such possible combinations. And in case of $W_{g-1 , n+1}(z,-z,z_2 \ldots z_n)$.

In general, if we can write a code where we can give the initial data and then will compute $W_{g,n}(z_1, z_2, \ldots , z_n)$. It should be a recursive definition. I maple I cannot compute more than $(3,1)$ tuples. But with effective Dynamical programming, we definitely can do more. If someone shows me how to do the initial computation in sagemath, then I will try to write the general programme.

edit retag flag offensive close merge delete


@Anupamsage : your notation is ambiguous (unbalanced parentheses) ; could you check ?

EDIT : Edited, corrected and given as an answer.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-05-08 09:09:04 +0200 )edit

I have edited it now.

Anupamsage gravatar imageAnupamsage ( 2022-05-16 09:11:03 +0200 )edit

2 Answers

Sort by » oldest newest most voted

answered 2022-05-17 21:16:27 +0200

dan_fulea gravatar image

updated 2022-05-17 21:18:03 +0200

It is hard to understand in one breath what you have tried and what you finally want.

Here is a simple piece of code getting the residue for that $W_{1,1}$, in code W11. The further implementation has from the point of view of the programmer nothing new to show up. Since i hate (typing) $\sqrt{2a}$ i will use $b$ instead.

assume(b > 0);

y = lambda z: 2*arcsinh( z / b ) / sqrt(z^2 + b^2)
K = lambda z: 1 / z / (y(z) - y(-z))
W02 = lambda z1, z2: 1/(z1 - z2)^2
W11 = lambda z1: ( K(z) / (z - z1) * W02(z, -z) ).residue(z == 0).canonicalize_radical()

print(f'W11(z1) = {W11(z1)}')

This prints:

W11(z1) = -1/48*(3*b^2 + 2*z1^2)/z1^4

There is nothing new involved while taking residues when implementing all the needed recursion. (Please provide code in a follow-up question, if something does not work on the path. Please try to reduce the questions to one issue each, and best this issue is of programatical nature.)

edit flag offensive delete link more


Thanks will do that

Anupamsage gravatar imageAnupamsage ( 2022-05-18 14:12:15 +0200 )edit

I was computing as you shown for W12, though having correct answer for W11 and W03 I am not getting correct answer for W12, I have posted the question with the code here I have to use substiution function.

Anupamsage gravatar imageAnupamsage ( 2022-05-31 06:10:59 +0200 )edit

answered 2022-05-08 16:13:18 +0200

Emmanuel Charpentier gravatar image

updated 2022-05-08 16:18:32 +0200

I suppose that you meant :

$$ y(z)\,=\,\frac{2 \, \sqrt{\operatorname{arsinh}\left(\frac{z}{2 \, a}\right)}}{\sqrt{z^{2} + 2 \, a}}$$

What's the point of working the Taylor series when the analytic answer is available ? Run :

var("z, a")

then :

sage: Poles=[u.rhs() for u in y(z).denominator().solve(z)] ; Poles
[-sqrt(2)*sqrt(-a), sqrt(2)*sqrt(-a)]
sage: [maxima_calculus.residue(y(z), z, u)._sage_() for u in Poles]
[0, 0]


sage: (sinh(z).exponentialize()==x).solve(z)
[z == log(x - sqrt(x^2 + 1)), z == log(x + sqrt(x^2 + 1))]

No need for Taylor series here either, but a need for branch choice...


edit flag offensive delete link more


$$y(z) = 2 \frac{sinh^{-1}(z/(2a)^{1/2})}{(z^2 +2a)^{1/2}}$$ this is the function , so the sqroot on the numerator is on the inside of arcsinh

Anupamsage gravatar imageAnupamsage ( 2022-05-16 09:13:21 +0200 )edit

Can you confirm that you meant :

$$ z \ {\mapsto}\ \frac{2 \, \operatorname{arsinh}\left(\sqrt{\frac{1}{2}} \sqrt{\frac{z}{a}}\right)}{\sqrt{z^{2} + 2 \, a}} $$

In which case, K is :

$$ z \ {\mapsto}\ \frac{1}{2 \, z {\left(\frac{\operatorname{arsinh}\left(\sqrt{\frac{1}{2}} \sqrt{\frac{z}{a}}\right)}{\sqrt{z^{2} + 2 \, a}} - \frac{\operatorname{arsinh}\left(\sqrt{\frac{1}{2}} \sqrt{-\frac{z}{a}}\right)}{\sqrt{z^{2} + 2 \, a}}\right)}} $$

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-05-16 14:08:47 +0200 )edit

I meant $arcsinh( z/ \sqrt(2a))$ there is no square root over $z$ inside the arcsinh.

Anupamsage gravatar imageAnupamsage ( 2022-05-17 01:24:24 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2022-05-08 07:19:30 +0200

Seen: 451 times

Last updated: May 17 '22