A Little Side-Bar on Series Expansions

Suppose we start with a nice little function

fun[t_] := ArcTanh[ω t]

for which we need a Taylor expansion up to the tenth power

funSeries = Series[fun[t], {t, 0, 10}]

Notice the trailing "remainder" part.

In fact, Mathematica remembers that this is not a simple polynomial:

Factor[funSeries]

To turn it into one—to truncate the series to a finite polynomial—we need to use:

funPolynomial = Normal[funSeries]

Now this is a finite polynomial:

Factor[funPolynomial]

and we may use it as such for further manipulations and calculations.

Trying to plot the original, exact function and the truncation of its series

Plot[{fun[t], funPolynomial} /. {ω -> 1}, {t, 0, 
          1}];

fails in this simple approach, because the substitution of the symbol ω with the number 1 does not happen in time before Plot[...] checks if its argument can be plotted.

This evaluation can be forced by inserting, ...well, Evaluate[...]:

Plot[
        Evaluate[{fun[t], funPolynomial} /. {ω -> 1}], {t, 0, 
          1}];

or, by copy-and-pasting the actual polynomial and removing the ω's by hand (tedious):

Plot[{fun[t] /. {ω -> 1}, 
          t  + ((t^3)/3) + ((t^5)/5) + ((t^7)/7) + ((t^9)/9)}, {t, 0, 
          1}];

or by substituting one level earlier:

Plot[{fun[t] /. {ω -> 1}, 
          funPolynomial /. {ω -> 1}}, {t, 0, 1}];

In fact, it may be instructive to peek "under the hood":

Table[funSeries[[n]], {n, 0, 10}]

Table[funPolynomial[[n]], {n, 0, 10}]

The same kind of information can be gleaned by using InputForm[...]:

InputForm[funSeries]

InputForm[funPolynomial]

A few Simple Experiments

In fact, let's experiment a little more with the Taylor series function:

Series[Csc[x], {x, 0, 4}]

so, I have in fact misnamed it: it is not a Taylor series!!!

It is in fact a Laurent series, as it does calculate also negative powers for non-analytic functions:

Series[Csc[x]^3, {x, 0, 4}]

Series[Csc[x]^3/Sinh[x]^3, {x, 0, 4}]

Series[Csc[x]^3/Sinh[x]^3, {x, 0, 8}]

Also, you need not expand around zero. Compare:

Series[Csc[x], {x, 0, 4}]

?Residue

Residue[Csc[x], {x, 0}]

Series[Csc[x], {x, π, 4}]

Residue[Csc[x], {x, π}]

Residue[Csc[x]^3, {x, π}]

Series[Csc[x], {x, π/2, 4}]

But, Mathematica's Series[...] function has a limitation:

Series[Exp[1/x], {x, 0, 5}]

and knows about it too.

Series[Exp[-1/x], {x, 0, 5}]

D[Exp[1/x], x]

?Series

Well, how about expanding about another point

Series[Exp[-1/x], {x, 1, 5}]

That's a perfectly convergent series (check, using the ratio test, for example), but is somewhat unwieldy, and does not show the negative powers in x...

So, how about expanding about infinity:

Series[Exp[-1/x], {x, Infinity, 5}]

Indeed—that's the trick!

Of course, you are out of luck with a function that diverges "at both ends":

Series[Exp[x - 1/x], {x, Infinity, 5}]

Manipulations with Series

You can divide a series by another:

Series[Sin[x], {x, 0, 10}]/Series[Cos[x], {x, 0, 10}]

and Mathematica automatically evaluates the result as a series:

Series[Tan[x], {x, 0, 10}]

as expected, since ((sin(x))/(cos(x))) = tan(x) .

You can exponentiate series:

Series[1/(1 - x), {x, 0, 6}]^2

Series[1/(1 - x)^2, {x, 0, 6}]

You can even put series into the exponent:

2^Series[1/(1 - x), {x, 0, 3}]

Series[2^(1/(1 - x)), {x, 0, 3}]

Now, these do not look the same, but:

Simplify[2^Series[1/(1 - x), {x, 0, 3}]]

Simplify[Series[2^(1/(1 - x)), {x, 0, 3}]]

Mathematica also knows about the typical practice in applied mathematics and sicences of not expanding logarithms, but keeping them so that the logarithmic divergences would show where present:

Series[x^x, {x, 0, 4}]

Parameters that are present in the function being expanded are treated as constants:

Series[1/(a - x), {x, 0, 2}]

...unless you tell mathematica otherwise:

Series[1/(a[x] - x), {x, 0, 2}]

Notice that the SeriesData in a series overrides the normalness of other expressions, so that

x + Series[1/(1 - x), {x, 0, 3}]

has lumped the free-standing "x" into the linear term in the series; hereafter, the whole expression is a series.

Moreover, you can make Mathematica think of an otherwise finite polynomial as a series:

exPoly = Expand[(1 - x)^3]

Factor[exPoly]

but

Factor[exPoly + O[x]^8]

By appending that "+O[x]^8" trailer, the expression has been declared a series to Mathematica, and is no longer considered a finite polynomial. You'll have to use Normal[...] to restore its normalcy.

Just as you've been taught to compose functions, (f∘g) (x) := f(g(x)), you can compose series, and you can also compute inverse series:

This is a simple, well-known series:

aSeries = Series[Exp[x], {x, 0, 5}]

This is the series for the inverse function of Exp[x], which is Log[x]. Note that the latter has a well-defined Taylor series not about 0 but about 1:

InverseSeries[aSeries, x]

You can now compose these two series, effectively computing Log[Exp[x]]

ComposeSeries[%, %%]

where Mathematica cautiously claims that this equals x, but only up to terms of order (x^6), since it was working with series and only up to and including fifth powers.

Notice that it was important to have the original series and the inverse series expanded about compatible points for the series composition to be evaluated correctly. This can be very tricky... so, use "when all else fails".