def extract_leading_order(self, symbols): """Returns the leading term and its order. Examples ======== >>> from diofant.abc import x >>> (x + 1 + 1/x**5).extract_leading_order(x) ((x**(-5), O(x**(-5))),) >>> (1 + x).extract_leading_order(x) ((1, O(1)),) >>> (x + x**2).extract_leading_order(x) ((x, O(x)),) """ from diofant import Order lst = [] symbols = list(symbols if is_sequence(symbols) else [symbols]) point = [0] * len(symbols) seq = [(f, Order(f, *zip(symbols, point))) for f in self.args] for ef, of in seq: for e, o in lst: if o.contains(of) and o != of: of = None break if of is None: continue new_lst = [(ef, of)] for e, o in lst: if of.contains(o) and o != of: continue new_lst.append((e, o)) lst = new_lst return tuple(lst)
def test_Order(): assert precedence(Order(x)) == PRECEDENCE["Atom"]
def test_series(): for c in (Limit, Limit(y, x, 1), Order, Order(y)): check(c)