### 2.33.2 Taylor expansion : `taylor`

`taylor` 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 Taylor 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,``n``,``a``,...` (instead of `...,x=``a``,``n``,...`) is also accepted.
`taylor` 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,

lim
x→ 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).
Input :

`taylor(sin(x),x=1,2)`

Or (be carefull with the order of the arguments !) :

`taylor(sin(x),x,2,1)`

Output :

`sin(1)+cos(1)*(x-1)+(-(1/2*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

taylor(

x3+sin(x)3
x−sin(x)

)

Input :

`taylor(x```^```3+sin(x)```^```3/(x-sin(x)))`

The output is only a 2nd-order series expansion :

`6+-27/10*x```^2```+x```^```3*order_size(x)`

Indeed the numerator and denominator valuation is 3, hence we loose 3 orders. To get order 4, we should ask n=7, input :

`taylor(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)`