Namespaces

Types in MathNet.Numerics

Type Polynomial

Namespace MathNet.Numerics

Interfaces IFormattable, IEquatable<Polynomial>, ICloneable

A single-variable polynomial with real-valued coefficients and non-negative exponents.

Constructors

Static Functions

Methods

Properties

Fields

Public Constructors

Polynomial(IEnumerable<double> coefficients)

Create a polynomial with the provided coefficients (in ascending order, where the index matches the exponent). Example: {5, 0, 2} -> "p : x -> 5 + 0 x^1 + 2 x^2".
Parameters
IEnumerable<double> coefficients

Polynomial coefficients as enumerable

Polynomial(double coefficient)

Create a constant polynomial. Example: 3.0 -> "p : x -> 3.0"
Parameters
double coefficient

The coefficient of the "x^0" monomial.

Polynomial()

Create a zero-polynomial

Polynomial(int n)

Create a zero-polynomial with a coefficient array of the given length. An array of length N can support polynomials of a degree of at most N-1.
Parameters
int n

Length of the coefficient array

Polynomial(Double[] coefficients)

Create a polynomial with the provided coefficients (in ascending order, where the index matches the exponent). Example: {5, 0, 2} -> "p : x -> 5 + 0 x^1 + 2 x^2".
Parameters
Double[] coefficients

Polynomial coefficients as array

Public Static Functions

Polynomial Add(Polynomial a, double b)

Addition of a polynomial and a scalar.

Polynomial Add(Polynomial a, Polynomial b)

Addition of two Polynomials (point-wise).
Parameters
Polynomial a

Left Polynomial

Polynomial b

Right Polynomial

Return
Polynomial

Resulting Polynomial

Polynomial Divide(Polynomial a, double k)

Scales a polynomial by division by a scalar
Parameters
Polynomial a

Polynomial

double k

Scalar value

Return
Polynomial

Resulting Polynomial

Tuple<Polynomial, Polynomial> DivideRemainder(Polynomial a, Polynomial b)

Euclidean long division of two polynomials, returning the quotient q and remainder r of the two polynomials a and b such that a = q*b + r
Parameters
Polynomial a

Left polynomial

Polynomial b

Right polynomial

Return
Tuple<Polynomial, Polynomial>

A tuple holding quotient in first and remainder in second

Complex Evaluate(Complex z, Complex[] coefficients)

Evaluate a polynomial at point x. Coefficients are ordered ascending by power with power k at index k. Example: coefficients [3,-1,2] represent y=2x^2-x+3.
Parameters
Complex z

The location where to evaluate the polynomial at.

Complex[] coefficients

The coefficients of the polynomial, coefficient for power k at index k.

Complex Evaluate(Complex z, Double[] coefficients)

Evaluate a polynomial at point x. Coefficients are ordered ascending by power with power k at index k. Example: coefficients [3,-1,2] represent y=2x^2-x+3.
Parameters
Complex z

The location where to evaluate the polynomial at.

Double[] coefficients

The coefficients of the polynomial, coefficient for power k at index k.

double Evaluate(double z, Double[] coefficients)

Evaluate a polynomial at point x. Coefficients are ordered ascending by power with power k at index k. Example: coefficients [3,-1,2] represent y=2x^2-x+3.
Parameters
double z

The location where to evaluate the polynomial at.

Double[] coefficients

The coefficients of the polynomial, coefficient for power k at index k.

Polynomial Fit(Double[] x, Double[] y, int order, DirectRegressionMethod method)

Least-Squares fitting the points (x,y) to a k-order polynomial y : x -> p0 + p1*x + p2*x^2 +... + pk*x^k

Polynomial Multiply(Polynomial a, double k)

Scales a polynomial by a scalar
Parameters
Polynomial a

Polynomial

double k

Scalar value

Return
Polynomial

Resulting Polynomial

Polynomial Multiply(Polynomial a, Polynomial b)

Multiplies a polynomial by a polynomial (convolution)
Parameters
Polynomial a

Left polynomial

Polynomial b

Right polynomial

Return
Polynomial

Resulting Polynomial

Polynomial Negate(Polynomial a)

Negation of a polynomial.

Polynomial PointwiseDivide(Polynomial a, Polynomial b)

Point-wise division of two Polynomials
Parameters
Polynomial a

Left Polynomial

Polynomial b

Right Polynomial

Return
Polynomial

Resulting Polynomial

Polynomial PointwiseMultiply(Polynomial a, Polynomial b)

Point-wise multiplication of two Polynomials
Parameters
Polynomial a

Left Polynomial

Polynomial b

Right Polynomial

Return
Polynomial

Resulting Polynomial

Polynomial Subtract(double b, Polynomial a)

Addition of a polynomial from a scalar.

Polynomial Subtract(Polynomial a, double b)

Addition of a scalar from a polynomial.

Polynomial Subtract(Polynomial a, Polynomial b)

Subtraction of two Polynomials (point-wise).
Parameters
Polynomial a

Left Polynomial

Polynomial b

Right Polynomial

Return
Polynomial

Resulting Polynomial

Public Methods

Polynomial Clone()

Polynomial Differentiate()

Tuple<Polynomial, Polynomial> DivideRemainder(Polynomial b)

Division of two polynomials returning the quotient-with-remainder of the two polynomials given
Parameters
Polynomial b

Right polynomial

Return
Tuple<Polynomial, Polynomial>

A tuple holding quotient in first and remainder in second

DenseMatrix EigenvalueMatrix()

Get the eigenvalue matrix A of this polynomial such that eig(A) = roots of this polynomial.
Return
DenseMatrix

Eigenvalue matrix A

bool Equals(Polynomial other)

bool Equals(object obj)

double Evaluate(double z)

Evaluate a polynomial at point x.
Parameters
double z

The location where to evaluate the polynomial at.

Complex Evaluate(Complex z)

Evaluate a polynomial at point x.
Parameters
Complex z

The location where to evaluate the polynomial at.

IEnumerable<double> Evaluate(IEnumerable<double> z)

Evaluate a polynomial at points z.
Parameters
IEnumerable<double> z

The locations where to evaluate the polynomial at.

int GetHashCode()

Type GetType()

Polynomial Integrate()

Complex[] Roots()

Calculates the complex roots of the Polynomial by eigenvalue decomposition
Return
Complex[]

a vector of complex numbers with the roots

string ToString(IFormatProvider formatProvider)

Format the polynomial in ascending order, e.g. "4.3 + 2.0x^2 - x^3".

string ToString()

Format the polynomial in ascending order, e.g. "4.3 + 2.0x^2 - x^3".

string ToString(string format, IFormatProvider formatProvider)

Format the polynomial in ascending order, e.g. "4.3 + 2.0x^2 - x^3".

string ToString(string format)

Format the polynomial in ascending order, e.g. "4.3 + 2.0x^2 - x^3".

string ToStringDescending(string format, IFormatProvider formatProvider)

Format the polynomial in descending order, e.g. "x^3 + 2.0x^2 - 4.3".

string ToStringDescending(IFormatProvider formatProvider)

Format the polynomial in descending order, e.g. "x^3 + 2.0x^2 - 4.3".

string ToStringDescending(string format)

Format the polynomial in descending order, e.g. "x^3 + 2.0x^2 - 4.3".

string ToStringDescending()

Format the polynomial in descending order, e.g. "x^3 + 2.0x^2 - 4.3".

Public Properties

Double[] Coefficients get; set;

The coefficients of the polynomial in a

int Degree get;

Degree of the polynomial, i.e. the largest monomial exponent. For example, the degree of y=x^2+x^5 is 5, for y=3 it is 0. The null-polynomial returns degree -1 because the correct degree, negative infinity, cannot be represented by integers.

Polynomial Zero get;

Public fields

string VariableName

Only needed for the ToString method
return string