def leadterm(self, x): """ Returns the leading term a*x**b as a tuple (a, b). Example: >>> from sympy.abc import x >>> (1+x+x**2).leadterm(x) (1, 0) >>> (1/x**2+x+x**2).leadterm(x) (1, -2) Note: self is assumed to be the result returned by Basic.series(). """ from sympy import powsimp x = sympify(x) c,e = self.as_leading_term(x).as_coeff_exponent(x) c = powsimp(c, deep=True, combine='exp') if not c.has(x): return c,e raise ValueError("cannot compute leadterm(%s, %s), got c=%s" % (self, x, c))
def leadterm(self, x): """ Returns the leading term a*x**b as a tuple (a, b). Example: >>> from sympy.abc import x >>> (1+x+x**2).leadterm(x) (1, 0) >>> (1/x**2+x+x**2).leadterm(x) (1, -2) Note: self is assumed to be the result returned by Basic.series(). """ from sympy import powsimp x = sympify(x) c, e = self.as_leading_term(x).as_coeff_exponent(x) c = powsimp(c, deep=True, combine='exp') if not c.has(x): return c, e raise ValueError("cannot compute leadterm(%s, %s), got c=%s" % (self, x, c))
def leadterm(self, x): x = Basic.sympify(x) c,e = self.as_leading_term(x).as_coeff_exponent(x) if not c.has(x): return c,e raise ValueError("cannot compute ldegree(%s, %s), got c=%s" % (self, x, c))