not the prettiest code I've ever written.  handles linear and quadratic cases *sometimes*.  this could all be fixed/aided if I'd just write a polynomial factor function...