I have programmed a procedure to calculate certain polynomials associated to matrices. There is a variable for each column of the matrix, say z1,...,zn, and the polynomials get quite large as the matrices grow in size. The procedure gives the correct answer but, for large matrices, the terms in the resulting polynomial are not collected properly. For instance, terms z1*z2*z3*z4 and -z1*z2*z3*z4 might both appear. "Simplify %;" does not cancel these terms. By copying the answer and pasting it as a command, I can cancel the terms but most answers are so big that copying cannot be done in practice (hundreds of pages). It does not seem to help to define the answer as a function and evaluate it in the variables. Does anyone have any ideas?

Please Wait...