Hi Andrea,

On 2013-04-17, Andrea Lazzarotto <andrea.lazzaro...@gmail.com> wrote:
> Hi, I am trying to work with polynomials in Finite Fields. We have to 
> implement the Extended Euclidean Algorithm for using it with Reed Solomon 
> Codes.
> ...
> Now my problem is that I would like to divide a by b and get bot the quotient 
> and the reminder. All the documentation I have found online says that I have 
> to write:
>
><pre>a.quo_rem(b)</pre>
>
> But sage says that the method doesn't exist. Can you suggest me what I am 
> missing?

The problem is that in fact you are *not* considering two polynomials:
  sage: type(a)
  sage.rings.polynomial.polynomial_zmod_flint.Polynomial_zmod_flint
  sage: type(b)
  sage.symbolic.expression.Expression

Note that by saying
  S(x) = ...
you define S as a symbolic function on a symbolic variable x, and if you
re-define x later, then the variable of S will still be symbolic, and
not belong to a polynomial ring.

Hence, b is just a symbolic expression that happens to look like a
polynomial.

I guess what you'd need to define is:
  sage: m = 4
  sage: k = 7
  sage: n = 2^m-1
  sage: f.<alpha> = FiniteField(2^m)
  sage: P.<x> = f[]
  # r should be defined as a polynomial, not as a symbolic function:
  sage: r =
  
1+alpha*x+alpha^2*x^2+x^3+x^4+x^5+x^6+x^7+x^8+alpha^3*x^9+x^10+x^11+x^12+x^13+x^14;
  r
  x^14 + x^13 + x^12 + x^11 + x^10 + alpha^3*x^9 + x^8 + x^7 + x^6 + x^5
  + x^4 + x^3 + alpha^2*x^2 + alpha*x + 1
  sage: Si = [r(alpha^i) for i in [1..8]]
  # S should be defined by summing up the list elements, not as
  # a symbolic function
  sage: S = add([Si[i]*x^(7-i)  for i in [0..7]]); S
  alpha^2*x^7 + (alpha^2 + alpha + 1)*x^6 + (alpha^3 + alpha^2)*x^5 +
  x^4 + (alpha^3 + alpha + 1)*x^3 + alpha^2*x^2 + x + alpha^3 + alpha +
  1
  sage: type(S)
  sage.rings.polynomial.polynomial_zz_pex.Polynomial_ZZ_pEX
  sage: P2.<x> = Integers(q)[]
  sage: a = x^(2*t)

But now we have a problem: b = S(x) would not work, because you work
here with the field GF(16,'alpha') on the one hand, but with the ring
Integers(16) (which contains zero devisors) on the other hand.
Multiplication between elements of the two domains is simply not
possible in a mathematically sober way.

Is working in such a strange ring with zero divisors really what you want?

If you instead define
  sage: b = S
  sage: x = P.gen()
  sage: a = x^(2*t)

then you get

  sage: a.quo_rem(b)
  ((alpha^3 + alpha^2 + 1)*x + alpha^3 + alpha^2,
   x^6 + alpha*x^5 + (alpha^3 + alpha)*x^4 + (alpha^3 + alpha^2)*x^3 +
   alpha^3*x^2 + (alpha^3 + alpha)*x + alpha^3 + alpha^2 + 1)
  sage: type(a)
  sage.rings.polynomial.polynomial_zz_pex.Polynomial_ZZ_pEX
  sage: type(b)
  sage.rings.polynomial.polynomial_zz_pex.Polynomial_ZZ_pEX

Is this perhaps what you wanted to do?

Best regards,
Simon


-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to