Series, Limits, and Residues

Sums and Products
This constructs the sum :
You can leave out the lower limit if it is equal to 1:
This makes i increase in steps of 2, so that only oddnumbered values are included:
Products work just like sums:
the sum
the sum with i increasing in steps of di
the nested sum
the product
Sums and products.
This sum is computed symbolically as a function of n:
The Wolfram System can also give an exact result for this infinite sum:
As with integrals, simple sums can lead to complicated results:
This sum cannot be evaluated exactly using standard mathematical functions:
You can nevertheless find a numerical approximation to the result:
The Wolfram Language also has a notation for multiple sums and products. Sum[f,{i,imin,imax},{j,jmin,jmax}] represents a sum over i and j, which would be written in standard mathematical notation as . Notice that in Wolfram Language notation, as in standard mathematical notation, the range of the outermost variable is given first.
This is the multiple sum . Notice that the outermost sum over i is given first, just as in the mathematical notation:
The way the ranges of variables are specified in Sum and Product is an example of the rather general iterator notation that the Wolfram Language uses. You will see this notation again when we discuss generating tables and lists using Table ("Making Tables of Values"), and when we describe Do loops ("Repetitive Operations").
iterate imax times, without incrementing any variables
i goes from 1 to imax in steps of 1
i goes from imin to imax in steps of 1
i goes from imin to imax in steps of di
i goes from imin to imax, and for each such value, j goes from jmin to jmax, etc.
Wolfram Language iterator notation.
Power Series
The mathematical operations we have discussed so far are exact. Given precise input, their results are exact formulas.
In many situations, however, you do not need an exact result. It may be quite sufficient, for example, to find an approximate formula that is valid, say, when the quantity x is small.
This gives a power series approximation to for close to , up to terms of order :
The Wolfram Language knows the power series expansions for many mathematical functions:
If you give it a function that it does not know, Series writes out the power series in terms of derivatives:
Power series are approximate formulas that play much the same role with respect to algebraic expressions as approximate numbers play with respect to numerical expressions. The Wolfram Language allows you to perform operations on power series, in all cases maintaining the appropriate order or "degree of precision" for the resulting power series.
Here is a simple power series, accurate to order :
When you do operations on a power series, the result is computed only to the appropriate order in x:
This turns the power series back into an ordinary expression:
Now the square is computed exactly:
Applying Expand gives a result with 11 terms:
find the power series expansion of expr about the point x=x0 to at most n th order
truncate a power series to give an ordinary expression
Power series operations.
Making Power Series Expansions
find the power series expansion of expr about the point x=x0 to order at most (x-x0)n
find series expansions with respect to y, then x
Functions for creating power series.
Here is the power series expansion for about the point to order :
Here is the series expansion of about the point :
If the Wolfram Language does not know the series expansion of a particular function, it writes the result symbolically in terms of derivatives:
In mathematical terms, Series can be viewed as a way of constructing Taylor series for functions.
The standard formula for the Taylor series expansion about the point of a function with th derivative is . Whenever this formula applies, it gives the same results as Series. (For common functions, Series nevertheless internally uses somewhat more efficient algorithms.)
Series can also generate some power series that involve fractional and negative powers, not directly covered by the standard Taylor series formula.
Here is a power series that contains negative powers of x:
Here is a power series involving fractional powers of x:
Series can also handle series that involve logarithmic terms:
There are, of course, mathematical functions for which no standard power series exist. The Wolfram Language recognizes many such cases.
Series sees that has an essential singularity at , and does not produce a power series:
Series can nevertheless give you the power series for about the point :
Especially when negative powers occur, there is some subtlety in exactly how many terms of a particular power series the function Series will generate.
One way to understand what happens is to think of the analogy between power series taken to a certain order, and real numbers taken to a certain precision. Power series are "approximate formulas" in much the same sense as finiteprecision real numbers are approximate numbers.
The procedure that Series follows in constructing a power series is largely analogous to the procedure that N follows in constructing a realnumber approximation. Both functions effectively start by replacing the smallest pieces of your expression by finiteorder, or finiteprecision, approximations, and then evaluating the resulting expression. If there are, for example, cancellations, this procedure may give a final result whose order or precision is less than the order or precision that you originally asked for. Like N, however, Series has some ability to retry its computations so as to get results to the order you ask for. In cases where it does not succeed, you can usually still get results to a particular order by asking for a higher order than you need.
Series compensates for cancellations in this computation, and succeeds in giving you a result to order :
When you make a power series expansion in a variable x, the Wolfram Language assumes that all objects that do not explicitly contain x are in fact independent of x. Series thus does partial derivatives (effectively using D) to build up Taylor series.
Both a and n are assumed to be independent of x:
a[x] is now given as an explicit function of x:
You can use Series to generate power series in a sequence of different variables. Series works like Integrate, Sum, and so on, and expands first with respect to the last variable you specify.
Series performs a series expansion successively with respect to each variable. The result in this case is a series in x, whose coefficients are series in y:
The Representation of Power Series
Power series are represented in the Wolfram System as SeriesData objects.
The power series is printed out as a sum of terms, ending with O[x] raised to a power:
Internally, however, the series is stored as a SeriesData object:
By using SeriesData objects, rather than ordinary expressions, to represent power series, the Wolfram System can keep track of the order and expansion point, and do operations on the power series appropriately. You should not normally need to know the internal structure of SeriesData objects.
You can recognize a power series that is printed out in standard output form by the presence of an O[x] term. This term mimics the standard mathematical notation , and represents omitted terms of order . For various reasons of consistency, the Wolfram System uses the notation O[x]^n for omitted terms of order , corresponding to the mathematical notation , rather than the slightly more familiar, though equivalent, form .
Any time that an object like O[x] appears in a sum of terms, the Wolfram System will in fact convert the whole sum into a power series.
The presence of O[x] makes the Wolfram System convert the whole sum to a power series:
Series objects can involve fractional powers:
Here is the internal representation of the series:
Series can involve logarithmic terms:
The logarithmic factors appear explicitly inside the SeriesData coefficient list:
Operations on Power Series
The Wolfram Language allows you to perform many operations on power series. In all cases, the Wolfram Language gives results only to as many terms as can be justified from the accuracy of your input.
Here is a power series accurate to fourth order in :
When you square the power series, you get another power series, also accurate to fourth order:
Taking the logarithm gives you the result 2x, but only to order :
The Wolfram Language keeps track of the orders of power series in much the same way as it keeps track of the precision of approximate real numbers. Just as with numerical calculations, there are operations on power series which can increase, or decrease, the precision (or order) of your results.
Here is a power series accurate to order :
This gives a power series that is accurate only to order :
The Wolfram Language also allows you to do calculus with power series.
Here is a power series for :
Here is its derivative with respect to x:
Integrating with respect to x gives back the original power series:
When you perform an operation that involves both a normal expression and a power series, the Wolfram Language "absorbs" the normal expression into the power series whenever possible.
The 1 is automatically absorbed into the power series:
The x^2 is also absorbed into the power series:
If you add Sin[x], the Wolfram Language generates the appropriate power series for Sin[x], and combines it with the power series you have:
The Wolfram Language also absorbs expressions that multiply power series. The symbol a is assumed to be independent of x:
The Wolfram Language knows how to apply a wide variety of functions to power series. However, if you apply an arbitrary function to a power series, it is impossible for the Wolfram Language to give you anything but a symbolic result.
The Wolfram Language does not know how to apply the function f to a power series, so it just leaves the symbolic result:
Composition and Inversion of Power Series
When you manipulate power series, it is sometimes convenient to think of the series as representing functions, which you can, for example, compose or invert.
compose power series
invert a power series
Composition and inversion of power series.
Here is the power series for to order :
This replaces the variable in the power series for by a power series for :
The result is the power series for :
If you have a power series for a function , then it is often possible to get a power series approximation to the solution for in the equation . This power series effectively gives the inverse function such that . The operation of finding the power series for an inverse function is sometimes known as reversion of power series.
Here is the series for :
Inverting the series gives the series for :
This agrees with the direct series for :
Composing the series with its inverse gives the identity function:
Converting Power Series to Normal Expressions
convert a power series to a normal expression
Converting power series to normal expressions.
Power series in the Wolfram Language are represented in a special internal form, which keeps track of such attributes as their expansion order.
For some purposes, you may want to convert power series to normal expressions. From a mathematical point of view, this corresponds to truncating the power series, and assuming that all higherorder terms are zero.
This generates a power series, with four terms:
Squaring the power series gives you another power series, with the appropriate number of terms:
Normal truncates the power series, giving a normal expression:
You can now apply standard algebraic operations:
give the coefficient of the n th order term in a power series
Extracting coefficients of terms in power series.
This gives the coefficient of in the original power series:
This gives the coefficient for the term in the Taylor expansion of the function about zero:
Solving Equations Involving Power Series
give the equations obtained by equating corresponding coefficients in the power series
solve for coefficients in power series
Solving equations involving power series.
Here is a power series:
This gives an equation involving the power series:
LogicalExpand generates a sequence of equations for each power of x:
This solves the equations for the coefficients a[i]. You can also feed equations involving power series directly to Solve:
Some equations involving power series can also be solved using the InverseSeries function discussed in "Composition and Inversion of Power Series".
Summation of Series
find the sum of expr as n goes from nmin to nmax
Evaluating sums.
The Wolfram System recognizes this as the power series expansion of :
This sum comes out in terms of a Bessel function:
Here is another sum that can be done in terms of common special functions:
Generalized hypergeometric functions are not uncommon in sums:
There are many analogies between sums and integrals. And just as it is possible to have indefinite integrals, so indefinite sums can be set up by using symbolic variables as upper limits.
This is effectively an indefinite sum:
This sum comes out in terms of incomplete gamma functions:
This sum involves polygamma functions:
Taking the difference between results for successive values of gives back the original summand:
The Wolfram System can do essentially all sums that are found in books of tables. Just as with indefinite integrals, indefinite sums of expressions involving simple functions tend to give answers that involve more complicated functions. Definite sums, like definite integrals, often, however, come out in terms of simpler functions.
This indefinite sum gives a quite complicated result:
The definite form is much simpler:
Here is a slightly more complicated definite sum:
Solving Recurrence Equations
If you represent the n th term in a sequence as a[n], you can use a recurrence equation to specify how it is related to other terms in the sequence.
RSolve takes recurrence equations and solves them to get explicit formulas for a[n].
This solves a simple recurrence equation:
This takes the solution and makes an explicit table of the first 10 a[n]:
solve a recurrence equation
Solving a recurrence equation.
This solves a recurrence equation for a geometric series:
This gives the same result:
This gives an algebraic solution to a recurrence equation:
This solves the Fibonacci recurrence equation:
RSolve can be thought of as a discrete analog of DSolve. Many of the same functions generated in solving differential equations also appear in finding symbolic solutions to recurrence equations.
This generates a gamma function, which generalizes the factorial:
This secondorder recurrence equation comes out in terms of Bessel functions:
RSolve does not require you to specify explicit values for terms such as a[1]. Like DSolve, it automatically introduces undetermined constants C[i] to give a general solution.
This gives a general solution with one undetermined constant:
RSolve can solve equations that do not depend only linearly on a[n]. For nonlinear equations, however, there are sometimes several distinct solutions that must be given. Just as for differential equations, it is a difficult matter to find symbolic solutions to recurrence equations, and standard mathematical functions only cover a limited set of cases.
Here is the general solution to a nonlinear recurrence equation:
This gives two distinct solutions:
RSolve can solve not only ordinary difference equations in which the arguments of differ by integers, but also difference equations in which the arguments of are related by multiplicative factors.
This solves the difference analog of the factorial equation:
Here is a secondorder difference equation:
solve a coupled system of recurrence equations
Solving systems of recurrence equations.
This solves a system of two coupled recurrence equations:
solve partial recurrence equations
Solving partial recurrence equations.
Just as one can set up partial differential equations that involve functions of several variables, so one can also set up partial recurrence equations that involve multidimensional sequences. Just as in the differential equations case, general solutions to partial recurrence equations can involve undetermined functions.
This gives the general solution to a simple partial recurrence equation:
Finding Limits
In doing many kinds of calculations, you need to evaluate expressions when variables take on particular values. In many cases, you can do this simply by applying transformation rules for the variables using the /. operator.
You can get the value of at 0 just by explicitly replacing with 0, and then evaluating the result:
In some cases, however, you have to be more careful.
Consider, for example, finding the value of the expression when . If you simply replace by in this expression, you get the indeterminate result . To find the correct value of when , you need to take the limit.
find the limit of expr when x approaches x0
Finding limits.
This gives the correct value for the limit of as :
No finite limit exists in this case:
Limit can find this limit, even though you cannot get an ordinary power series for at :
The same is true here:
The value of Sign[x] at is 0:
Its limit, however, is 1. The limit is by default taken from above:
Not all functions have definite limits at particular points. For example, the function oscillates infinitely often near , so it has no definite limit there. Nevertheless, at least so long as remains real, the values of the function near always lie between and . Limit represents values with bounded variation using Interval objects. In general, Interval[{xmin,xmax}] represents an uncertain value which lies somewhere in the interval to .
Limit returns an Interval object, representing the range of possible values of near its essential singularity at :
The Wolfram Language can do arithmetic with Interval objects:
The Wolfram Language represents this limit symbolically in terms of an Interval object:
Some functions may have different limits at particular points, depending on the direction from which you approach those points. You can use the Direction option for Limit to specify the direction you want.
find the limit as x approaches x0 from below
find the limit as x approaches x0 from above
Directional limits.
The function has a different limiting value at , depending on whether you approach from above or below:
Approaching from below gives a limiting value of :
Approaching from above gives a limiting value of :
Limit makes no assumptions about functions like f[x] about which it does not have definite knowledge. As a result, Limit remains unevaluated in most cases involving symbolic functions.
Limit has no definite knowledge about f, so it leaves this limit unevaluated:
Limit[expr,x->x0] tells you what the value of expr is when x tends to x0. When this value is infinite, it is often useful instead to know the residue of expr when x equals x0. The residue is given by the coefficient of in the power series expansion of expr about the point x0.
the residue of expr when x equals x0
Computing residues.
The residue here is equal to 1:
The residue here is zero:
Residues can be computed at the point at infinity:
Padé Approximation
The Padé approximation is a rational function that can be thought of as a generalization of a Taylor polynomial. A rational function is the ratio of polynomials. Because these functions only use the elementary arithmetic operations, they are very easy to evaluate numerically. The polynomial in the denominator allows you to approximate functions that have rational singularities.
give the Padé approximation to centered at x0 of order (n,m)
give the diagonal Padé approximation to centered at x0 of order n
Padé approximations.
More precisely, a Padé approximation of order to an analytic function at a regular point or pole is the rational function where is a polynomial of degree , is a polynomial of degree , and the formal power series of about the point begins with the term . If is equal to , the approximation is called a diagonal Padé approximation of order .
Here is the Padé approximation of order to at :
This gives another Padé approximation of the same order:
The initial terms of this series vanish. This is the property that characterizes the Padé approximation:
This plots the difference between the approximation and the true function. Notice that the approximation is very good near the center of expansion, but the error increases rapidly as you move away:
In the Wolfram Language PadeApproximant is generalized to allow expansion about branch points.
This gives the diagonal Padé approximation of order to a generalized rational function at :
This gives the diagonal Padé approximation of order to the logarithm of a rational function at the branch point :
The series expansion of the function agrees with the diagonal Padé approximation up to order :