Simple, algebraic solution

def simple_graded(f, d):
    return sum((t for t in f.terms() if t.deg()==d))
This solution is obvious, but quite slow.



2009-09-10