The TruncatedSeries Package
By Ted Ersek
ersektr@navair . navy . mil

The essential part of the TruncatedSeries package evolved from solutions Daniel Lichtblau, Adre Deprit, and Paul Abbott sent to the mathgroup.

Installing and Loading the Package

To determine where to put the (TruncatedSeries.m) file evaluate the next cell.  If this directory doesn't already have a sub-directory called Enhancements add one now.  The (TruncatedSeries.m) file should then be copied to this Enhancements directory.

ToFileName[{$TopDirectory, "AddOns", "ExtraPackages"}]

Once the (TruncatedSeries.m) file is copied to the right folder the package can be loaded by evaluating the Needs statement in the next cell.

Needs["Enhancements`TruncatedSeries`"];

The next input displays the TruncatedSeries usage message.

?TruncatedSeries

TruncatedSeries has the same option as the built in Series function and the setting of this option is passed directly to Series.

Options[TruncatedSeries]

Examples

Example 1

The next input gives a series approximation of  Exp[x y]Log[y].

Series[Exp[x y] Log[y], {x, 0, 3}, {y, 1, 3}] // Normal

One might want to ignore all terms in the series above that are (4^th) order or higher.  In this example (((x^3)/6)) (-1 + y)  is a fouth order term, and   ((5  (x^3))/12) (((-1 + y))^2)  is a fifth order term.  In the next cell TruncatedSeries is used to get an approximation with only terms third order and below.  

I think in practice one will most often use TruncatedSeries to get a first or second order approximation.  Several of these examples are third and fourth order approximations because I think they give results that make it easier to see which terms are included in the result.

tst = TruncatedSeries[Exp[x y] Log[y], {{x, 0}, {y, 1}}, 3]

Example 2

The next input gives a series approximation of  Exp[x y]*Log[y] / (z-1).

Series[Exp[x y] Log[y]/(z - 1), {x, 0, 2}, {y, 1, 2}, {z, 0, 2}] // 
      Normal

The next input gives the same series approximation where only second order terms and below are included.

TruncatedSeries[Exp[x y] Log[y]/(z - 1), {{x, 0}, {y, 1}, {z, 0}}, 
      2]

Example 3

Sometimes we can get a Series expansion about ∞, and we get negative exponents such as in the next example.

Series[ArcTan[ x]/(a - 1), {x, ∞, 4}, {a, 0, 4}] // 
      Normal

In the next cell TruncatedSeries returns a polynomial approximation of the same function where the sum of the absolute value of all the exponents in each term is 4 or less.

TruncatedSeries[ArcTan[ x]/(a - 1), {{x, ∞}, {a, 0}}, 
      4]

TruncatedSeries can handle axpansions aboute ∞ provided they have the following form. 
TruncatedSeries[f,{{x,∞},{y,y0}},n]/; y0=!=∞
TruncatedSeries[f,{{x,xn},{y,∞}},n]/; x0=!=∞

Example 4

If the expansion is not about ∞, TruncatedSeries can handle an expansion in any finite number of dimensions.  As an example TruncatedSeries returns a third order approximation in six variables in the next cell.

TruncatedSeries[
      Exp[w + 3  u] Sin[v - x] 
        Cos[y + 2  z], {{u, 0}, {v, 0}, {w, 0}, {x, 0}, {y, 0}, {z, 0}}, 
      3]

Messages

The cells below demonstrate that TruncatedSeries returns an appropriate message in most cases where it isn't defined.

TruncatedSeries[Exp[x y] Log[y]]

TruncatedSeries[Exp[x y] Log[y], {{x, 0}, {y, 1}}]

TruncatedSeries[Exp[x y] Log[y], {{x, 0}, {y, 1}}, 4, 5, 6]

TruncatedSeries[Exp[x y], {{y, 1}, {z, 0, 2}}, 2]

TruncatedSeries[Exp[x y], {x, 0}, {y, 1}, 2]

TruncatedSeries[Exp[x y], {{x, 0}, {y + 1, 1}}, 2]

TruncatedSeries[Exp[x y], {{x, 0}, {π, 1}}, 2]

TruncatedSeries[Exp[x y], {{x, 0}, {y, 1}}, -2]

Clear[n];
TruncatedSeries[Exp[x y], {{x, 0}, {y, 1}}, n]

TruncatedSeries[Exp[x y], {{x, 0}, {y, 1}}, 2, n]

TruncatedSeries[Exp[x y], {{x, 0}, {y, 1}}, 2, 
      Constants -> z]