def expr_from_dict(rep, *gens):
 result = []
 for (monom, coeff) in rep.items():
  term = [coeff]
  for (g, m) in zip(gens, monom):
   if m:
    term.append(Pow(g, m))
  result.append(Mul(*term))
 return Add(*result)

def expr_from_dict ( rep , * gens ) : result = [ ] for ( monom , coeff ) in rep . items ( ) : term = [ coeff ] for ( g , m ) in zip ( gens , monom ) : if m : term . append ( Pow ( g , m ) ) result . append ( Mul ( * term ) ) return Add ( * result )
convert a multinomial form into an expression .