lmlib.polynomial#

Package Abstract :: This module provides a calculus for uni- and multivariate polynomials using the vector exponent notation [Wildhaber2019], Chapter 6. This calculus simplifies to use polynomials in (squared error) cost functions, e.g., as localized signal models.

Polynomial Classes#

Poly(coef, expo)

Univariate polyonimial in vector exponent notation: \(\alpha^\mathsf{T} x^q\)

MPoly(coefs, expos)

Multivariate polynomials \({\tilde{\alpha}}^\mathsf{T} (x^q \otimes y^r)\), or with factorized coefficient vector \((\alpha \otimes \beta )^\mathsf{T} (x^q \otimes y^r)\).

Polynomial Operators#

Operators for Univariate Polynomials#

Operators handling univariate polynomials. Return parameters are highlighted in \(\color{blue}{blue}\).

Sum of Polynomials \(\alpha^\mathsf{T} x^q + \beta^\mathsf{T} x^r\)#

poly_sum(polys)

\(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)

poly_sum_coef(polys)

\(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = \color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)

poly_sum_coef_Ls(expos)

\(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = (\color{blue}{\Lambda_1} \alpha + \dots + \color{blue}{\Lambda_N}\beta)^\mathsf{T} x^{\tilde{q}}\)

poly_sum_expo(expos)

\(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)

poly_sum_expo_Ms(expos)

\(\alpha^\mathsf{T} x^q + \dots + \beta^\mathsf{T} x^r = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{M_1} q + \dots +\color{blue}{M_N} r}\)

>>> import lmlib as lm
>>>
>>> p1 = lm.Poly([1, 3, 5], [0, 1, 2])
>>> p2 = lm.Poly([2, -1], [0, 1])
>>>
>>> p_sum = lm.poly_sum((p1, p2))
>>> print(p_sum)
[ 1.  3.  5.  2. -1.], [0. 1. 2. 0. 1.]

Product of Polynomials \(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^r\)#

poly_prod(polys)

\(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^q = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)

poly_prod_coef(polys)

\(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^r = \color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)

poly_prod_expo(expos)

\(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^r = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)

poly_prod_expo_Ms(expos)

\(\alpha^\mathsf{T} x^q \cdot \beta^\mathsf{T} x^r = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{M_1} q + \color{blue}{M_2} r}\)

>>> import lmlib as lm
>>>
>>> p1 = lm.Poly([1, 3, 5], [0, 1, 2])
>>> p2 = lm.Poly([2, -1], [0, 1])
>>>
>>> p_prod = lm.poly_prod((p1, p2))
>>> print(p_prod)
[ 2 -1  6 -3 10 -5], [0. 1. 1. 2. 2. 3.]

Square of a Polynomial \((\alpha^\mathsf{T} x^q)^2\)#

poly_square(poly)

\((\alpha^\mathsf{T} x^q)^2 = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)

poly_square_coef(poly)

\(\color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)

poly_square_expo(expo)

\(\tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)

poly_square_expo_M(expo)

\(\tilde{\alpha}^\mathsf{T} x^{\color{blue}{M} q}\)

>>> import lmlib as lm
>>>
>>> p1 = lm.Poly([1, 3, 5], [0, 1, 2])
>>>
>>> p_square = lm.poly_square(p1)
>>> print(p_square)
[ 1  3  5  3  9 15  5 15 25], [0. 1. 2. 1. 2. 3. 2. 3. 4.]

Shift of a Polynomial \(\alpha^\mathsf{T} (x+ \gamma)^q\)#

poly_shift(poly, gamma)

\(\alpha^\mathsf{T} (x+ \gamma)^q = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)

poly_shift_coef(poly, gamma)

\(\color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)

poly_shift_coef_L(expo, gamma)

\(\color{blue}{\Lambda} \alpha^\mathsf{T} x^{\tilde{q}}\)

poly_shift_expo(expo)

\(\tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)

>>> import lmlib as lm
>>>
>>> p1 = lm.Poly([1, 3, 5], [0, 1, 2])
>>> gamma = 2
>>> p_shift = lm.poly_shift(p1, gamma)
>>> print(p_shift)
[27. 23.  5.], [0 1 2]

Dilation of a Polynomial \(\alpha^\mathsf{T} (\eta x)^q\)#

poly_dilation(poly, eta)

\(\alpha^\mathsf{T} (\eta x)^q = \color{blue}{\tilde{\alpha}^\mathsf{T} x^q}\)

poly_dilation_coef(poly, eta)

\(\alpha^\mathsf{T} (\eta x)^q =\color{blue}{\tilde{\alpha}}^\mathsf{T} x^q\)

poly_dilation_coef_L(expo, eta)

\(\alpha^\mathsf{T} (\eta x)^q =\color{blue}{\Lambda} \alpha^\mathsf{T} x^{q}\)

>>> import lmlib as lm
>>>
>>> p1 = lm.Poly([1, 3, 5], [0, 1, 2])
>>> eta = -5
>>> p_dilation = lm.poly_dilation (p1, eta)
>>> print(p_dilation)
[  1 -15 125], [0 1 2]

Integral of a Polynomial \(\int (\alpha^\mathsf{T} x^q) dx\)#

poly_int(poly)

\(\int \big(\alpha^{\mathsf{T}}x^q\big) dx = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)

poly_int_coef(poly)

\(\int \big(\alpha^{\mathsf{T}}x^q\big) dx = \color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)

poly_int_coef_L(expo)

\(\int \big(\alpha^{\mathsf{T}}x^q\big) dx = \color{blue}{\Lambda} \alpha^\mathsf{T} x^{\tilde{q}}\)

poly_int_expo(expo)

\(\int \big(\alpha^{\mathsf{T}}x^q\big) dx = \tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)

>>> import lmlib as lm
>>>
>>> p1 = lm.Poly([1, 3, 5], [0, 1, 2])
>>>
>>> p_int = lm.poly_int(p1)
>>> print(p_int)
[1.         1.5        1.66666667], [1 2 3]

Derivative of a Polynomial \(\frac{d}{dx} (\alpha^\mathsf{T} x^q)\)#

poly_diff(poly)

\(\frac{d}{dx} \big(\alpha^{\mathsf{T}}x^q\big) = \color{blue}{\tilde{\alpha}^\mathsf{T} x^\tilde{q}}\)

poly_diff_coef(poly)

\(\frac{d}{dx} \big(\alpha^{\mathsf{T}}x^q\big) =\color{blue}{\tilde{\alpha}}^\mathsf{T} x^\tilde{q}\)

poly_diff_coef_L(expo)

\(\frac{d}{dx} \big(\alpha^{\mathsf{T}}x^q\big) =\color{blue}{\Lambda} \alpha^\mathsf{T} x^{\tilde{q}}\)

poly_diff_expo(expo)

\(\frac{d}{dx} \big(\alpha^{\mathsf{T}}x^q\big) =\tilde{\alpha}^\mathsf{T} x^{\color{blue}{\tilde{q}}}\)

>>> import lmlib as lm
>>>
>>> p1 = lm.Poly([1, 3, 5], [0, 1, 2])
>>>
>>> p_diff = lm.poly_diff(p1)
>>> print(p_diff)
[ 0  3 10], [0 0 1]

Operators for Multivariate Polynomials#

Operators handling multi variate polynomials. Return parameters are highlighted in \(\color{blue}{blue}\).