1.4.7 Picking Out Pieces of Algebraic Expressions
Functions to pick out pieces of polynomials.
Here is an algebraic expression.
In:= e = Expand[(1 + 3x + 4y^2)^2]
This gives the coefficient of x in e.
In:= Coefficient[e, x]
Exponent[expr, y] gives the highest power of y that appears in expr.
In:= Exponent[e, y]
This gives the fourth term in e.
In:= Part[e, 4]
You may notice that the function Part[expr, n] used to pick out the n term in a sum is the same as the function described in Section 1.2.4 for picking out elements in lists. This is no coincidence. In fact, as discussed in Section 2.1.5, every Mathematica expression can be manipulated structurally much like a list. However, as discussed in Section 2.1.5, you must be careful, because Mathematica often shows algebraic expressions in a form that is different from the way it treats them internally.
Coefficient works even with polynomials that are not explicitly expanded out.
In:= Coefficient[(1 + 3x + 4y^2)^2, x]
Functions to pick out pieces of rational expressions.
Here is a rational expression.
In:= r = (1 + x)/(2 (2 - y))
Denominator picks out the denominator.
Denominator gives 1 for expressions that are not quotients.
In:= Denominator[1/x + 2/y]
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER
FOR THE LATEST INFORMATION.