I would rather transform the polynomials to symmetric functions and then do the expansion there. Something like
sage: Sym = SymmetricFunctions(QQ['t']) sage: P = Sym.hall_littlewood().P() sage: R = PolynomialRing(QQ['t'], 'x', 4) sage: x = R.gens() sage: Sym.from_polynomial(x[0]+x[1]+x[2]+x[3]) m[1] sage: P(Sym.from_polynomial(x[0]+x[1]+x[2]+x[3])) HLP[1] Best, Anne On 12/4/13 11:04 PM, Travis Scrimshaw wrote: > Hey Dan, > This is only a part of the way, but I'd start by doing the computations by > having t in a polynomial ring R (over QQ say), and the basic variables x_i > coming from a power series ring over R: > > sage: R.<t> = QQ[] > sage: S.<x1,x2,x3> = PowerSeriesRing(R) > sage: (1 - t*x1*x3) / (1 - x1*x3) > 1 + (-t + 1)*x1*x3 + (-t + 1)*x1^2*x3^2 + (-t + 1)*x1^3*x3^3 + (-t + > 1)*x1^4*x3^4 + (-t + 1)*x1^5*x3^5 + O(x1, x2, x3)^12 > > Of course there's the reverse too: > > sage: R.<x1,x2,x3> = PowerSeriesRing(QQ) > sage: S.<t> = R[] > sage: f = (1 - t*x1*x3) / (1 - x1*x3); f > (-x1*x3 - x1^2*x3^2 - x1^3*x3^3 - x1^4*x3^4 - x1^5*x3^5 - x1^6*x3^6 + O(x1, > x2, x3)^14)*t + 1 + x1*x3 + x1^2*x3^2 + x1^3*x3^3 + x1^4*x3^4 + x1^5*x3^5 + > O(x1, x2, x3)^12 > > And if you don't want any grouping: > > sage: R.<x1,x2,x3,t> = PowerSeriesRing(QQ) > sage: (1 - t*x1*x3) / (1 - x1*x3) > 1 + x1*x3 - x1*x3*t + x1^2*x3^2 - x1^2*x3^2*t + x1^3*x3^3 - x1^3*x3^3*t + > x1^4*x3^4 - x1^4*x3^4*t + x1^5*x3^5 - x1^5*x3^5*t + O(x1, x2, x3, t)^12 > > Now to get the HL P polynomials into the correct variables: > > sage: Sym = SymmetricFunctions(R) > sage: HLP = Sym.hall_littlewood(t).P() > sage: p21 = HLP[2,1].expand(3) > sage: p21 = p21.substitute(x0=x1, x1=x2, x2=x3) > sage: p21 > x1^2*x2 + x1^2*x3 + x1*x2^2 + (-t^2 - t + 2)*x1*x2*x3 + x1*x3^2 + x2^2*x3 + > x2*x3^2 > sage: p21.parent() > Multivariate Power Series Ring in x1, x2, x3 over Univariate Polynomial Ring > in t over Rational Field > > Then from this point you could do some linear algebra using a "nice" ordering > of the basis: > > sage: R.<t> = QQ[] > sage: S.<x1,x2,x3> = PowerSeriesRing(R) # If you aren't getting enough > terms, add "default_prec=20" to increase the degrees computed > sage: f = (1 - t*x1*x2) / (1 - x1*x2) * (1 - t*x1*x3) / (1 - x1*x3) * (1 - > t*x2*x3) / (1 - x2*x3) > sage: Sym = SymmetricFunctions(R) > sage: HLP = Sym.hall_littlewood(t).P() > sage: p11 = HLP[1,1].expand(3) > sage: p11 = p11.substitute(x0=x1, x1=x2, x2=x3) > sage: c = f.coefficients() > sage: f[2] - p11 * c[x1*x2] # I only took the degree 2 terms for easier > viewing/proof of concept > 0 > sage: f - p11 * c[x1*x2] > 1 + (-t + 1)*x1^2*x2^2 + (t^2 - 2*t + 1)*x1^2*x2*x3 + (-t + 1)*x1^2*x3^2 + > (t^2 - 2*t + 1)*x1*x2^2*x3 + (t^2 - 2*t + 1)*x1*x2*x3^2 + (-t + 1)*x2^2*x3^2 > + (-t + 1)*x1^3*x2^3 + (t^2 - 2*t + > 1)*x1^3*x2^2*x3 + ... + O(x1, x2, x3)^12 > > So from this point it would be wrapping this up in a function that iterates > over partitions in some "nice" way (Sage goes by lex largest to smallest) and > returns a dictionary of index/value as > partition/coefficient, for example [1, 1]: -t + 1 (which comes from c[x1*x2]). > > Here's the more automated, but less explicit, version: > > sage: n = 3 # This could be the input to a function > sage: R.<t> = QQ[] > sage: S = PowerSeriesRing(R, n, 'x', default_prec=n+1) > sage: Sym = SymmetricFunctions(R) > sage: HLP = Sym.hall_littlewood(t).P() > sage: d = S.gens_dict() > sage: make_poly = lambda la: HLP[la].expand(n).substitute(**d) > sage: lead_term = lambda la: prod(S.gen(i)**v for i,v in enumerate(la)) > > sage: f = prod( (1 - t*S.gen(i)*S.gen(j)) / (1 - S.gen(i)*S.gen(j)) for i in > range(n) for j in range(i+1,n) ) > sage: f > 1 + (-t + 1)*x0*x1 + (-t + 1)*x0*x2 + (-t + 1)*x1*x2 + O(x0, x1, x2)^4 > > sage: ret = {} > sage: for k in range(n+1): # For the default precision > ....: for la in Partitions(k): > ....: c = f.coefficients() > ....: coeff = c.get(lead_term(la), 0) > ....: if coeff != 0: > ....: ret[la] = coeff > ....: f -= coeff * make_poly(la) > ....: > sage: ret # This would be the output of that function > {[]: 1, [1, 1]: -t + 1} > sage: f > 0 + O(x0, x1, x2)^4 > > Same code but with n = 5: > > sage: ret > {[]: 1, [1, 1]: -t + 1, [1, 1, 1, 1]: t^4 - t^3 - t + 1, [2, 2]: -t + 1} > sage: f > 0 + O(x0, x1, x2, x3, x4)^6 > > Same thing but with n = 8 and the default_prec = 6: > > sage: ret > {[]: 1, [1, 1]: -t + 1, [1, 1, 1, 1]: t^4 - t^3 - t + 1, [2, 2]: -t + 1} > sage: f > 0 + O(x0, x1, x2, x3, x4, x5, x6, x7)^6 > > Is this what you were looking for? It's not the fastest (and IDK how it would > compare to your implementation), but it should work. > > Best, > Travis > > > On Wednesday, December 4, 2013 2:59:08 PM UTC-8, Dan Betea wrote: > > Hi there, > > Is there a quick way (in Sage) to expand a product like \prod_{i<j} > \frac{1-t x_i x_j}{1- x_i x_j} in Hall Littlewood polynomials in the > appropriate number of variables? More precisely, given a > partition of length <= to the number of variables, I want to compute the > coefficient of the corresponding P or Q HL polynomial. > > Note this example is known precisely (one of the Littlewood identities > for HL polynomials). > > The product I'm interested in is more difficult and contains an extra set > of variables y (together with their inverses). It contains univariate factors > like \prod_{i} (1-t_0 x_i)(1-t_1 x_i)/(1-t > x_i^2) along with "i<j" factors of the above form. Through some magic > using Littlewood Richardson coefficients, Kostka polynomials and a deep look > into Macdonald, one can obtain the coefficient of > P_{\lambda}. However, the process takes a lot of setup and is *slow* (so > not very prone to the experimentation we want to try). I imagine Sage would > have this functionality when dealing with > symmetric functions. > > Thanks, > > db -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-combinat-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-combinat-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-combinat-devel. For more options, visit https://groups.google.com/groups/opt_out.