Previous Page Next Page Contents

taylor -- compute a Taylor series expansion

Introduction

taylor(f, x = x0) computes the first terms of the Taylor series of f with respect to the variable x around the point x0.

Call(s)

taylor(f, x < = x0> <, order>)

Parameters

f - an arithmetical expression representing a function in x
x - an identifier
x0 - the expansion point: an arithmetical expression; if not specified, the default expansion point 0 is used.
order - the number of terms to be computed: a nonnegative integer; the default order is given by the environment variable ORDER (default value 6).

Returns

an object of domain type Series::Puiseux or a symbolic expression of type "taylor".

Side Effects

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

Overloadable:

f

Related Functions

asympt, diff, limit, O, series, Series::Puiseux, Type::Series

Details

Example 1

We compute a Taylor series around the default point 0:

>> s := taylor(exp(x^2), x)
                                      4
                                 2   x       6
                            1 + x  + -- + O(x )
                                     2

The result of taylor is of the following domain type:

>> domtype(s)
                              Series::Puiseux

If we apply the function expr to a series, we get an arithmetical expression without the order term:

>> expr(s); domtype(%)
                                      4
                                 2   x
                                x  + -- + 1
                                     2
      
                                 DOM_EXPR
>> delete s:

Example 2

A Taylor series expansion of f(x) = 1/(x^2-1) around x = 1 does not exist. Therefore, taylor responds with an error message:

>> taylor(1/(x^2 - 1), x = 1)
      Error: does not have a Taylor series expansion, try 'series' [\
      taylor]

Following the advice given in this error message, we try series to compute a more general series expansion. A Laurent expansion does exist:

>> series(1/(x^2 - 1), x = 1)
                                             2          3
          1             / x       \   (x - 1)    (x - 1)
      --------- - 1/4 + | - - 1/8 | - -------- + -------- +
      2 (x - 1)         \ 8       /      16         32
      
                  4
         O((x - 1) )

Example 3

If a Taylor series expansion cannot be computed, then the function call with evaluated arguments is returned symbolically together with a warning:

>> taylor(1/exp(x^a), x = 0)
      Warning: could not compute Taylor series expansion; try 'serie\
      s' with option 'Left', 'Right', or 'Real' for a more general e\
      xpansion [taylor]
      
                               /    1           \
                         taylor| -------, x = 0 |
                               |      a         |
                               \ exp(x )        /

In this example, also series returns a symbolic function call. Even if you try one of the proposed options, series is not able to compute a series expansion.

Here is another example where no Taylor expansion can be computed. However, series with an optional argument yields a more general type of expansion in this case:

>> taylor(psi(1/x), x = 0)
      Warning: could not compute Taylor series expansion; try 'serie\
      s' with option 'Left', 'Right', or 'Real' for a more general e\
      xpansion [taylor]
      
                               /    / 1 \        \
                         taylor| psi| - |, x = 0 |
                               \    \ x /        /
>> series(psi(1/x), x = 0, Right)
                                     2    4
                        / 1 \   x   x    x        5
                      ln| - | - - - -- + --- + O(x )
                        \ x /   2   12   120

Example 4

This is an example of a ``directional'' Taylor expansion along the real axis around infinity:

>> taylor(exp(1/x), x = infinity)
                  1    1      1       1       1       / 1  \
              1 + - + ---- + ---- + ----- + ------ + O| -- |
                  x      2      3       4        5    |  6 |
                      2 x    6 x    24 x    120 x     \ x  /

Example 5

Here is an example where the actual number of computed terms differs from the requested number:

>> taylor((sin(x^4) - tan(x^4)) / x^10, x, 15) 
                                  2
                                 x       5
                               - -- + O(x )
                                 2

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000