topCoefficients -- first variable and its coefficient of a polynomial or matrix
Synopsis
-
- Usage:
(lf, cf) = topCoefficients f
-
Inputs:
-
Outputs:
-
lf, a ring element, or a matrix, the power of the lowest index variable occurring in f, if f is a ring element, or the one row matrix of these powers for each column, if f is a matrix.
-
cf, a ring element, or a matrix, the coefficient of lf in f, if f is a ring element, or the matrix of these coefficients for each column of f
Description
i1 : A = ZZ[x]
o1 = A
o1 : PolynomialRing
|
i2 : (lf,cf) = topCoefficients (7*x^4-13*x^3+x+1)
4
o2 = (x , 7)
o2 : Sequence
|
i3 : v = first support lf
o3 = x
o3 : A
|
i4 : e = first degree lf
o4 = 4
|
The polynomial ring may have more variables.
i5 : B = ZZ[x,y,z]
o5 = B
o5 : PolynomialRing
|
i6 : f = y^4*(3*z^3-z^2-1) - y^3*z^7 + y + z^12
12 3 7 4 3 4 2 4
o6 = z - y z + 3y z - y z - y + y
o6 : B
|
i7 : (lf,cf) = topCoefficients f
4 3 2
o7 = (y , 3z - z - 1)
o7 : Sequence
|
Caveat
If the polynomial ring B of f has a polynomial coefficient ring A, and no variables of B occur in f, then this 'drills down' into A and finds the top variable and coefficient there, but as elements of B
Ways to use topCoefficients:
-
topCoefficients(Matrix)
-
topCoefficients(RingElement)