 
 
 
2.33.3  Series expansion : series
 
series takes from one to four arguments :
- 
an expression dependending of a variable (by default x),
- an equality variable=value (e.g. x=a) where to compute
the series expansion, by default x=0, 
- an integer n, the order of the series expansion,
by default 5
- a direction -1, 1 (for unidirectional series expansion)
or 0 (for bidirectional series expansion) (by default 0).
Note that the syntax ...,x,a,n,... 
(instead of ...,x=a,n,...) is also accepted.
series returns a polynomial in x-a, plus a remainder 
of the form:
(x-a)^n*order_size(x-a)
where order_size is a function such that,
| ∀ r>0, |  | xr order_size(x) = 0 | 
The order returned by series may be smaller than n if
cancellations between numerator and denominator occur.
Examples :
- 
series expansion in the vicinity of x=0
 Find an series expansion of 
x3+sin(x)3/x−sin(x) 
in the vicinity of x=0.
 Input :series(x^3+sin(x)^3/(x-sin(x)))
 Output is only a 2nd-order series expansion :6+-27/10*x^2+x^3*order_size(x)
 We have lost 3 orders because the valuation of the numerator and
denominator is 3. To get a 4-th order expansion, we must therefore 
take n=7, input:series(x^3+sin(x)^3/(x-sin(x)),x=0,7)
 Or :series(x^3+sin(x)^3/(x-sin(x)),x,0,7)
 Output is a 4th-order series expansion :6+-27/10*x^2+x^3+711/1400*x^4+
x^5*order_size(x)
 
- series expansion in the vicinity of x=a
 Find a series 4th-order expansion of cos(2x)2 in the vicinity of
x=π/6.
 Input:series(cos(2*x)^2,x=pi/6, 4)
 Output :1/4+(-(4*sqrt(3)))/4*(x-pi/6)+(4*3-4)/4*(x-pi/6)^2+ 32*sqrt(3)/3/4*(x-pi/6)^3+(-16*3+16)/3/4*(x-pi/6)^4+ (x-pi/6)^5*order_size(x-pi/6)
 
- series expansion in the vicinity of x=+∞ or x=-∞
- 
Find a 5th-order series expansion of arctan(x) in the vicinity of
x=+∞.
 Input :series(atan(x),x=+infinity,5) Output :pi/2-1/x+1/3*(1/x)^3+1/-5*(1/x)^5+
(1/x)^6*order_size(1/x)
 Note that the expansion variable and the argument of the 
order_size function is
 h=1/x →x→ + ∞ 0 .
- Find a series 2nd-order expansion of (2x−1)e1/x−1 in the vicinity of
x=+∞.
 Input :series((2*x-1)*exp(1/(x-1)),x=+infinity,3) Output is only a 1st-order series expansion :2*x+1+2/x+(1/x)^2*order_size(1/x)
 To get a 2nd-order series expansion in 1/x, input:series((2*x-1)*exp(1/(x-1)),x=+infinity,4) Output :2*x+1+2/x+17/6*(1/x)^2+(1/x)^3*order_size(1/x)
 
- Find a 2nd-order series expansion of (2x−1)e1/x−1 in the vicinity 
of x=-∞.
 Input :series((2*x-1)*exp(1/(x-1)),x=-infinity,4) Output :-2*(-x)+1-2*(-1/x)+17/6*(-1/x)^2+
 (-1/x)^3*order_size(-1/x)
 
 
- unidirectional series expansion.
 The fourth parameter indicates the direction :- 
1 to do an series expansion in the vicinity of x=a with 
  x>a,
- -1 to do an series expansion in the vicinity of x=a with 
  x<a,
- 0 to do an series expansion in the vicinity of x=a with 
  x ≠ a.
 For example, 
find a 2nd-order series expansion of  (1+x)1/x/x3  in 
the vicinity of x=0+. Input :series((1+x)^(1/x)/x^3,x=0,2,1)
 Output :exp(1)/x^3+(-(exp(1)))/2/x^2+1/x*order_size(x)
 
 
 
