James Frye asks about simplifying things like > 2 A + 2 %I B > ------------ > 2 The attached code will pull out common factors in things like the above. It is in a way a very simple case of factorization, except that unlike factorization, it never makes radical changes to the form of the expression (e.g. expanding out (a+b)^100+1). Usually, you'll want to use it as scanmap(pullout,...), so I've included convenience functions scan_pullout etc. There are three variants: pullout pulls out any common factor; pullout_num only numeric factors (not including radicals); pullout_const pulls out any constant factors (including arbitrary expressions involving only numbers and symbolic constants like %pi). There is also pullout_using_content, which I don't generally recommend. I am including a table of example results for the three functions as an attachment. Though pullout seems like the "most powerful", it is not necessarily what you want. For example: pullout(x*(a^7-1)+(y+1)^5*(a-1)) = 7 5 (a - 1) x (a - 1) ((y + 1) + ----------) a - 1 Notice that the division hasn't been carried out. Though that is probably a *good* thing in this case, it does look peculiar. On the other hand, pullout_using_content *does* divide out, so you have: pullout_using_content(x*(z^7-1)+(y+1)^5*(z-1)) = 7 5 4 3 2 5 4 x z + (y + 5 y + 10 y + 10 y + 5 y + 1) z - y - 5 y 3 2 - 10 y - 10 y - 5 y - x - 1 Is that better? Just to confuse matters, since content is a CRE function, the result depends on the variable ordering: pullout_using_content(x*(a^7-1)+(y+1)^5*(a-1)) = 5 4 3 2 (a - 1) (y + 5 y + 10 y + 10 y + 5 y 6 5 4 3 2 + (a + a + a + a + a + a + 1) x + 1) Good luck! -s
Attached file: pullout.txt
Attached file: pullout.mac