i1 : R = ZZ/10007[a,b]; |
i2 : f = (2*a+3)^4 + 5 |
i3 : g = (2*a+b+1)^3 |
i4 : size f, size g |
i5 : degree f |
i6 : degree g |
The list of terms of a polynomial is obtained with terms.
i7 : terms g |
i8 : select(terms g, i -> degree i == {2}) |
i9 : sum oo |
i10 : name f |
i11 : name g |
The usual algebraic operations on polynomials are available, but there are some special remarks to make about division. The result of division depends on the ordering of monomials chosen when the ring is created, for division of f by g proceeds by locating monomials in f divisible by the leading monomial of g, and substituting for it the negation of the rest of g. The quotient is provided by the expression f//g, and the remainder is obtained with f%g.
i12 : quot = f//g |
i13 : rem = f%g |
i14 : f == quot * g + rem |
Polynomials can be homogenized with respect to one of the variables in the ring with homogenize.
i15 : homogenize(f,b) |
Polynomials can be factored with factor.
i16 : S = factor f |
i17 : T = factor g |
The results above are represented as products of powers. (Exponents equal to 1 don't appear in the display.) We can see the internal structure to a specified depth (in this case, 2) with peek2.
i18 : peek2(S,2) |
i19 : peek2(T,2) |
i20 : T#0 |
i21 : T#0#0 |
i22 : T#0#1 |
i23 : ring f |
i24 : ring f === ring g |
i25 : f_1 |
i26 : f_a |
i27 : g_(a*b) |
We may get parts of the leading term of a polynomial as follows.
i28 : leadTerm g |
i29 : leadCoefficient g |
i30 : leadMonomial g |
i31 : exponents leadMonomial g |
i32 : coefficients f |
i33 : coefficients g |
i34 : exponents f |
i35 : exponents g |
i36 : listForm f |
i37 : S = listForm g |
i38 : S / print; |
i39 : S = standardForm f |
i40 : standardForm g |
i41 : S#(new HashTable from {0 => 2}) |
Monomials (monoid elements) have an accessible form which is implicitly used above.
i42 : listForm leadMonomial g |
i43 : standardForm leadMonomial g |
i44 : f < g |
i45 : f ? g |
i46 : sort {b^2-1,a*b,a+1,a,b} |