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.
The function is sensitive to the environment variable ORDER
,
which determines the default number of terms in series computations.
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)
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])
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]
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])
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:
simplify(%)
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)

An arithmetical
expression representing a function in 
 

The expansion points: arithmetical expressions. Also expressions
involving If not specified, the default expansion point 0 is used. 

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

One of the flags 

A list of positive integers determining the number of terms
of the computed series. A variable By default, all variables have the weight 1. 

With this flag, the integer value 

With this flag, the terms in the computed series range from
some leading total degree 

Option, specified as When building the resulting expression, for each coefficient 
Arithmetical expression.
f