polynomial.js
function(x, y) {

    var r = {};

    var i = degree(x);
    var j = degree(y);
    var trace = [];

    while (i >= j) {

      var tmp = r[i - j] = FIELD['div'](x[i] || 0, y[j] || 0);

      for (var k in y) {
        x[+k + i - j] = FIELD['sub'](x[+k + i - j] || 0, FIELD['mul'](y[k] || 0, tmp));
      }

      if (Polynomial['trace'] !== null) {

        var tr = {};
        for (var k in y) {
          tr[+k + i - j] = FIELD['mul'](y[k] || 0, tmp);
        }
        trace.push(new Polynomial(tr));
      }

      i = degree(x);
    }

    // Add rest
    if (Polynomial['trace'] !== null) {
      trace.push(new Polynomial(x));
      Polynomial['trace'] = trace;
    }
    return r;
  }
function(x, y) {

    var r = {};

    var i = degree(x);
    var j = degree(y);
    var trace = [];

    while (i >= j) {

      var tmp = r[i - j] = FIELD['div'](x[i] || 0, y[j] || 0);

      for (var k in y) {
        x[+k + i - j] = FIELD['sub'](x[+k + i - j] || 0, FIELD['mul'](y[k] || 0, tmp));
      }

      if (Polynomial['trace'] !== null) {

        var tr = {};
        for (var k in y) {
          tr[+k + i - j] = FIELD['mul'](y[k] || 0, tmp);
        }
        trace.push(new Polynomial(tr));
      }

      i = degree(x);
    }

    // Add rest
    if (Polynomial['trace'] !== null) {
      trace.push(new Polynomial(x));
      Polynomial['trace'] = trace;
    }
    return r;
  }
function ( x , y ) { var r = { } ; var i = degree ( x ) ; var j = degree ( y ) ; var trace = [ ] ; while ( i >= j ) { var tmp = r [ i - j ] = FIELD [ 'div' ] ( x [ i ] || 0 , y [ j ] || 0 ) ; for ( var k in y ) { x [ + k + i - j ] = FIELD [ 'sub' ] ( x [ + k + i - j ] || 0 , FIELD [ 'mul' ] ( y [ k ] || 0 , tmp ) ) ; } if ( Polynomial [ 'trace' ] !== null ) { var tr = { } ; for ( var k in y ) { tr [ + k + i - j ] = FIELD [ 'mul' ] ( y [ k ] || 0 , tmp ) ; } trace . push ( new Polynomial ( tr ) ) ; } i = degree ( x ) ; } // Add rest if ( Polynomial [ 'trace' ] !== null ) { trace . push ( new Polynomial ( x ) ) ; Polynomial [ 'trace' ] = trace ; } return r ; }
Helper function for division

@param {Object} x The numerator coefficients
@param {Object} y The denominator coefficients
@returns {Object}
Helper function for division