예제 #1
0
    def _eval_as_leading_term(self, x):
        from diofant import factor_terms

        expr = self.func(*[t.as_leading_term(x) for t in self.args]).removeO()
        if not expr:
            # simple leading term analysis gave us 0 but we have to send
            # back a term, so compute the leading term (via series)
            return self.compute_leading_term(x)
        elif not expr.is_Add:
            return expr
        else:
            plain = expr.func(*[s for s, _ in expr.extract_leading_order(x)])
            rv = factor_terms(plain, fraction=False)
            rv_simplify = rv.simplify()
            # if it simplifies to an x-free expression, return that;
            # tests don't fail if we don't but it seems nicer to do this
            if x not in rv_simplify.free_symbols:
                if rv_simplify.is_zero and plain.is_zero is not True:
                    return (expr - plain)._eval_as_leading_term(x)
                return rv_simplify
            return rv
예제 #2
0
 def simp_hyp(expr):
     return factor_terms(expand_mul(expr)).rewrite(sin)
예제 #3
0
 def simp_hyp(expr):
     return factor_terms(expand_mul(expr)).rewrite(sin)