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

An arithmetical
expression representing a function in 

An identifier or an indexed identifier 

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

The truncation order (in conjunction with 

One of the flags 

With this flag, the integer value 

With this flag, the exponents of 
Object of domain type Series::Puiseux
or
a symbolic expression of type "taylor"
.
f
asympt
 diff
 limit
 mtaylor
 O
 series
 Series::Puiseux
 Type::Series