Function reference · Polynomials

coeffs

Returns the coefficients of a polynomial, from the constant term up.

Missing powers give 0.

Notation

coeffs(expression[, variable])

Write it in an expression: nerdamer('coeffs(x^2+2*x+1,x)'), or in the Playground.

nerdamer.coeffs

nerdamer.coeffs(expression: ExpressionInput, variable?: ExpressionInput): Vector

A method on the default import. Arguments can be strings, as in Notation.

import { coeffs }

import { coeffs } from 'nerdamer/algebra';
coeffs(expression: ExpressionInput, variable?: ExpressionInput): Vector

Import only this function, from nerdamer/algebra.

Parameters

expression
Polynomial expression whose coefficients should be collected.
variable
Optional polynomial variable. Defaults to the first variable in the expression.

Examples

A quadratic.

coeffs(x^2+2*x+1,x)
// → [1, 2, 1]
Open in Playground

Symbolic coefficients; the missing x term gives 0.

coeffs(a*x^2+b,x)
// → [b, 0, a]
Open in Playground

← Back to Function reference