1 | initial version |
WorksForMe(TM) in Sage 9.1?beta0 ... when done manually:
sage: list(zip(X,rho))
[(x0, 1), (x1, 1/(q1*q2*q3))]
sage: psi.residue(x0==1).combine().factor()
(q1*q2*x1 - 1)*(q1*q3*x1 - 1)*(q2*q3*x1 - 1)*(q1*q2 - x1)*(q1*q3 - x1)*(q2*q3 - x1)*(m - x1)*(m - 1)*q1^2*q2^2*q3^2/((q1*q2*q3*x1 - 1)*(q1*q2*q3 - x1)*(q1*x1 - 1)*(q2*x1 - 1)*(q3*x1 - 1)*m^2*(q1 - x1)*(q2 - x1)*(q3 - x1)*(x1 - 1))
sage: (chi*(x0-1)).factor().subs(x0==1)
(q1*q2*x1 - 1)*(q1*q3*x1 - 1)*(q2*q3*x1 - 1)*(q1*q2 - x1)*(q1*q3 - x1)*(q2*q3 - x1)*(m - x1)*(m - 1)*q1^2*q2^2*q3^2/((q1*q2*q3*x1 - 1)*(q1*q2*q3 - x1)*(q1*x1 - 1)*(q2*x1 - 1)*(q3*x1 - 1)*m^2*(q1 - x1)*(q2 - x1)*(q3 - x1)*(x1 - 1))
sage: bool(psi.residue(x0==1).combine().factor()==(chi*(x0-1)).factor().subs(x0==
....: 1))
True
sage: psi.residue(x1==1/(q1*q2*q3)).combine().factor()
0
sage: (chi*(x1-1/(q1*q2*q3))).factor().subs(x1==1/(q1*q2*q3))
0
sage: bool(psi.residue(x1==1/(q1*q2*q3)).combine().factor()==(chi*(x1-1/(q1*q2*q3
....: ))).factor().subs(x1==1/(q1*q2*q3)))
True
I think that the problem resides in your two last lines of code:
psi = psi.residue(xi==rhoi).combine().factor()
chi = (chi*(xi-rhoi)).factor().subs({xi: rhoi})
which scratch the previous values of psi and chi...
And, BTW, psi
has a native definition in sage: from psi?
:
Signature: psi(x, *args, **kwds)
Docstring:
The digamma function, psi(x), is the logarithmic derivative of the
gamma function.
psi(x) = frac{d}{dx} log(Gamma(x)) =
frac{Gamma'(x)}{Gamma(x)}
We represent the n-th derivative of the digamma function with
psi(n, x) or psi(n, x).
Unless you have a pressing necessity of redefining it, it might be wiser to leave psi
's definition untouched...
2 | No.2 Revision |
WorksForMe(TM) in Sage 9.1?beta0 ... when done manually:
sage: list(zip(X,rho))
[(x0, 1), (x1, 1/(q1*q2*q3))]
sage: psi.residue(x0==1).combine().factor()
(q1*q2*x1 - 1)*(q1*q3*x1 - 1)*(q2*q3*x1 - 1)*(q1*q2 - x1)*(q1*q3 - x1)*(q2*q3 - x1)*(m - x1)*(m - 1)*q1^2*q2^2*q3^2/((q1*q2*q3*x1 - 1)*(q1*q2*q3 - x1)*(q1*x1 - 1)*(q2*x1 - 1)*(q3*x1 - 1)*m^2*(q1 - x1)*(q2 - x1)*(q3 - x1)*(x1 - 1))
sage: (chi*(x0-1)).factor().subs(x0==1)
(q1*q2*x1 - 1)*(q1*q3*x1 - 1)*(q2*q3*x1 - 1)*(q1*q2 - x1)*(q1*q3 - x1)*(q2*q3 - x1)*(m - x1)*(m - 1)*q1^2*q2^2*q3^2/((q1*q2*q3*x1 - 1)*(q1*q2*q3 - x1)*(q1*x1 - 1)*(q2*x1 - 1)*(q3*x1 - 1)*m^2*(q1 - x1)*(q2 - x1)*(q3 - x1)*(x1 - 1))
sage: bool(psi.residue(x0==1).combine().factor()==(chi*(x0-1)).factor().subs(x0==
....: 1))
True
sage: psi.residue(x1==1/(q1*q2*q3)).combine().factor()
0
sage: (chi*(x1-1/(q1*q2*q3))).factor().subs(x1==1/(q1*q2*q3))
0
sage: bool(psi.residue(x1==1/(q1*q2*q3)).combine().factor()==(chi*(x1-1/(q1*q2*q3
....: ))).factor().subs(x1==1/(q1*q2*q3)))
True
I think that the problem resides in your two last lines of code:
psi = psi.residue(xi==rhoi).combine().factor()
chi = (chi*(xi-rhoi)).factor().subs({xi: rhoi})
which scratch the previous values of psi and chi...
And, BTW, psi
has a native definition in sage: from psi?
:
Signature: psi(x, *args, **kwds)
Docstring:
The digamma function, psi(x), is the logarithmic derivative of the
gamma function.
psi(x) = frac{d}{dx} log(Gamma(x)) =
frac{Gamma'(x)}{Gamma(x)}
We represent the n-th derivative of the digamma function with
psi(n, x) or psi(n, x).
Unless you have a pressing necessity of redefining it, it might be wiser to leave psi
's definition untouched...
EDIT :
However, my last two lines are exactly as they shuold be: I want to iterate over the residue operation
Okay. Let's replace your last five lines by:
chi = [(chi1*chi2/chi3).factor()]
psi = chi.copy()
for xi,rhoi in zip(X,rho):
psi.insert(0,psi[0].residue(xi==rhoi).combine().factor())
chi.insert(0,(chi[0]*(xi-rhoi)).factor().subs({xi: rhoi}))
Then check each step:
sage: list(map(lambda u,v:bool(u==v), psi, chi))
[False, True, True]
The first iteration gives the expected result, the second cannot be proved True
.