1.10. Namespace Polynomial

class Polynomial

Khiva Polynomial class containing a number of polynomial methods.

Public Static Functions

static KhivaArray Khiva.Polynomial.PolyFit(KhivaArray x, KhivaArray y, int deg)

Least squares polynomial fit. Fit a polynomial \(p(x) = p[0] * x^{deg} + ... + p[deg]\) of degree \(deg\) to points \((x, y)\). Returns a vector of coefficients \(p\) that minimises the squared error.

Return
Polynomial coefficients, highest power first.
Parameters
  • x: x-coordinates of the M sample points \((x[i], y[i])\).
  • y: y-coordinates of the sample points.
  • deg: Degree of the fitting polynomial.

static KhivaArray Khiva.Polynomial.Roots(KhivaArray p)

Calculates the roots of a polynomial with coefficients given in \(p\). The values in the rank-1 array \(p\) are coefficients of a polynomial.If the length of \(p\) is \(n+1\) then the polynomial is described by:

\[ p[0] * x ^ n + p[1] * x ^{n-1} + ... + p[n - 1] * x + p[n] \]

Return
KhivaArray containing the roots of the polynomial.
Parameters