13.5.2 Series expansion
The taylor or
series command finds Taylor expansions.
-
taylor takes one mandatory and
four optional arguments:
-
expr, an expression depending on a variable.
- Optionally, x, the variable (by default x).
- Optionally n, an integer, the order of the series expansion
(by default 5).
- Optionally, a, the center of the Taylor expansion (by
default 0). This can be combined with the optional x by
replacing x by x=a.
- dir, a direction, which can be -1 or
1, for unidirectional series expansion, or 0 (for
bidirectional series expansion) (by default 0).
- taylor(expr,x ⟨,a,n,dir ⟩)
returns the Taylor expansion of expr about a or order n;
consisting of a polynomial in x−a plus a remainder of the form
of the form:
where order_size is a function such that
∀ r>0, | | xr order_size(x)=0
|
For regular series expansion, order_size
is a bounded function, but for non regular series expansion, it might tend slowly to
infinity, for example like a power of ln(x).
Example
or:
or (be careful with the order of the arguments):
or:
|
sin | ⎛
⎝ | 1 | ⎞
⎠ | +cos | ⎛
⎝ | 1 | ⎞
⎠ | ⎛
⎝ | x−1 | ⎞
⎠ | − | | sin | ⎛
⎝ | 1 | ⎞
⎠ | ⎛
⎝ | x−1 | ⎞
⎠ | 2+ | ⎛
⎝ | x−1 | ⎞
⎠ | 3 order_size | ⎛
⎝ | x−1 | ⎞
⎠ |
| | | | | | | | | | |
|
Remark.
The order returned by taylor may
be smaller than n if cancellations between numerator and denominator
occur, for example consider
taylor(x^3+sin(x)^3/(x-sin(x)),x=0,5) |
|
6− | | x2+x3+ | | x4+x6 order_size | ⎛
⎝ | x | ⎞
⎠ |
| | | | | | | | | | |
|
which is only a 2nd degree expansion.
Indeed the numerator and denominator valuation is 3, hence you lose 3
orders. To get order 4, you should use n=7.
taylor(x^3+sin(x)^3/(x-sin(x)),x=0,7) |
|
6− | | x2+x3+ | | x4− | | x6+x8 order_size | ⎛
⎝ | x | ⎞
⎠ |
| | | | | | | | | | |
|
a fourth degree expansion.
Examples
Find a 4th-order expansion of cos(2x)2 in the vicinity of
x=π/6.
taylor(cos(2*x)^2,x=pi/6, 4) |
|
| | − | √ | | | ⎛
⎜
⎜
⎝ | x− | | ⎞
⎟
⎟
⎠ | +2 | ⎛
⎜
⎜
⎝ | x− | | ⎞
⎟
⎟
⎠ | | + | | | √ | | | ⎛
⎜
⎜
⎝ | x− | | ⎞
⎟
⎟
⎠ | | − | | | ⎛
⎜
⎜
⎝ | x− | | ⎞
⎟
⎟
⎠ | | + | ⎛
⎜
⎜
⎝ | x− | | ⎞
⎟
⎟
⎠ | | order_size | ⎛
⎜
⎜
⎝ | x− | | ⎞
⎟
⎟
⎠ |
| | | | | | | | | | |
|
Find a 5th-order series expansion of arctan(x) in the vicinity of
x=+∞.
series(atan(x),x=+infinity,5) |
|
| | − | | + | | − | | + | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ | | order_size | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ |
| | | | | | | | | | |
|
Note that the expansion variable and the argument of the
order_size function is
h=1/x → 0 as x→+∞.
Find a 2nd-order expansion of (2x−1)e1/x−1 in the vicinity of
x=+∞.
series((2*x-1)*exp(1/(x-1)),x=+infinity,3) |
Output (only a 1st-order series expansion):
|
2 | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ | | +1+ | | + | | | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ | | + | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ | | order_size | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ |
| | | | | | | | | | |
|
Note that this is only a 1st-order expansion. To get a 2nd-order
series expansion in 1/x:
series((2*x-1)*exp(1/(x-1)),x=+infinity,4) |
|
2 | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ | | +1+ | | + | | | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ | | + | | | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ | | + | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ | | order_size | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ |
| | | | | | | | | | |
|
Find a 2nd-order series expansion of (2x−1)e1/x−1 in the vicinity
of x=-∞.
series((2*x-1)*exp(1/(x-1)),x=-infinity,4) |
|
−2 | ⎛
⎜
⎜
⎝ | − | | ⎞
⎟
⎟
⎠ | | +1+ | | + | | | ⎛
⎜
⎜
⎝ | − | | ⎞
⎟
⎟
⎠ | | − | | | ⎛
⎜
⎜
⎝ | − | | ⎞
⎟
⎟
⎠ | | + | ⎛
⎜
⎜
⎝ | − | | ⎞
⎟
⎟
⎠ | | order_size | ⎛
⎜
⎜
⎝ | − | | ⎞
⎟
⎟
⎠ |
| | | | | | | | | | |
|
Find a 2nd-order series expansion of (1+x)1/x/x3 in
the vicinity of x=0+.
series((1+x)^(1/x)/x^3,x=0,2,1) |
(Note that this is a one-sided series expansion, since dir=1.)
|
e x−3− | | x−2+x−1 order_size | ⎛
⎝ | x | ⎞
⎠ |
| | | | | | | | | | |
|