On Monday, August 18, 2014 7:11:53 AM UTC-7, juaninf wrote: > > Dear Emmanuel, > Thank, ... one last question ... How I will be able to extract the > coefficients of t^0,t^1,...,t^(p-1) > > I wouldn't trust SR with anything in positive characteristic. It is not designed for it and it is hard to control what it will do at any particular moment (many algebraic operations will work out fine, but I wouldn't be confident that I can predict that it will only use those).
The substitution you want to do is just a polynomial evaluation, so it should be fairly easy to work out what to do in terms of polynomial rings, without touching SR at all: k.<t>=GF(2^3) namesR=["x%d%d"%(j,i) for j in [0..3] for i in [0..2]] R=PolynomialRing(k,names=namesR) subsvar=[sum((t^i*R.gen(i+3*j) for i in [0..2])) for j in [0..3]] //now we have your substitution namesP=["X%d"%i for i in [0..3]] P=PolynomialRing(k,names=namesP) p=P.random_element(degree=2) //this gives your example polynomial. Evaluating: p(subsvar) q=p(subsvar) #let's give it a name //to split according to coefficients wrt. t we need t to be the "outer" variable: A=PolynomialRing(GF(2),namesR) At=A['t'] //unfortunately, sage cannot figure out the coercion from R to At by itself, so we need to help it. We just extract coefficient-monomial pairs //and map them over individually and then assemble as a polynomial again: //we run into a bad bug here as well: qAt=sum(At(b.polynomial())*A(a) for b,a in dict(q).iteritems()) dict(q) unfortunately has the coefficients for keys and monomials for values. That must be a stupid typo in the source. e.g. dict(R.0+R.1) gives garbage back. After the bugfix the invocation should be .... a,b in dict(q).iteritems() ... //to get the coefficients you want: qAt.list() however, currently that will only give you the correct answer if all the non-zero coefficients in q happen to be distinct. You could use q.dict() instead which has the appropriate order, but encodes the monomials as exponent vectors, which are hard to convert to At. [you should go that route, though, because the other method can give you wrong answers] -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.