Polynomial Class

Represents a polynomial.

Definition

Namespace: Numerics.NET.Curves
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4
C#
[SerializableAttribute]
public class Polynomial : PolynomialBase, IFormattable, 
	IEquatable<Polynomial>
Inheritance
Object  →  Curve  →  LinearCombination  →  PolynomialBase  →  Polynomial
Implements
IEquatable<Polynomial>, IFormattable

Remarks

Use the Polynomial class to represent ordinary polynomials. A polynomial is an algebraic expression consisting of one or more summed terms, each term consisting of a constant multiplier and a variable raised to an integral exponent. It inherits from Curve and provides specialized implementation for most methods.

The parameters of a Polynomial correspond to the coefficients of the polynomial. The coefficients can be accessed through the indexed Coefficient[Int32] property. In C#, this property is the indexer for this class.

The ValueAt(Double) method returns the value of the polynomial at a specific point. SlopeAt(Double) returns the derivative. Integral(Double, Double) evaluates the definite integral over a specified interval.

The FindRoots() method attempts to find all real roots of the polynomial. It returns a Double array. The corresponding FindComplexRoots() method attempts to find all complex roots, and returns them as an array of complex number values. The roots are sorted in order of ascending real part.

Methods for arithmetic operations on polynomials have been defined. Corresponding operator overloads are available for those languages that support them.

Constructors

Polynomial(IList<Double>) Constructs a new polynomial with the specified coefficients.
Polynomial(Int32) Constructs a new polynomial of the specified degree.
Polynomial(Double[], Boolean) Constructs a new polynomial with the specified coefficients.
Polynomial(IList<Double>, Boolean) Constructs a new polynomial with the specified coefficients.

Properties

Basis Gets the function basis for the polynomial.
(Overrides LinearCombination.Basis)
Coefficient Gets or sets the coefficient of the function with the specified index.
(Inherited from LinearCombination)
Degree Gets the degree of the polynomial.
(Inherited from PolynomialBase)
Parameters Gets the collection of parameters that determine the shape of this Curve.
(Inherited from Curve)

Methods

Add(LinearCombination) Adds another LinearCombination to this instance.
(Inherited from LinearCombination)
Add(Double, LinearCombination) Adds a multiple of another LinearCombination to this instance.
(Overrides LinearCombination.Add(Double, LinearCombination))
Add(Polynomial, Polynomial) Adds two polynomials.
Clone Constructs an exact copy of this instance.
(Inherited from Curve)
ComplexSlopeAt Evaluates the slope or first derivative of a polynomial for a complex number argument.
ComplexValueAt Evaluates the polynomial for a complex number argument.
Deflate Deflates a polynomial by dividing out a root.
Divide(Polynomial, Polynomial) Divides one Polynomial by another.
Divide(Polynomial, Polynomial, Polynomial) Divides one Polynomial by another.
Equals(Object) Overridden. Returns whether this instance is equal to a specified object.
(Overrides Object.Equals(Object))
Equals(Polynomial) Overridden. Returns whether this instance is equal to a specified polynomial.
Equals(Polynomial, Polynomial) Returns whether two Polynomial objects represent the same value.
Evaluate Evaluates a polynomial with the specified coefficients.
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
FindComplexRoots Gets the set of roots of the Polynomial.
FindRoots Gets the set of X-coordinates where the Polynomial crosses the X-axis.
(Overrides Curve.FindRoots())
FromRoots(Double[]) Constructs a new polynomial that has the specified roots.
FromRoots(ReadOnlySpan<Double>) Constructs a new polynomial that has the specified roots.
GetCurveFitter Returns a CurveFitter object that can be used to fit the curve to data.
(Inherited from LinearCombination)
GetDerivative Returns a Curve of type Polynomial that represents the derivative of this Polynomial.
(Overrides Curve.GetDerivative())
GetHashCode Overridden. Returns the hash code for this instance.
(Overrides Object.GetHashCode())
GetInterpolatingPolynomial(Double[], Double[]) Constructs the interpolating polynomial through a set of points.
GetInterpolatingPolynomial(ReadOnlySpan<Double>, ReadOnlySpan<Double>) 
GetInterpolatingPolynomial(Vector<Double>, Vector<Double>) Constructs the interpolating polynomial through a set of points.
GetTypeGets the Type of the current instance.
(Inherited from Object)
Integral Gets the definite integral of the curve between the specified X-coordinates.
(Overrides Curve.Integral(Double, Double))
LeastSquaresFit(Vector<Double>, Vector<Double>, Int32) Returns the Polynomial that is the best least squares fit through the given set of points.
LeastSquaresFit(Vector<Double>, Vector<Double>, Int32, Vector<Double>) Returns the Polynomial that is the best weighted least squares fit through the given set of points.
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Modulus Divides one Polynomial by another and returns the remainder.
Multiply Multiplies two polynomials.
OnParameterChanged Called when a coefficient of the polynomial is changed.
(Inherited from PolynomialBase)
OnParameterChanging Called before the value of a curve parameter is changed.
(Inherited from Curve)
Reduce() Reduces the degree of a polynomial so that the leading coefficient is different from zero.
(Inherited from PolynomialBase)
Reduce(Double) Reduces the degree of a polynomial so that the leading coefficient is greater than the specified tolerance.
(Inherited from PolynomialBase)
SetParameter Sets a curve parameter to the specified value.
(Inherited from Curve)
SlopeAt Evaluates the slope or first derivative of a polynomial for a real argument.
(Overrides LinearCombination.SlopeAt(Double))
Solve Finds the x value where the curve reaches the specified y value.
(Inherited from Curve)
Subtract(LinearCombination) Subtracts another LinearCombination from this instance.
(Inherited from LinearCombination)
Subtract(Polynomial, Polynomial) Subtracts two polynomials.
TangentAt Gets the tangent line to the curve at the specified X-coordinate.
(Inherited from Curve)
ToString() Returns a string representation of this instance.
(Overrides Object.ToString())
ToString(String) Returns a string representation of this instance using the specified string to format the coefficients.
ToString(String, IFormatProvider) Returns a string representation of this instance using the specified string and format provider to format the coefficients.
ValueAt Evaluates the polynomial for a real argument.
(Overrides LinearCombination.ValueAt(Double))

Operators

Addition(Polynomial, Polynomial) Adds two polynomials.
Division(Polynomial, Polynomial) Divides one Polynomial by another.
Equality(Polynomial, Polynomial) Compares two Polynomial objects for equality.
Inequality(Polynomial, Polynomial) Compares two Polynomial objects for inequality.
Modulus(Polynomial, Polynomial) Divides one Polynomial by another and returns the remainder.
Multiply(Polynomial, Polynomial) Multiplies two polynomials.
Subtraction(Polynomial, Polynomial) Subtracts two polynomials.

Fields

One Gets the polynomial with a constant value of one.
Zero Gets the polynomial with a constant value of zero.

See Also