Skip to content

puncturedfem.Polynomial

Polynomial in two variables, represented as a list of Monomials.

Attributes:

Name Type Description
monos list[Monomial]

List of Monomials in the Polynomial.

__add__(other)

Define the addition operation self + other.

Parameters:

Name Type Description Default
other object

Object to add to self. Must be either a Polynomial or a scalar.

required

__call__(x, y)

Evaluate the Polynomial at the point (x, y).

Parameters:

Name Type Description Default
x FloatLike

x-coordinate of the point.

required
y FloatLike

y-coordinate of the point.

required

Returns:

Type Description
FloatLike

Value(s) of the Polynomial at the point(s) (x, y). If x and y are arrays, returns an array of values of the same shape.

__eq__(other)

Test equality between self and other.

Parameters:

Name Type Description Default
other object

Object to compare with self. Must be a Polynomial.

required

__iadd__(other)

Define the increment operation self += other.

Parameters:

Name Type Description Default
other object

Object to add to self. Must be either a Polynomial or a scalar.

required

__init__(coef_multidx_pairs=None)

Polynomial in two variables, represented as a list of Monomials.

Parameters:

Name Type Description Default
coef_multidx_pairs list[tuple[float, int, int]], optional

List of coefficient / multi-index pairs, by default None

None

__mul__(other)

Define the multiplication operator self * other.

Parameters:

Name Type Description Default
other object

Object to multiply with self. Must be either a Polynomial or a scalar.

required

__neg__()

Negate the Polynomial.

__pow__(exponent)

Define the exponentiation operator self ** exponent.

Parameters:

Name Type Description Default
exponent int

Nonnegative integer exponent.

required

__radd__(other)

Define the addition operator other + self.

Parameters:

Name Type Description Default
other object

Object to add to self. Must be either a Polynomial or a scalar.

required

__repr__()

Get a string representation of the Polynomial.

Returns:

Type Description
str

String representation of the Polynomial.

__rmul__(other)

Define the multiplication operator other * self.

Parameters:

Name Type Description Default
other object

Object to multiply with self. Must be either a Polynomial or a scalar.

required

__rsub__(other)

Define the subtraction operator other - self.

Parameters:

Name Type Description Default
other object

Object to subtract self from. Must be either a Polynomial or a scalar.

required

__str__()

Get a string representation of the Polynomial.

Returns:

Type Description
str

String representation of the Polynomial.

__sub__(other)

Define the subtraction operator self - other.

Parameters:

Name Type Description Default
other object

Object to subtract from self. Must be either a Polynomial or a scalar.

required

__truediv__(other)

Divide the Polynomial by a scalar.

Parameters:

Name Type Description Default
other object

Scalar to divide the Polynomial by.

required

add_monomial(m)

Add a Monomial to the Polynomial.

Parameters:

Name Type Description Default
m Monomial

Monomial to add to the Polynomial.

required

add_monomial_with_idx(coef, idx)

Add a Monomial with a given lexicographical index idx.

Parameters:

Name Type Description Default
coef float

Coefficient of the Monomial.

required
idx int

Lexicographical index of the Monomial.

required

See Also

MultiIndex

add_monomials(monos=None)

Add a list of Monomials to the Polynomial.

Parameters:

Name Type Description Default
monos list[Monomial], optional

List of Monomials to add to the Polynomial, by default None

None

add_monomials_with_idxs(coef_list, idx_list)

Add list of Monomials with given lexicographical indices.

Parameters:

Name Type Description Default
coef_list list[float]

List of coefficients of the Monomials.

required
idx_list list[int]

List of lexicographical indices of the Monomials.

required

Raises:

Type Description
PolynomialError

If the number of coefficients and multi-indices are not equal.

See Also

MultiIndex

anti_laplacian()

Polynomial anti-Laplacian of the Polynomial.

Returns:

Type Description
Polynomial

Polynomial P such that Delta P = self.

compose(q1, q2)

Compose the Polynomial with two other Polynomials.

Parameters:

Name Type Description Default
q1 Polynomial

Polynomial in x and y.

required
q2 Polynomial

Polynomial in x and y.

required

Returns:

Type Description
Polynomial

Composed Polynomial new(x,y) = self(q1(x,y), q2(x,y)).

consolidate()

Consolidate the coefficients of repeated indices.

copy()

Get a copy of the Polynomial.

Returns:

Type Description
Polynomial

A copy of the Polynomial.

get_weighted_normal_derivative(K)

Compute the weighted normal derivative of the Polynomial.

Parameters:

Name Type Description Default
K MeshCell

MeshCell on whose boundary to compute the normal derivative.

required

Returns:

Type Description
np.ndarray

Values of the weighted normal derivative of the Polynomial.

get_weighted_tangential_derivative(K)

Compute the weighted normal derivative of the Polynomial.

Parameters:

Name Type Description Default
K MeshCell

MeshCell on whose boundary to compute the tangential derivative.

required

Returns:

Type Description
np.ndarray

Values of the weighted tangential derivative of the Polynomial.

grad()

Gradient of the Polynomial.

Returns:

Type Description
tuple[Polynomial, Polynomial]

Pair of the partial derivatives of the Polynomial with respect to x and y.

is_zero()

Is True if the Polynomial is zero.

Returns:

Type Description
bool

True if the Polynomial is zero.

laplacian()

Laplacian of the Polynomial.

Returns:

Type Description
Polynomial

Laplacian of the Polynomial: Delta f = f_{xx} + f_{yy}.

partial_deriv(var)

Partial derivative of the Polynomial with respect to the variable var.

Parameters:

Name Type Description Default
var str

Variable with respect to which the derivative is taken. Must be either 'x' or 'y'.

required

Returns:

Type Description
Polynomial

Partial derivative of the Polynomial with respect to the variable var.

pow(exponent)

Raise the Polynomial to a nonnegative integer power.

Parameters:

Name Type Description Default
exponent int

Nonnegative integer exponent.

required

Returns:

Type Description
Polynomial

Polynomial raised to the exponent.

remove_zeros()

Remove terms with zero coefficients.

set(coef_multidx_pairs=None)

Set the Polynomial to the list of coefficient / multi-index pairs.

Parameters:

Name Type Description Default
coef_multidx_pairs list[tuple[float, int, int]], optional

List of coefficient / multi-index pairs, by default None

None

set_to_zero()

Set the Polynomial to zero.

Notes

This is done by removing all Monomials from the Polynomial.

sort()

Sort the Monomials according to multi-index id.

Notes

Using Insertion Sort algorithm since Monomial list is assumed be be short.