This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Compute a multivariate Taylor series expansion

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


mtaylor(f, x = x0, <order>, <mode>, <weights>, <Mapcoeffs = mc>)
mtaylor(f, x, <order>, <mode>, <weights>, <Mapcoeffs = mc>)
mtaylor(f, x = x0, AbsoluteOrder = order, <weights>, <Mapcoeffs = mc>)
mtaylor(f, x = x0, RelativeOrder = order, <weights>, <Mapcoeffs = mc>)
mtaylor(f, [x = x0, y = y0, …], <order>, <mode>, <weights>, <Mapcoeffs = mc>)
mtaylor(f, [x, y, …], <order>, <mode>, <weights>, <Mapcoeffs = mc>)
mtaylor(f, [x = x0, y = y0, …], <AbsoluteOrder = order>, <weights>, <Mapcoeffs = mc>)
mtaylor(f, [x = x0, y = y0, …], RelativeOrder = order, <weights>, <Mapcoeffs = mc>)


mtaylor(f, [x = x0, y = y0, ...]) computes the first terms of the multivariate Taylor series of f with respect to the variables x, y etc. around the points x = x0, y = y0 etc.

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

The terms are counted from the lowest total degree on for finite expansion points, and from the highest total degree term on for expansions around infinity.

If AbsoluteOrder is specified, order represents the truncation order of the series, i.e., no terms of total degree order or higher are computed.

For infinite expansion points, the absolute values of the exponents of the corresponding variables are used to compute the total degree.

For finite expansion points x0, y0, ..., the computed series with respect to the variables x, y, ... of weight w1, w2, ... is

taylor(f(x0 + t^w1*(x - x0), y0 + t^w2*(y - y0), dots), t = 0),

evaluated at the point t = 1.

Environment Interactions

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


Example 1

We compute a Taylor series around the origin (default). The expansion contains all terms through total degree 3:

mtaylor(exp(x^2 - y), [x, y], 4)

We request additional terms of higher order:

mtaylor(exp(x^2 - y), [x, y], 5)

In the example above, the leading term is of total degree 0. In the following example, the leading term is of total degree 2. Thus, the default mode RelativeOrder produces terms of total degree smaller than4 + 2 = 6:

mtaylor(x*y*exp(x^2 - y), [x, y], 4)

We request an absolute truncation order of 4, so that only terms of total degree smaller than 4 are computed:

mtaylor(x*y*exp(x^2 - y), [x, y], AbsoluteOrder = 4)

Example 2

For infinite expansions points a series in the reciprocal of the variable is returned:

mtaylor(exp(z)/(x - y), [x = infinity, y = 0, z])

We reduce the order in z by giving z a higher weight:

mtaylor(exp(z)/(x - y), [x = infinity, y = 0, z], [1, 1, 2])

Example 3

If a Taylor series expansion does not exist, or if mtaylor cannot find a Taylor series expansion, then mtaylor throws an error.

Try to find the Taylor series expansion of around x = 1, y = 1. The Taylor series expansion does not exist, and mtaylor throws an error:

mtaylor(1/(x*y - 1), [x = 1, y = 1])
Error: Cannot compute a Taylor expansion of '1/(x*y - 1)'. [mtaylor]

Example 4

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

mtaylor(sqrt(y)*sin(sqrt(y)/x), [x = infinity, y = 0])

In fact, this is even an undirected expansion:

mtaylor(sqrt(y)*sin(sqrt(y)/x), [x = complexInfinity, y = 0])

Example 5

A common problem in symbolic calculations is "expression swell:" Intermediate expressions which are not or cannot be simplified lead to unnecessarily complicated results. The following is an example of such behavior:

mtaylor((a+x)^n, x, 4)

In general, applying simplify or Simplify to complicated results is a strategy that often helps. In this case, however, it would destroy the format of the series:


What is required is a way to map a function like simplify to the coefficients of the series only. Since mtaylor returns an ordinary expression, this must be done in the mtaylor call itself, using the Mapcoeffs option:

mtaylor((a+x)^n, x, 4, Mapcoeffs=simplify)

Related Examples



An arithmetical expression representing a function in x, y, ...

x, y, …

identifiers or indexed identifiers

x0, y0, …

The expansion points: arithmetical expressions. Also expressions involving infinity or complexInfinity are accepted.

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


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

The order concept refers to the total degree in the variables (the sum of all exponents).


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


A list of positive integers determining the number of terms of the computed series. A variable x with weight w contributes as x^w to the total degree of the terms in the series. Thus, using weight 2 for x, halves the order in x to which the series is computed.

By default, all variables have the weight 1.



With this flag, the integer value order is the truncation order of the computed series, i.e., only terms of total degree less than order are present.


With this flag, the terms in the computed series range from some leading total degree v to the highest total degree v + order - 1 (i.e., the truncation order w.r.t. the total degree is v + order).


Option, specified as Mapcoeffs = mc

When building the resulting expression, for each coefficient c, insert mc(c) instead.

Return Values

Arithmetical expression.

Overloaded By


See Also

MuPAD Functions

Was this topic helpful?