Algebra.js
function(s, lookat) { 
                    lookat = lookat || 0;
                    var det = s[lookat], l = s.length; 
                    if(!det) return;
                    //eliminate the first term if it doesn't apply
                    var umax = get_unique_max(det); 
                    for(var i=lookat+1; i<l; i++) {
                        var term = s[i],   
                            is_equal = det.sum.equals(term.sum);
                        if(!is_equal && umax) { 
                            break;
                        } 
                        if(is_equal) {
                            //check the differences of their maxes. The one with the biggest difference governs
                            //e.g. x^2*y^3 vs x^2*y^3 is unclear but this isn't the case in x*y and x^2
                            var max1, max2, idx1, idx2, l2 = det.terms.length;
                            for(var j=0; j<l2; j++) {
                                var item1 = det.terms[j], item2 = term.terms[j];
                                if(typeof max1 === 'undefined' || item1.greaterThan(max1)) {
                                    max1 = item1; idx1 = j;
                                }
                                if(typeof max2 === 'undefined' || item2.greaterThan(max2)) {
                                    max2 = item2; idx2 = j;
                                }
                            }
                            //check their differences
                            var d1 = max1.subtract(term.terms[idx1]),
                                d2 = max2.subtract(det.terms[idx2]);
                            if(d2 > d1) {
                                umax = [max2, idx2, term];
                                break;
                            }
                            if(d1 > d2) {
                                umax = [max1, idx1, det];
                                break;
                            }
                        }
                        else { 
                            //check if it's a suitable pick to determine the order
                            umax = get_unique_max(term); 
                            //if(umax) return umax;
                            if(umax) break;
                        }
                        umax = get_unique_max(term); //calculate a new unique max
                    }

                    //if still no umax then any will do since we have a tie
                    if(!umax) return get_unique_max(s[0], true);
                    var e, idx;
                    for(var i=0; i<s2.length; i++) {
                        var cterm = s2[i].terms;
                        //confirm that this is a good match for the denominator
                        idx = umax[1];
                        if(idx === cterm.length - 1) return ;
                        e = cterm[idx]; 
                        if(!e.equals(0)) break;
                    }
                    if(e.equals(0)) return get_det(s, ++lookat); //look at the next term

                    return umax;
                }
function(s, lookat) { 
                    lookat = lookat || 0;
                    var det = s[lookat], l = s.length; 
                    if(!det) return;
                    //eliminate the first term if it doesn't apply
                    var umax = get_unique_max(det); 
                    for(var i=lookat+1; i<l; i++) {
                        var term = s[i],   
                            is_equal = det.sum.equals(term.sum);
                        if(!is_equal && umax) { 
                            break;
                        } 
                        if(is_equal) {
                            //check the differences of their maxes. The one with the biggest difference governs
                            //e.g. x^2*y^3 vs x^2*y^3 is unclear but this isn't the case in x*y and x^2
                            var max1, max2, idx1, idx2, l2 = det.terms.length;
                            for(var j=0; j<l2; j++) {
                                var item1 = det.terms[j], item2 = term.terms[j];
                                if(typeof max1 === 'undefined' || item1.greaterThan(max1)) {
                                    max1 = item1; idx1 = j;
                                }
                                if(typeof max2 === 'undefined' || item2.greaterThan(max2)) {
                                    max2 = item2; idx2 = j;
                                }
                            }
                            //check their differences
                            var d1 = max1.subtract(term.terms[idx1]),
                                d2 = max2.subtract(det.terms[idx2]);
                            if(d2 > d1) {
                                umax = [max2, idx2, term];
                                break;
                            }
                            if(d1 > d2) {
                                umax = [max1, idx1, det];
                                break;
                            }
                        }
                        else { 
                            //check if it's a suitable pick to determine the order
                            umax = get_unique_max(term); 
                            //if(umax) return umax;
                            if(umax) break;
                        }
                        umax = get_unique_max(term); //calculate a new unique max
                    }

                    //if still no umax then any will do since we have a tie
                    if(!umax) return get_unique_max(s[0], true);
                    var e, idx;
                    for(var i=0; i<s2.length; i++) {
                        var cterm = s2[i].terms;
                        //confirm that this is a good match for the denominator
                        idx = umax[1];
                        if(idx === cterm.length - 1) return ;
                        e = cterm[idx]; 
                        if(!e.equals(0)) break;
                    }
                    if(e.equals(0)) return get_det(s, ++lookat); //look at the next term

                    return umax;
                }
function ( s , lookat ) { lookat = lookat || 0 ; var det = s [ lookat ] , l = s . length ; if ( ! det ) return ; //eliminate the first term if it doesn't apply
 var umax = get_unique_max ( det ) ; for ( var i = lookat + 1 ; i < l ; i ++ ) { var term = s [ i ] , is_equal = det . sum . equals ( term . sum ) ; if ( ! is_equal && umax ) { break ; } if ( is_equal ) { //check the differences of their maxes. The one with the biggest difference governs
 //e.g. x^2*y^3 vs x^2*y^3 is unclear but this isn't the case in x*y and x^2
 var max1 , max2 , idx1 , idx2 , l2 = det . terms . length ; for ( var j = 0 ; j < l2 ; j ++ ) { var item1 = det . terms [ j ] , item2 = term . terms [ j ] ; if ( typeof max1 === 'undefined' || item1 . greaterThan ( max1 ) ) { max1 = item1 ; idx1 = j ; } if ( typeof max2 === 'undefined' || item2 . greaterThan ( max2 ) ) { max2 = item2 ; idx2 = j ; } } //check their differences
 var d1 = max1 . subtract ( term . terms [ idx1 ] ) , d2 = max2 . subtract ( det . terms [ idx2 ] ) ; if ( d2 > d1 ) { umax = [ max2 , idx2 , term ] ; break ; } if ( d1 > d2 ) { umax = [ max1 , idx1 , det ] ; break ; } } else { //check if it's a suitable pick to determine the order
 umax = get_unique_max ( term ) ; //if(umax) return umax;
 if ( umax ) break ; } umax = get_unique_max ( term ) ; //calculate a new unique max
 } //if still no umax then any will do since we have a tie
 if ( ! umax ) return get_unique_max ( s [ 0 ] , true ) ; var e , idx ; for ( var i = 0 ; i < s2 . length ; i ++ ) { var cterm = s2 [ i ] . terms ; //confirm that this is a good match for the denominator
 idx = umax [ 1 ] ; if ( idx === cterm . length - 1 ) return ; e = cterm [ idx ] ; if ( ! e . equals ( 0 ) ) break ; } if ( e . equals ( 0 ) ) return get_det ( s , ++ lookat ) ; //look at the next term
 return umax ; }
tries to find an LT in the dividend that will satisfy division
tries to find an LT in the dividend that will satisfy division