Algebra.js
function() { 
            var a = this.clone(),
                i = 1,
                b = a.clone().diff(),
                c = a.clone().gcd(b),
                w = a.divide(c)[0];
            var output = Polynomial.fromArray([new Frac(1)], a.variable);
            while(!c.equalsNumber(1)) { 
                var y = w.gcd(c); 
                var z = w.divide(y)[0];
                //one of the factors may have shown up since it's square but smaller than the 
                //one where finding
                if(!z.equalsNumber(1) && i>1) {
                    var t = z.clone();
                    for(var j=1; j<i; j++)
                        t.multiply(z.clone());
                    z = t;
                }
                output = output.multiply(z); 
                i++;
                w = y;
                c = c.divide(y)[0];
            }
            return [output, w, i];
        }
function() { 
            var a = this.clone(),
                i = 1,
                b = a.clone().diff(),
                c = a.clone().gcd(b),
                w = a.divide(c)[0];
            var output = Polynomial.fromArray([new Frac(1)], a.variable);
            while(!c.equalsNumber(1)) { 
                var y = w.gcd(c); 
                var z = w.divide(y)[0];
                //one of the factors may have shown up since it's square but smaller than the 
                //one where finding
                if(!z.equalsNumber(1) && i>1) {
                    var t = z.clone();
                    for(var j=1; j<i; j++)
                        t.multiply(z.clone());
                    z = t;
                }
                output = output.multiply(z); 
                i++;
                w = y;
                c = c.divide(y)[0];
            }
            return [output, w, i];
        }
function ( ) { var a = this . clone ( ) , i = 1 , b = a . clone ( ) . diff ( ) , c = a . clone ( ) . gcd ( b ) , w = a . divide ( c ) [ 0 ] ; var output = Polynomial . fromArray ( [ new Frac ( 1 ) ] , a . variable ) ; while ( ! c . equalsNumber ( 1 ) ) { var y = w . gcd ( c ) ; var z = w . divide ( y ) [ 0 ] ; //one of the factors may have shown up since it's square but smaller than the 
 //one where finding
 if ( ! z . equalsNumber ( 1 ) && i > 1 ) { var t = z . clone ( ) ; for ( var j = 1 ; j < i ; j ++ ) t . multiply ( z . clone ( ) ) ; z = t ; } output = output . multiply ( z ) ; i ++ ; w = y ; c = c . divide ( y ) [ 0 ] ; } return [ output , w , i ] ; }
Makes polynomial square free
@returns {Array}
Makes polynomial square free