1.4.6 Picking Out Pieces of Algebraic Expressions
Here is an algebraic expression.
Functions to pick out pieces of polynomials.
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
Coefficient works even with polynomials that are not explicitly expanded out.
often shows algebraic expressions in a form that is different from the way it treats them internally.
In:= Coefficient[(1 + 3x + 4y^2)^2, x]
Here is a rational expression.
Functions to pick out pieces of rational expressions.
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]