taylor

Compute a Taylor series expansion

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

taylor(f, x, <order>, <mode>, <NoWarning>)
taylor(f, x = x0, <order>, <mode>, <NoWarning>)
taylor(f, x, <AbsoluteOrder = order>, <NoWarning>)
taylor(f, x = x0, <AbsoluteOrder = order>, <NoWarning>)
taylor(f, x, <RelativeOrder = order>, <NoWarning>)
taylor(f, x = x0, <RelativeOrder = order>, <NoWarning>)

Description

taylor(f, x = x0) computes the first terms of the Taylor series of f with respect to the variable x around the point x0.

Three cases can occur:

  1. taylor is able to compute the corresponding Taylor series. In this case, the result is a series expansion of domain type Series::Puiseux. Use expr to convert it to an arithmetical expression of domain type DOM_EXPR. Cf. Example 1.

  2. taylor is able to decide that the corresponding Taylor series does not exist. In this case, an error is raised. Cf. Example 2.

  3. taylor is not able to determine whether the corresponding Taylor series exists or not. Internally, the function series is called; it returns a symbolical call. In this case, also taylor returns a symbolic expression of type "taylor". Cf. Example 3.

Mathematically, the expansion computed by taylor is valid in some open disc around the expansion point in the complex plane.

If x0 is complexInfinity, then an expansion around the complex infinity, i.e., the north pole of the Riemann sphere, is computed. If x0 is infinity or -infinity, a directed series expansion valid along the real axis is computed.

Such an expansion is computed as follows: The series variable x in f is replaced by . Then a directed series expansion at u = 0 from the right is computed. If x0 = complexInfinity, then an undirected expansion around u = 0 is computed. Finally, is substituted in the result.

Mathematically, the result of an expansion around complexInfinity or ±infinity is a power series in . Cf. Example 4.

With the default mode RelativeOrder, the number of requested terms for the expansion is order if specified. If no order is specified, the value of the environment variable ORDER used. You can change the default value 6 by assigning a new value to ORDER.

The number of terms is counted from the lowest degree term on for finite expansion points, and from the highest degree term on for expansions around infinity, i.e., "order" has to be regarded as a "relative truncation order".

If AbsoluteOrder is specified, order represents the truncation order of the series (i.e., the x power in the Big-Oh term).

taylor uses the more general series function series to compute the Taylor expansion. See the corresponding help page for series for details about the parameters and the data structure of a Taylor series expansion.

Environment Interactions

The function is sensitive to the environment variable ORDER, which determines the default number of terms in series computations.

Examples

Example 1

We compute a Taylor series around the default point 0:

s := taylor(exp(x^2), x)

The result of taylor is of the following domain type:

domtype(s)

If we apply the function expr to a series, we get an arithmetical expression without the order term:

expr(s)

domtype(%)

delete s:

Example 2

A Taylor series expansion of around x = 1 does not exist. Therefore, taylor responds with an error message:

taylor(1/(x^2 - 1), x = 1)
Error: Cannot compute a Taylor expansion of '1/(x^2 - 1)'. Try 'series' for a more general expansion. [taylor]

Following the advice given in this error message, we try series to compute a more general series expansion. A Laurent expansion does exist:

series(1/(x^2 - 1), x = 1)

Example 3

If a Taylor series expansion cannot be computed, then the function call with evaluated arguments is returned symbolically together with a warning:

taylor(1/exp(x^a), x = 0)
Warning: Cannot compute a Taylor expansion of 'exp(-x^a)'. Try 'series' with the 'Left', 'Right', or 'Real' option for a more general expansion. [taylor]

In this example, also series returns a symbolic function call. Even if you try one of the proposed options, series is not able to compute a series expansion.

Here is another example where no Taylor expansion can be computed. However, series with an optional argument yields a more general type of expansion in this case:

taylor(psi(1/x), x = 0)
Warning: Cannot compute a Taylor expansion of 'psi(1/x)'. Try 'series' with the 'Left', 'Right', or 'Real' option for a more general expansion. [taylor]

series(psi(1/x), x = 0, Right)

Example 4

This is an example of a directed Taylor expansion along the real axis around infinity:

taylor(exp(1/x), x = infinity)

In fact, this is even an undirected expansion:

taylor(exp(1/x), x = complexInfinity)

Parameters

f

An arithmetical expression representing a function in x

x

An identifier or an indexed identifier

x0

The expansion point: an arithmetical expression. Also expressions involving infinity or complexInfinity are accepted.

If not specified, the default expansion point 0 is used.

order

The truncation order (in conjunction with AbsoluteOrder) or, in conjunction with RelativeOrder, the number of terms to be computed, respectively. A nonnegative integer; the default order is given by the environment variable ORDER (default value 6).

mode

One of the flags AbsoluteOrder or RelativeOrder. The default is RelativeOrder.

Options

AbsoluteOrder

With this flag, the integer value order is the truncation order of the computed series (i.e., the exponent of x in the Big-Oh term).

RelativeOrder

With this flag, the exponents of x in the computed series range from some leading order v to the highest exponent v + order - 1 (i.e., the exponent of x in the Big-Oh term is v + order). In this case, order essentially is the "number of x powers" in the computed series if the series involves all integer powers of x.

NoWarning

Suppresses warning messages printed during the series computation. This can be useful if taylor is called within user-defined procedures.

Return Values

Object of domain type Series::Puiseux or a symbolic expression of type "taylor".

Overloaded By

f

Was this topic helpful?