## Documentation Center |

Taylor series expansions approximate an arbitrary expression
with a polynomial. The number of terms in a series expansion determines
the accuracy of the approximation. The number of terms in a series
expansion depends on the truncation
order of the expansion. By default, MuPAD^{®} computes the
first six terms of series expansions:

taylor(exp(x), x)

The number of terms includes the terms with coefficients equal
to zero. For example, the taylor series expansion of `cos(x)` includes
the terms 0 *x*, 0 *x*^{3},
and 0 *x*^{5}. MuPAD computes
these terms, but does not display them:

taylor(cos(x), x)

Suppose, you want to approximate an exponential function with
the polynomial expression around `x = 0`. Use the
third parameter in `taylor` to
specify the order of series expansion. For example, compute the series
expansions `approx1` specifying the truncation order `3`.
Compare the result with the series expansion computed for the default
order:

exact := exp(x): approx1 := taylor(exp(x), x, 3); approx2 := taylor(exp(x), x)

Plot the exact expression, `exact`, and its
taylor series expansions, `approx1` and `approx2`,
in the same coordinate system. The series expansion with more terms
approximates the expression `exp(x)` better:

plot( plot::Function2d(exact, x = -PI..PI, Legend = "exp(x)", Color = RGB::Red), plot::Function2d(approx2, x = -PI..PI, Legend = "approximation of exp(x), up to O(x^6)", Color = RGB::Blue), plot::Function2d(approx1, x = -PI..PI, Legend = "approximation of exp(x), up to O(x^3)", Color = RGB::Green) )

There are two ways to change the truncation order for series expansions:

Locally by passing the truncation order as the third parameter to

`taylor`. By using this parameter, you specify the truncation order for a particular series expansion. All other series expansions use the default order. The parameter is available for the following commands:`taylor`,`mtaylor`, and`series`. For more information, see the help pages for these commands.Globally by using the environment variable

`ORDER`. When you change this variable, all series expansions use the new truncation order.

To change the truncation order for a particular series expansion,
pass the new order as a third parameter to `taylor`:

taylor(exp(x), x, 10)

To change the default truncation order for all series expansions,
modify the environment variable `ORDER`:

ORDER := 7: taylor(exp(x), x)

The following computations use the new value of `ORDER`:

taylor(sqrt(1 - x), x)

delete ORDER: taylor(sqrt(1 - x), x)

Was this topic helpful?