Naive approach

First, we show it in a naive way, similar to the first solution above.

def evaluate(f,m):
    res=0
    for term in f.terms():
        product=1
        for variable in term.variables():
            product=m[variable]*product
        res=res+product
    return Polynomial(res)



2010-09-14