|
1.4.6 Picking Out Pieces of Algebraic Expressions

Functions to pick out pieces of polynomials.
Here is an algebraic expression.
In[1]:= e = Expand[(1 + 3x + 4y^2)^2]
Out[1]= 
This gives the coefficient of x in e.
In[2]:= Coefficient[e, x]
Out[2]= 
Exponent[expr,y] gives the highest power of y that appears in expr.
In[3]:= Exponent[e, y]
Out[3]= 
This gives the fourth term in e.
In[4]:= Part[e, 4]
Out[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[5]:= Coefficient[(1 + 3x + 4y^2)^2, x]
Out[5]= 

Functions to pick out pieces of rational expressions.
Here is a rational expression.
In[6]:= r = (1 + x)/(2 (2 - y))
Out[6]= 
Denominator picks out the denominator.
In[7]:= Denominator[%]
Out[7]= 
Denominator gives 1 for expressions that are not quotients.
In[8]:= Denominator[1/x + 2/y]
Out[8]= 
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT. SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION. |