By "return a polynomial" I mean return one in the given representation, ie it should be an anonymous array. So you need to change the last @c for \@c. (Makes this 110 characters.) The rule about different polynomials means that if you call this twice, the second answer should be a reference to a different array than the first.