## Section17.7Sage

Sage is particularly adept at building, analyzing and manipulating polynomial rings. We have seen some of this in the previous chapter. Let's begin by creating three polynomial rings and checking some of their basic properties. There are several ways to construct polynomial rings, but the syntax used here is the most straightforward.

### SubsectionPolynomial Rings and their Elements

Basic properties of rings are availble for these examples.

With the construction syntax used above, the variables can be used to create elements of the polynomial ring without explicit coercion (though we need to be careful about constant polynomials).

Polynomials can be evaluated like they are functions, so we can mimic the evaluation homomorphism.

Notice that p is a degree two polynomial, yet through a brute-force examination we see that the polynomial only has one root, contrary to our usual expectations. It can be even more unusual.

Sage can create and manipulate rings of polynomials in more than one variable, though we will not have much occasion to use this functionality in this course.

### SubsectionIrreducible Polynomials

Whether or not a polynomial factors, taking into consideration the ring used for its coefficients, is an important topic in this chapter and many of the following chapters. Sage can factor, and determine irreducibility, over the integers, the rationals, and finite fields.

First, over the rationals.

Factoring over the integers is really no different than factoring over the rationals. This is the content of Theorem 17.14 — finding a factorization over the integers can be converted to finding a factorization over the rationals. So it is with Sage, there is little difference between working over the rationals and the integers. It is a little different working over a finite field. Commentary follows.

To check these factorizations, we need to compute in the finite field, F, and so we need to know how the symbol a behaves. This symbol is considered as a root of a degree two polynomial over the integers mod 5, which we can get with the .modulus() method.

So $$a^2+4a+2=0\text{,}$$ or $$a^2=-4a-3=a+2\text{.}$$ So when checking the factorizations, anytime you see an $$a^2$$ you can replace it by $$a+2\text{.}$$ Notice that by Corollary 17.8 we could find the one linear factor of r, and the four linear factors of s, through a brute-force search for roots. This is feasible because the field is finite.

However, q factors into a pair of degree 2 polynomials, so no amount of testing for roots will discover a factor.

With Eisenstein's Criterion, we can create irreducible polynomials, such as in Example 17.18.

Over the field $${\mathbb Z}_p\text{,}$$ the field of integers mod a prime $$p\text{,}$$ Conway polynomials are canonical choices of a polynomial of degree $$n$$ that is irreducible over $${\mathbb Z}_p\text{.}$$ See the exercises for more about these polynomials.

### SubsectionPolynomials over Fields

If $$F$$ is a field, then every ideal of $$F[x]$$ is principal (Theorem 17.20). Nothing stops you from giving Sage two (or more) generators to construct an ideal, but Sage will determine the element to use in a description of the ideal as a principal ideal.

Theorem 17.22 is the key fact that allows us to easily construct finite fields. Here is a construction of a finite field of order $$7^5=16\,807\text{.}$$ All we need is a polynomial of degree $$5$$ that is irreducible over $${\mathbb Z}_7\text{.}$$

The symbol xbar is a generator of the field, but right now it is not accessible. xbar is the coset $$x + \langle x^5+ x + 4\rangle\text{.}$$ A better construction would include specifying this generator.