# 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.

 ExpandNumerator[expr] expand numerators only ExpandDenominator[expr] expand denominators only Expand[expr] expand numerators, dividing the denominator into each term ExpandAll[expr] expand numerators and denominators completely

Different kinds of expansion for rational expressions.

Here is a rational expression:
 In:= Out= ExpandNumerator writes the numerator of each term in expanded form:
 In:= Out= Expand expands the numerator of each term, and divides all the terms by the appropriate denominators:
 In:= Out= ExpandDenominator expands out the denominator of each term:
 In:= Out= ExpandAll does all possible expansions in the numerator and denominator of each term:
 In:= Out= ExpandAll[expr,patt], etc. avoid expanding parts which contain no terms matching patt

Controlling expansion.

This avoids expanding the term which does not contain z:
 In:= Out= Together[expr] combine all terms over a common denominator Apart[expr] write an expression as a sum of terms with simple denominators Cancel[expr] cancel common factors between numerators and denominators Factor[expr] perform a complete factoring

Structural operations on rational expressions.

Here is a rational expression:
 In:= Out= Together puts all terms over a common denominator:
 In:= Out= You can use Factor to factor the numerator and denominator of the resulting expression:
 In:= Out= Apart writes the expression as a sum of terms, with each term having as simple a denominator as possible:
 In:= Out= Cancel cancels any common factors between numerators and denominators:
 In:= Out= Factor first puts all terms over a common denominator, then factors the result:
 In:= Out= 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:= Out= This gives the partial fraction decomposition with respect to x:
 In:= Out= Here is the partial fraction decomposition with respect to y:
 In:= Out= 