[sage-support] Re: Modular operation in multivariate polynomials

2012-02-17 Thread Oleksandr Kazymyrov
Hi Simon,

 Do you have a trac account, or shall I open a trac ticket myself? 
No, I havn't. If this is not a problem for you then open.

At the moment I use the following code:

pol=sum([g.mod(P(y^{0}+y.format(1bits)))  for g in pol.monomials()])

Maybe it will help.

Best regards,
Oleksandr

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Modular operation in multivariate polynomials

2012-02-17 Thread Simon King
Hi Oleksandr,

On 17 Feb., 10:33, Oleksandr Kazymyrov vrona.aka.ham...@gmail.com
wrote:
 No, I havn't. If this is not a problem for you then open.

OK, I'll do so later today.

 At the moment I use the following code:

 pol=sum([g.mod(P(y^{0}+y.format(1bits)))  for g in pol.monomials()])

No, that won't do the right thing.

The literature uses the words monomial and term in a confusing
way, namely in two opposite points of view: Some say that a polynomial
is a sum of monomials (i.e., a monomial comprises a coefficient) and a
term is without the coefficient. Others say that a monomial is an
element of the commutative monoid that the polynomial ring is
constructed from: They say that a monomial has no coefficient, whereas
a term is the product of a monomial with its coefficient (i.e., a
polynomial is a sum of terms).

Sage follows the second convention:
 sage: P.x,y = GF(3)[]
 sage: p = P.random_element()
 sage: p
 x^2 + x*y - 1
 sage: p.monomials()
 [x^2, x*y, 1]
 sage: p.coefficients()
 [1, 1, 2]
 sage: sum(p.monomials()) == p
 False

So, you must not forget to multiply each monomial with its
coefficient, for example:
 sage: sum([c*m for c,m in zip(p.coefficients(),p.monomials())]) == p
 True

Best regards,
Simon

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Modular operation in multivariate polynomials

2012-02-17 Thread Oleksandr Kazymyrov
Hi Simon,

I agree with you. My previous message is true only for GF(2^n).

Best regards,
Oleksandr

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Modular operation in multivariate polynomials

2012-02-17 Thread Simon King
Hi all,

On 17 Feb., 10:53, Simon King simon.k...@uni-jena.de wrote:
  No, I havn't. If this is not a problem for you then open.

 OK, I'll do so later today.

I opened http://trac.sagemath.org/sage_trac/ticket/12529

Best regards,
Simon

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Modular operation in multivariate polynomials

2012-02-16 Thread Simon King
Hi Oleksandr,

On 16 Feb., 14:09, Oleksandr Kazymyrov vrona.aka.ham...@gmail.com
wrote:
 I expect that the degree of the polynomial will be less than 2^bits=8.

Why do you expect this? There is a difference between a polynomial
(i.e., an element of a polynomial ring) and a polynomial function.
Polynomials can be of arbitrary degree, over any coefficient field.

Over a finite field, it is just normal that a polynomial constantly
evaluates as zero, but is not zero:
 sage: P.x,y = GF(3)[]
 sage: p = x^3 - x + y^3 - y
 sage: p.degree()
 3
 sage: p == 0
 False
 sage: [p(x=a,y=b) for a,b in cartesian_product_iterator([list(GF(3)),
list(GF(3))])]
 [0, 0, 0, 0, 0, 0, 0, 0, 0]

Sorry if I misunderstood the problem.

Best regards,
Simon

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Modular operation in multivariate polynomials

2012-02-16 Thread Oleksandr Kazymyrov
Dear Simon,

 There is a difference between a polynomial (i.e., an element of a 
polynomial ring) and a polynomial function. Polynomials can be of arbitrary 
degree, over any coefficient field.

Yes I know this. But I think there is no difference between defining of 
PolynomialRing and PolynomialQuotientRing, assuming that you independently 
perform the operation by modulus. I am forcing the call of a function 
pol.mod(P(y^8+y)) to obtain the remainder by modulus. And I expect that 
monomial y^10*a2*b1^10*p5^2 will has degree 3 (y^3*a2*b1^10*p5^2) after 
operation pol.mod(P(y^8+y)) in the polynomial.

KInd regards,
Oleksandr

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: Modular operation in multivariate polynomials

2012-02-16 Thread Simon King
Hi Oleksandr,

On 16 Feb., 17:58, Oleksandr Kazymyrov vrona.aka.ham...@gmail.com
wrote:
 I am forcing the call of a function
 pol.mod(P(y^8+y)) to obtain the remainder by modulus.

Sorry, I had missed that (the example was quite long, and thus I had
the impression that you had merely constructed a polynomial over a
finite field, but no modulus except the modulus of the finite field).

 And I expect that
 monomial y^10*a2*b1^10*p5^2 will has degree 3 (y^3*a2*b1^10*p5^2) after
 operation pol.mod(P(y^8+y)) in the polynomial.

Right. That sounds like a bug to me.

Starting with your definitions, it seems to me that the bug is in
libSingular (which is used for polynomial arithmetic in Sage), whereas
Singular itself computes it correctly:

sage: polS = singular(pol)
sage: IS = singular(I)
sage: singular(NF(%s,std(%s))%(polS.name(), IS.name()))
y^7*a2*b1^14*p7^2+y^7*a2*b2^14*p7^2+y^6*a2*b0^8*b1^6*p7^2+y^6*a2*b1^8*b2^6*p7^2+y^6*a2*b0^2*b1^4*b2^8*p7^2+y^6*a2*b0^4*b2^10*p7^2+y^5*a2*b0^2*b1^12*p7^2+y^5*a2*b0^4*b1^8*b2^2*p7^2+y^5*a2*b0^8*b2^6*p7^2+y^5*a2*b1^2*b2^12*p7^2+y^6*a2*b1^4*b2^8*p6^2+y^4*a2*b0^10*b1^4*p7^2+y^4*a2*b0^12*b2^2*p7^2+y^4*a2*b1^10*b2^4*p7^2+y^4*a2*b0^4*b1^2*b2^8*p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