This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / The Mathematica Book / Practical Introduction / Algebraic Calculations  /

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]


  • This gives the coefficient of x in e.
  • In[2]:= Coefficient[e, x]


  • Exponent[expr,y] gives the highest power of y that appears in expr.
  • In[3]:= Exponent[e, y]


  • This gives the fourth term in e.
  • In[4]:= 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[5]:= Coefficient[(1 + 3x + 4y^2)^2, x]


    Functions to pick out pieces of rational expressions.

  • Here is a rational expression.
  • In[6]:= r = (1 + x)/(2 (2 - y))


  • Denominator picks out the denominator.
  • In[7]:= Denominator[%]


  • Denominator gives 1 for expressions that are not quotients.
  • In[8]:= Denominator[1/x + 2/y]