# 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`>)
taylor(`f`, `x = x0`, <`order`>, <`mode`>)
taylor(`f`, `x`, <`AbsoluteOrder = order`>)
taylor(`f`, `x = x0`, <`AbsoluteOrder = order`>)
taylor(`f`, `x`, <`RelativeOrder = order`>)
taylor(`f`, `x = x0`, <`RelativeOrder = order`>)
```

## 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`.

If `taylor` finds the corresponding Taylor series, 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`. See Example 1.

If a Taylor series does not exist or if `taylor` cannot find it, then `taylor` throws an error. See Example 2 and 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 . See 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

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 you apply the function `expr` to a series, the result is 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` throws an error:

`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] ```

Call `series` to compute a more general series expansion. A Laurent expansion does exist:

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

### Example 3

If `taylor` cannot find a Taylor series expansion, it also throws an error.

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

Call `series` with the optional argument. In this case, `series` returns a more general type of expansion. In cases where `series` cannot find a series expansion, it returns the symbolic function call.

`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`.

## Return Values

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

`f`