Skip to main content

Polynomial

class Polynomial 

A polynomial in the form ax^3 + bx^2 + cx + d up to a cubic polynomial.

Source code liberally taken from: https://github.com/FreyaHolmer/Mathfs/blob/master/Runtime/Curves/Polynomial.cs

Constructors

constructor

public new Polynomialc0: number: Polynomial
public new Polynomialc0: numberc1: number: Polynomial
public new Polynomialc0: numberc1: numberc2: number: Polynomial
public new Polynomialc0: numberc1: numberc2: numberc3: number: Polynomial

Parameters

  • c0: number

    The constant coefficient

Properties

c0

readonly public c0: number

c1

readonly public c1: number

c2

readonly public c2: number

c3

readonly public c3: number

Accessors

degree

public get degree(): number

The degree of the polynomial

Methods

differentiate

public differentiaten: number = 1: Polynomial

Return the nth derivative of the polynomial.

Parameters

  • n: number = 1

    The number of times to differentiate the polynomial.


eval

public evalt: number: number
public evalt: numberderivative: number: number

Evaluate the polynomial at the given value t.

Parameters

  • t: number

    The value to sample at


localExtrema

public localExtrema(): number[]

Calculate the local extrema of the polynomial.


localExtrema01

public localExtrema01(): number[]

Calculate the local extrema of the polynomial in the unit interval.


outputRange01

public outputRange01(): number[]

Return the output value range within the unit interval.


roots

public roots(): number[]

Calculate the roots (values where this polynomial = 0).

Depending on the degree of the polynomial, returns between 0 and 3 results.


split

public splitu: number: PolynomialPolynomial

Split the polynomial into two polynomials of the same overall shape.

Parameters

  • u: number

    The point at which to split the polynomial.


constant

static public constantc0: number: Polynomial

Constructs a constant polynomial

Parameters

  • c0: number

    The constant coefficient


cubic

static public cubicc0: numberc1: numberc2: numberc3: number: Polynomial

Constructs a cubic polynomial

Parameters

  • c0: number

    The constant coefficient

  • c1: number

    The linear coefficient

  • c2: number

    The quadratic coefficient

  • c3: number

    The cubic coefficient


linear

static public linearc0: numberc1: number: Polynomial

Constructs a linear polynomial

Parameters

  • c0: number

    The constant coefficient

  • c1: number

    The linear coefficient


quadratic

static public quadraticc0: numberc1: numberc2: number: Polynomial

Constructs a quadratic polynomial

Parameters

  • c0: number

    The constant coefficient

  • c1: number

    The linear coefficient

  • c2: number

    The quadratic coefficient