The problem is that series is trying to be clever and really give you 6 terms. In particular foo.series(x,n=N) is supposed to return something O(x**N). This is impossible here and series should probably fail gracefully, but the behaviour is not totally unexpected.
Note that you can always use nseries (for expansions about 0 from the right). This will always return a correct result, but not necessarily to the right order. E.g. (sin(x)/x).nseries(x, n=N) only returns O(x**(N-1)). What series does is to keep increasing the n passed to nseries until the result is O(x**N). On 22 Apr., 14:24, Frédéric Grosshans-André <[email protected]> wrote: > exp(O(x)).series() fails with the following ValueError: Could not > calculate 6 terms for exp(O(x)). On the other hand exp(O(x)).series(n=1) > succeeds and give the expected result. Is this a feature preventing me > to ask too precise Taylor expansion ? If yes, is there a way to ask the > series to return what I expected ? I'd like an expansion as far as > possible, with a maximum at O(x**n), of course. > > Below, a cut-n-pasted version of my trial, in the git master branch. > > Fred > > In [6]: exp(O(x)).series() > --------------------------------------------------------------------------- > ValueError Traceback (most recent call > last) > > /home/fred/git/sympy/<ipython console> in <module>() > > /home/fred/git/sympy/sympy/core/expr.pyc in series(self, x, x0, n, dir) > 1257 else: > 1258 raise ValueError('Could not calculate %s > terms for %s' > -> 1259 % (str(n), self)) > 1260 o = s1.getO() > 1261 s1 = s1.removeO() > > ValueError: Could not calculate 6 terms for exp(O(x)) > > In [7]: exp(O(x)).series(n=1) > Out[7]: 1 + O(x) -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
