Structural Operations on Rational Expressions

For ordinary polynomials, (RefLink[Factor, paclet:ref/Factor]) and (RefLink[Expand, paclet:ref/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:

t=(1+x)^2/(1-x)+3 x^2/(1+x)^2+(2-x)^2

(RefLink[ExpandNumerator, paclet:ref/ExpandNumerator]) writes the numerator of each term in expanded form:

ExpandNumerator[t]

(RefLink[Expand, paclet:ref/Expand]) expands the numerator of each term, and divides all the terms by the appropriate denominators:

Expand[t]

(RefLink[ExpandDenominator, paclet:ref/ExpandDenominator]) expands out the denominator of each term:

ExpandDenominator[t]

(RefLink[ExpandAll, paclet:ref/ExpandAll]) does all possible expansions in the numerator and denominator of each term:

ExpandAll[t]

Controlling expansion.

This avoids expanding the term which does not contain z:

ExpandAll[(x+1)^2/y^2+(z+1)^2/z^2,z]

Structural operations on rational expressions.

Here is a rational expression:

u=(-4x+x^2)/(-x+x^2)+(-4+3x+x^2)/(-1+x^2)

(RefLink[Together, paclet:ref/Together]) puts all terms over a common denominator:

Together[u]

You can use (RefLink[Factor, paclet:ref/Factor]) to factor the numerator and denominator of the resulting expression:

Factor[%]

(RefLink[Apart, paclet:ref/Apart]) writes the expression as a sum of terms, with each term having as simple a denominator as possible:

Apart[u]

(RefLink[Cancel, paclet:ref/Cancel]) cancels any common factors between numerators and denominators:

Cancel[u]

(RefLink[Factor, paclet:ref/Factor]) first puts all terms over a common denominator, then factors the result:

Factor[%]

In mathematical terms, (RefLink[Apart, paclet:ref/Apart]) decomposes a rational expression into "partial fractions".

In expressions with several variables, you can use (RefLink[Apart, paclet:ref/Apart])[expr,var] to do partial fraction decompositions with respect to different variables.

Here is a rational expression in two variables:

v=(x^2+y^2)/(x+x y)

This gives the partial fraction decomposition with respect to x:

Apart[v,x]

Here is the partial fraction decomposition with respect to y:

Apart[v,y]