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.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

**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 series expansions serve for approximating an arbitrary
expression by a polynomial expression around some value of a variable.
Taylor series expansions approximate expressions for which the derivatives
up to infinite order exist around a particular value * x_{0}* of
a variable

`x`

:.

To compute Taylor series expansion, use the `taylor`

command. For example, approximate
the expression `sin(x)/x`

around `x = 0`

:

exact := sin(x)/x: approx := taylor(sin(x)/x, x)

Plot the exact expression and its taylor series expansion in
the same coordinate system. The taylor series expansion approximates
the expression near `x = 0`

, but visibly deviates
from `sin(x)/x`

for larger `|x|`

:

plot( plot::Function2d(exact, x = -PI..PI, Legend = "sin(x)/x", Color = RGB::Red), plot::Function2d(approx, x = -PI..PI, Legend = "approximation of sin(x)/x") )

Accuracy of an approximation depends on the proximity to the expansion point and on the number of terms used in the series expansion. See how to specify the number of terms in Controlling the Number of Terms in Series Expansions.

Taylor series expansions around `x = 0`

are
also called Maclaurin series expansions. Approximate the expressions
by Maclaurin series:

taylor(exp(x), x); taylor(sin(x), x); taylor(cos(x)/(1 - x), x)

The Maclaurin series expansion does not exist for the following
expression. MuPAD^{®} throws an error:

taylor(arccot(x), x)

Error: Cannot compute a Taylor expansion of 'arccot(x)'. Try 'series' for a more general expansion. [taylor]

You can represent the following expression by a Taylor series
around `x = 1`

. To compute the series expansion around
a nonzero value of a variable, specify the value. For example, compute
the Taylor series expansions around `x = 1`

for the
following expressions:

taylor(ln(x), x = 1); taylor(arccot(x), x = 1)

The `taylor`

command
returns results in the form of Taylor series including the order term `O`

. To convert
the results to a regular polynomial expression without the `O`

-term, use
the `expr`

command:

s := taylor(sin(x)/exp(x), x); expr(s)

Was this topic helpful?