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 / Advanced Mathematics / Algebraic Manipulation  /

3.3.3 Structural Operations on Rational Expressions

For ordinary polynomials, Factor and Expand give the most important forms. For rational expressions, there are many different forms that can be useful.


Different kinds of expansion for rational expressions.

  • Here is a rational expression.
  • In[1]:= t = (1 + x)^2 / (1 - x) + 3 x^2 / (1 + x)^2 + (2 - x)^2

    Out[1]=

  • ExpandNumerator writes the numerator of each term in expanded form.
  • In[2]:= ExpandNumerator[t]

    Out[2]=

  • Expand expands the numerator of each term, and divides all the terms by the appropriate denominators.
  • In[3]:= Expand[t]

    Out[3]=

  • ExpandDenominator expands out the denominator of each term.
  • In[4]:= ExpandDenominator[t]

    Out[4]=

  • ExpandAll does all possible expansions in the numerator and denominator of each term.
  • In[5]:= ExpandAll[t]

    Out[5]=


    Controlling expansion.

  • This avoids expanding the term which does not contain z.
  • In[6]:= ExpandAll[(x + 1)^2/y^2 + (z + 1)^2/z^2, z]

    Out[6]=


    Structural operations on rational expressions.

  • Here is a rational expression.
  • In[7]:= u = (-4x + x^2)/(-x + x^2) + (-4 + 3x + x^2)/(-1 + x^2)

    Out[7]=

  • Together puts all terms over a common denominator.
  • In[8]:= Together[u]

    Out[8]=

  • You can use Factor to factor the numerator and denominator of the resulting expression.
  • In[9]:= Factor[%]

    Out[9]=

  • Apart writes the expression as a sum of terms, with each term having as simple a denominator as possible.
  • In[10]:= Apart[u]

    Out[10]=

  • Cancel cancels any common factors between numerators and denominators.
  • In[11]:= Cancel[u]

    Out[11]=

  • Factor first puts all terms over a common denominator, then factors the result.
  • In[12]:= Factor[%]

    Out[12]=

    In mathematical terms, Apart decomposes a rational expression into "partial fractions".
    In expressions with several variables, you can use Apart[expr,var] to do partial fraction decompositions with respect to different variables.

  • Here is a rational expression in two variables.
  • In[13]:= v = (x^2+y^2)/(x + x y)

    Out[13]=

  • This gives the partial fraction decomposition with respect to x.
  • In[14]:= Apart[v, x]

    Out[14]=

  • Here is the partial fraction decomposition with respect to y.
  • In[15]:= Apart[v, y]

    Out[15]=