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? 2020-01-24 11:49:02 +0200 commented answer possible bug in residue function In particular, if you substitute e.g. q1=3, q2=5, q3=7, m=11 you should see that chi[0] and psi[0] are different. 2020-01-22 17:22:22 +0200 received badge ● Teacher (source) 2020-01-22 17:22:22 +0200 received badge ● Self-Learner (source) 2020-01-22 13:35:22 +0200 received badge ● Commentator 2020-01-22 13:35:22 +0200 commented answer symmetric group: get back conjugacy class from its generators Looking at both your answer and mine, would it be possible to outpu a number between 1 and 11 instead of 'Subgroup generated by...'? 2020-01-22 13:29:14 +0200 commented answer symmetric group: get back conjugacy class from its generators @rburing Thanks, indeed I corrected. 2020-01-22 11:55:34 +0200 answered a question symmetric group: get back conjugacy class from its generators This is my attempt (edit): R = PolynomialRing(QQ, 4, ["q1","q2","q3","q4"]) q1,q2,q3,q4 = R.gens() f = 1+q1+q2 # for example G = SymmetricGroup(4) r = [] for g in G: if (f * g) == f: r.append(g) H = PermutationGroup(r) return ConjugacyClass(H, G) 2020-01-22 11:16:56 +0200 asked a question symmetric group: get back conjugacy class from its generators The function below returns a list r of elements of the symmetric group that leave a certain polynomial f fixed. I know (by the properties of f that I'm not specifiying here) that the list of g's that leave it fixed generate one of the 11 conjugacy subclasses of S(4). What is the best way to output from my code below a number between 1 and 11 that corresponds to such subclass? R = PolynomialRing(QQ, 4, ["q1","q2","q3","q4"]) q1,q2,q3,q4 = R.gens() f = 1 + q1 +q2 # in general, it is a polynomial with unit coefficients in the ring R G = SymmetricGroup(4) cl = G.conjugacy_classes_subgroups() r = [] for g in G: if (f * g) == f: r.append(g) return r 2020-01-22 10:55:21 +0200 commented answer possible bug in residue function Thanks for the tip about not redefining psi. However, my last two lines are exactly as they shuold be: I want to iterate over the residue operation. The problem I wanted to point out is that residue/series fails to give the correct result. Do you agree? Btw, do email notifications work for you? 2020-01-21 14:41:37 +0200 asked a question [meta] email alerts not working Despite correctly setting my 'email alerts' preferences, I do not get any email from the forum upon answers or comments. Does anyone know how to solve the issue? (I'm using Gmail for email.) 2020-01-21 13:39:46 +0200 received badge ● Nice Question (source) 2020-01-21 12:07:05 +0200 asked a question how to best simplify/factor symbolic expressions Define symbolic expressions T3 and T3s. q1,q2,q3 = var('q1,q2,q3') T3 = (q1^2*q2^2 + 1)*(q1^2*q3^2 + 1)*(q2^2*q3^2 + 1)*(q1*q2 + 1)*(q1*q2 - 1)*(q1*q3 + 1)*(q1*q3 - 1)*(q2*q3 + 1)*(q2*q3 - 1)/((q1^2*q2^2*q3^2 + 1)*(q1*q2*q3 + 1)*(q1*q2*q3 - 1)*(q1^2 + 1)*(q2^2 + 1)*(q3^2 + 1)*(q1 + 1)*(q1 - 1)*(q2 + 1)*(q2 - 1)*(q3 + 1)*(q3 - 1)) T3s = (q1^4*q2^4 - 1)*(q1^4*q3^4 - 1)*(q2^4*q3^4 - 1)/((q1^4*q2^4*q3^4 - 1)*(q1^4 - 1)*(q2^4 - 1)*(q3^4 - 1)) Is there any method to reduce T3 to its simpler (at least for a human) form T3s in Sage? 2020-01-21 10:57:16 +0200 asked a question 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? 2020-01-13 11:25:54 +0200 commented question how to best simplify product of square roots Ok, I guess I can be happy adding a .factor() after that :) 2020-01-13 11:24:02 +0200 commented question how to best simplify product of square roots @eric_g I understand, but still simplify_chain_real messes things up, look at the second example I added. 2020-01-12 11:17:34 +0200 asked a question how to best simplify product of square roots I'd like to simplify expressions like p1,p2,p3 = var('p1 p2 p3') assume(p1>0,p2>0,p3>0) R = p1*p2*sqrt(p3)*sqrt(p3/p1)*sqrt(p3/p2) R without using R.canonicalize_radical(), which unfortunately messes up other factors. I understand there are some options using R.simplify_chain_real(), but what else can I try? Let us see an example where also R.simplify_chain_real() messes things up: p1,p2,p3 = var('p1 p2 p3') assume(p1>0,p2>0,p3>0) # R = p1*p2*sqrt(p3)*sqrt(p3/p1)*sqrt(p3/p2) R = p1*p2*sqrt(p3)*sqrt(p3/p1)*sqrt(p3/p2)/((p1 - p3)*(p2 - p3)*(p3 - 1)) %display latex from sage.manifolds.utilities import simplify_chain_real simplify_chain_real(R) #R 2020-01-11 23:20:20 +0200 commented answer Monomials' list for Laurent polynomials Many thanks. If I previously introduced x,y as symbolic variables, is there a way to covert the elements in the list back to symbolic variables? 2020-01-11 16:27:05 +0200 asked a question Monomials' list for Laurent polynomials Given a Laurent polynomial, is there a method to list its monomials? For example, for the polynomial $f(x,y) = x/y + y +3/x$ in the ring $R[x^\pm,y^\pm]$, it should give a list of the form [x/y,y,3/x]. Something similar exists for polynomials, it is given by monomials(). 2019-12-31 21:05:04 +0200 received badge ● Editor (source) 2019-12-31 20:56:30 +0200 commented answer Residue in complex analysis 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. 2019-12-31 20:50:39 +0200 commented answer Residue in complex analysis Well, residue is coeff -1 of Laurent series, right? 2019-12-31 20:49:48 +0200 commented answer Residue in complex analysis var('x','t') (1/(t^2 - t + x)).maxima_methods().residue(t,(1+sqrt(1-4*x))/2) gives zero. 2019-12-27 22:15:30 +0200 answered a question Residue in complex analysis 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. 2019-12-27 22:07:46 +0200 commented answer Residue in complex analysis For some reason my code above does not work. I noticed the residue in maxima, but it does not seem to work consistently. 2019-12-27 22:06:35 +0200 received badge ● Scholar (source) 2019-12-27 22:06:32 +0200 received badge ● Supporter (source) 2019-12-20 00:56:30 +0200 received badge ● Student (source) 2019-12-20 00:48:33 +0200 asked a question substitution of variable in the result of monomials() Given a polynomial in n variables, I'd like to extract the list of its monomials, and then manipulate that list by substituting certain variables for others. Simple example: in $Z[x,y]$ consider the polynomial $1+x+y^2$; the list of its monomials (in some ordering) is $(1,x,y^2)$. My function should be able e.g. to take that list and substitute $y$ with $x$, namely return $[1,x,x^2]$. At the moment, my code gives error, but I do not understand how to fix it. N. = PolynomialRing(ZZ, 2) f = 1+x1+x2 g = f.monomials() for i in range(3): g[i] = g[i].substitute_expression(x2==x1) Namely, how do I make a variable in the polynomial ring also have the substitute attribute? or is there a better way to achieve this?