ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 21 Jan 2020 10:57:16 +0100possible bug in residue functionhttps://ask.sagemath.org/question/49615/possible-bug-in-residue-function/I compute the residue of a function in two ways, using the fact that it has simple poles.
It seems residue method gives the wrong anser (psi) to be compared to correct answer (chi).
br(x) = 1-x
q1,q2,q3,m = var('q1,q2,q3,m')
assume(q1>0,q2>0,q3>0,m>0)
q4 = (q1*q2*q3)^-1
k = 2
rho = [1,q4]
X = [var("x%d" % i) for i in range(k)]
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(q4*X[i]/X[j]) for i in range(k) if i != j]) for j in range (k)])
chi = (chi1*chi2/chi3).factor()
psi = chi
for xi,rhoi in zip(X,rho):
psi = psi.residue(xi==rhoi).combine().factor()
chi = (chi*(xi-rhoi)).factor().subs({xi: rhoi})
Now we can print chi and psi and see that they're different.
Is this a bug of residue or series?rue82Tue, 21 Jan 2020 10:57:16 +0100https://ask.sagemath.org/question/49615/Roots of multivariable polynomials with respect to one variable?https://ask.sagemath.org/question/44686/roots-of-multivariable-polynomials-with-respect-to-one-variable/This question was previously titled "Finding residues of a huge multivariable rational function."
From my understanding, when computing with huge rational functions, we shouldn't use symbolic variables. However, I don't see how to find roots and residues without symbolic variables. Here is a small scale example of the issue. I have a rational function that looks like below:
$f(u_1,x_1,u_2,x_2,u_3,x_3) = \frac{1}{{\left(u_{1} u_{2} u_{3} - x_{1} x_{2} x_{3}\right)} {\left(u_{1} u_{2} u_{3} - 1\right)} {\left(u_{1} u_{2} - x_{1} x_{2}\right)} {\left(u_{1} u_{2} - 1\right)} {\left(u_{1} - x_{1}\right)} {\left(u_{1} - 1\right)}}$
First I want to solve for $u_1$ in the denominator and find those roots (poles) that have $x_1$ as below.
Then I will loop through the roots and compute the residue of $f$ w.r.t. $u_1$ at those poles.
u1,u2,u3,x1,x2,x3 = var('u1,u2,u3,x1,x2,x3') #symbolic variables
f=1/((u1*u2*u3 - x1*x2*x3)*(u1*u2*u3 - 1)*(u1*u2 - x1*x2)*(u1*u2 - 1)*(u1 - x1)*(u1 - 1))
fden=f.denominator() #denominator of f
list1=fden.roots(u1) #poles of u1
[root for (root, multiplicity) in list1] #list of roots
The output is
[x1*x2*x3/(u2*u3), x1*x2/u2, x1, 1/(u2*u3), 1/u2, 1]
Then we choose those roots that have $x1$
poles1 = [x1*x2*x3/(u2*u3), x1*x2/u2, x1] #choose those that have x1
Finally, we find the residue of $f$ w.r.t $u1$ of the rational function at the poles containing $x1.$
ans1=0
for ff in poles1:
tmp=f.residue(u1==ff)
ans1+=tmp #ans1 is the residue of f w.r.t u1 at all the poles containing x1
ans1
The output is then
1/((u2*u3*x1 - x1*x2*x3)*(u2*u3*x1 - 1)*(u2*x1 - x1*x2)*(u2*x1 - 1)*(x1 - 1)) - 1/((u3*x1*x2 - x1*x2*x3)*(u3*x1*x2 - 1)* (x1*x2 - 1)*u2*(x1 - x1*x2/u2)*(x1*x2/u2 - 1)) + 1/((x1*x2*x3 - 1)*(x1*x2 - x1*x2*x3/u3)*(x1*x2*x3/u3 - 1)*u2*u3*(x1 x1*x2*x3/(u2*u3))*(x1*x2*x3/(u2*u3) - 1))
Then I replace $f$ with $ans1$ to continue to do the same process w.r.t $u2$ and poles containing $x2$ and finally w.r.t $u3$ and poles containing $x3.$ However, this consumes about 800GB of memory on an HPC when I feed it a larger rational function.
Is there a way to find
1. roots of multivariable polynomials with respect to one variable?
2. residue of a rational function avoiding symbolic variables?
Both .roots() and .residue() are not defined for rational functions that are not defined in terms of symbolic variables.HoldenSun, 16 Dec 2018 23:32:23 +0100https://ask.sagemath.org/question/44686/