Back to functions

coeffs


coefficients

Get the coefficients of a polynomial. The coefficients will be placed in the index of their power. So constants are in the 0th place, x^2 would be in the 2nd place, etc. Throws an error if expression is not a polynomial. Holes will be filled with zeroes


Usage: nerdamer("coeffs(polynomial, x)")


Parameters

expression polynomial The polynomial for which the coefficients are to be found.
expression x The respective variable with which to get the coefficients

EXAMPLES:
var coeffs = nerdamer.coeffs('3*x^2+1', 'x');
console.log(coeffs.toString());
coeffs.each(function(e, i) {
   console.log('coeff #'+i+': ', nerdamer(e).add('t').toString());
});
var poly = nerdamer('a*x^2+b*x+c+x');
coeffs = nerdamer.coeffs(poly, 'x');
console.log(coeffs.toString());
coeffs = nerdamer.coeffs('a*x+b/x^2', 'x');
OUTPUT:
Back to functions