2022-11-01 13:30:27 +0200 received badge ● Popular Question (source) 2022-06-20 18:38:32 +0200 received badge ● Popular Question (source) 2022-02-26 22:14:14 +0200 commented answer recognize a rational function is a polynomial Thank you! 2022-02-26 22:14:07 +0200 marked best answer recognize a rational function is a polynomial Is it possible to make sage recognize that a certain rational function is a Laurent polynomial, and treat it as such? A simple example: sage: R = LaurentPolynomialRing(ZZ, ['q1']) sage: R.inject_variables(verbose=False) sage: f = (1/(1-q1) + 1/(1-q1^-1)) sage: parent(f) Fraction Field of Univariate Polynomial Ring in q1 over Integer Ring  Here, f lives correctly in the fraction field. However, it is in particular a polynomial, to which I'd like to apply the polynomial methods, e.g. get its monomial list. Is this possible to achieve? 2022-02-26 15:53:12 +0200 commented answer recognize a rational function is a polynomial the error it gives is: fraction must have unit denominator. 2022-02-26 15:51:53 +0200 commented answer recognize a rational function is a polynomial Thanks, that's also what I thought, but why is it not working e.g. here? R. = LaurentPolynomialRing(ZZ,2) 2022-02-25 17:29:13 +0200 edited question recognize a rational function is a polynomial recognize a rational function is a polynomial Is it possible to make sage recognize that a certain rational function is 2022-02-25 17:28:49 +0200 asked a question recognize a rational function is a polynomial recognize a rational function is a polynomial Is it possible to make sage recognize that a certain rational function as 2022-02-25 16:09:08 +0200 commented answer factorization and multiplication in polynomial ring Thanks, although I thought symbolic computations would be slower here, right? 2022-02-22 10:39:29 +0200 commented answer factorization and multiplication in polynomial ring Thanks a lot! it seems to work well. 2022-02-22 10:39:14 +0200 marked best answer factorization and multiplication in polynomial ring I'm looking for an efficient (i.e. fast enough for $k=4$ and higher) way in Sage to build large rational functions (ratio of polynomials with integer coefficients), and then take residues at simple poles (which I know by construction), by multiplication and taking limit (via subs). I can do that in the symbolic ring, which I believe uses maxima or sympy, but at some point it becomes slow in factorization (say compared to mathematica), so I tried to work with polynomial rings, hoping that singular would be faster. However, at present I have issues: since by default it expands whatever factorized polynomial I define, then it has a hard time factorizing it back (see how long it takes even just to return $\chi$). Moreover, I cannot operate with factorization objects, e.g. I need to multiply them, but it seems this is not allowed. This is my current attempt: def br(x): return 1-1/x def measNew(): k = 3 R = PolynomialRing(ZZ, ['x%d' %p for p in range(k)]+['q1', 'q2', 'q3', 'q4', 'm'], order='invlex') R.inject_variables() K = 1 + q2 + q2^2 + q3 + q4 X = R.gens()[:k] rho = [p.substitute({q4:(q1*q2*q3)^-1}) for p in K.monomials()] rho.reverse() chix = prod([ br(X[j]) for j in range(k)]) chim = prod([ br(X[j]/m) for j in range(k)]) chiup = prod([ prod([ br(q1*q2*X[i]/X[j])*br(q1*q3*X[i]/X[j])*br(q2*q3*X[i]/X[j])*(br(X[i]/X[j]))^2 for i in range(k) if i > j]) for j in range(k)]) chiups = prod([ prod([ br(X[i]/(X[j]*q1*q2))*br(X[i]/(X[j]*q1*q3))*br(X[i]/(X[j]*q2*q3)) for i in range(k) if i > j]) for j in range(k)]) chido = 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)]) chidos = prod([ prod([ br(X[i]/(X[j]*q1))*br(X[i]/(X[j]*q2))*br(X[i]/(X[j]*q3))*br(X[i]/(X[j]*q1*q2*q3)) for i in range(k) if i > j]) for j in range (k)]) dx = prod([ X[j] for j in range(k)]) chinum = (chim*chiup*chiups) chiden = (chix*chido*chidos*dx) chi = (chinum/chiden) # return chi # just to check the intermediate step for xi,rhoi in zip(X,rho): chi = (chi*(xi-rhoi)).factor().subs({xi: rhoi}) return chi.factor()  Any help/suggestions? Thanks. 2022-02-19 21:54:30 +0200 commented answer factorization and multiplication in polynomial ring Yes, this assumption is correct. Let me run a few more checks. Note that k=1 is still broken as I pointed out. 2022-02-18 17:16:08 +0200 commented answer factorization and multiplication in polynomial ring Thanks for helping me. Two comments: it seems that R = PolynomialRing(QQ, is better here, e.g. k=1 does not complain. Wh 2022-02-18 11:29:55 +0200 commented answer factorization and multiplication in polynomial ring Sorry, but this does not look right: cancellations between numerator and denominator of chi will happen along the way (i 2022-02-18 11:22:44 +0200 commented answer factorization and multiplication in polynomial ring Simultaneous substitution is not allowed here: we always compute an iterated residue, for which order matters. 2022-02-18 11:13:35 +0200 commented question factorization and multiplication in polynomial ring I've also reversed rho, to get correct ordering. 2022-02-18 11:12:56 +0200 edited question factorization and multiplication in polynomial ring factorization and multiplication in polynomial ring I'm looking for an efficient (i.e. fast enough for $k=4$ and higher) 2022-02-18 11:11:57 +0200 commented question factorization and multiplication in polynomial ring You're right, that's not correct. 2022-02-17 21:37:29 +0200 edited question factorization and multiplication in polynomial ring factorization and multiplication in polynomial ring I'm looking for an efficient (i.e. fast enough for $k=4$ and higher) 2022-02-17 21:36:29 +0200 commented answer factorization and multiplication in polynomial ring in case I did not make it clear: the order in which residues are taken is crucial 2022-02-17 21:35:45 +0200 commented answer factorization and multiplication in polynomial ring Thanks, let me study your suggestions. Is there a reason why you changed the order from invlex? the actual ordering shou 2022-02-17 21:27:35 +0200 commented question factorization and multiplication in polynomial ring You're right. I never use X[p] with p \geq k, I just didn't know how to code it correctly. Thanks. 2022-02-17 15:09:54 +0200 commented answer fast factorization of ratios of polynomials I wrote a new question, trying to explain what I want and what goes wrong https://ask.sagemath.org/question/61151/factor 2022-02-17 15:07:07 +0200 asked a question factorization and multiplication in polynomial ring factorization and multiplication in polynomial ring I'm looking for an efficient (i.e. fast enough for $k=4$ and higher) 2022-02-11 15:19:36 +0200 commented answer fast factorization of ratios of polynomials the change is that what I called chi, is then used to compute a residue (see the last 3 lines), so one needs to be able 2022-02-10 16:24:13 +0200 commented answer fast factorization of ratios of polynomials do you think using the dictionary could work for the above? 2022-02-10 16:23:39 +0200 commented answer fast factorization of ratios of polynomials But see the edited question, as there will be cancellations. 2022-02-10 14:25:51 +0200 commented answer fast factorization of ratios of polynomials I added a full explanation, sorry for being not complete. I'm not sure using a dictionary is the fastest way here? 2022-02-10 14:24:55 +0200 edited question fast factorization of ratios of polynomials fast factorization of ratios of polynomials I consider polynomials of the form $P=\prod_i (1-1/y_i)$, where each $y_i$ i 2022-02-10 14:24:10 +0200 edited question fast factorization of ratios of polynomials fast factorization of ratios of polynomials I consider polynomials of the form $P=\prod_i (1-1/y_i)$, where each $y_i$ i 2022-02-10 14:20:16 +0200 edited question fast factorization of ratios of polynomials fast factorization of ratios of polynomials I consider polynomials of the form $P=\prod_i (1-1/y_i)$, where each $y_i$ i 2022-02-10 14:14:52 +0200 commented question fast factorization of ratios of polynomials Sure, but let me be more precise. What I asked is only part of the story, and I'd like to understand if using Singular i 2022-02-07 10:19:34 +0200 commented question fast factorization of ratios of polynomials @tmonteil I added a code example, does this clarify my question? 2022-02-07 10:18:44 +0200 edited question fast factorization of ratios of polynomials fast factorization of ratios of polynomials I consider polynomials of the form $P=\prod_i (1-1/y_i)$, where each $y_i$ i 2022-02-06 10:09:03 +0200 received badge ● Notable Question (source) 2022-02-06 10:07:52 +0200 commented question fast factorization of ratios of polynomials Well, numerator and denominator are factored separately, but I want to cancel common factors when taking the ratio, name 2022-02-06 01:55:36 +0200 received badge ● Popular Question (source) 2022-02-05 19:04:30 +0200 edited question fast factorization of ratios of polynomials fast factorization of ratios of polynomials I consider polynomials of the form $P=\prod_i (1-1/y_i)$, where each $y_i$ i 2022-02-05 19:02:55 +0200 asked a question fast factorization of ratios of polynomials fast factorization of ratios of polynomials I consider polynomials of the form $P=\prod_i (1-1/y_i)$, where each $y_i$ i 2021-05-06 20:27:34 +0200 received badge ● Popular Question (source) 2021-02-14 10:05:48 +0200 commented question prove an identity for any integer Thanks, I did see that, although in my case it just prints the sums and does not simplify them to zero. 2021-02-13 21:40:36 +0200 asked a question prove an identity for any integer Let $n$ be a positive integer and $m = (m_1, \ldots, m_n)$ an $n$-dimensional vector of real numbers. Let $g$ be a real number. I want to prove, for any $n$ and $m$, an equality of the form $$\sum_{i=1}^n f_i (m,g) = 0$$ where the function $f_i$ is a rational function of $m$ and $g$. Of course it's easy to check this by substituting finite values of $n$, but is there a way in Sage to prove it for any integer?