# How to divide two polynomials in GF(2)[x] and get result in same type as of operands [closed]

Suppose i have two polynomials $f,g$ from GF(2)[x] which is having type class 'sage.rings.polynomial.polynomial_gf2x.Polynomial_GF2X'.

When i find $f/g$ (if $f$ is divisible by $g$ in GF(2)[x]) , it is coming as the type class 'sage.rings.fraction_field_element.FractionFieldElement_1poly_field'

How to convert $f/g$ to the same type class as of $f$ and $g$?

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by Akhilesh close date 2023-12-11 13:00:43.279839

Sort by ยป oldest newest most voted

Like this:

sage: R.<x> = PolynomialRing(GF(2))
sage: f = x^3 - 1
sage: g = x - 1
sage: f // g
x^2 + x + 1
sage: type(f // g)
<class 'sage.rings.polynomial.polynomial_gf2x.Polynomial_GF2X'>
sage: (f // g).parent() is R
True


Or if you have an element of the fraction field which equals a fraction with a unit in the denominator, you can convert it into an element of R:

sage: R(f / g)
x^2 + x + 1

more