Annihilating polynomials for similarity and commutator mappings