# Modes (Basis functions)¶

modepy.modes provides orthonormal bases and their derivatives on unit simplices.

## Jacobi polynomials¶

modepy.jacobi(alpha, beta, n, x)

Evaluate Jacobi polynomials of type $$(\alpha, \beta)$$ with $$\alpha, \beta > -1$$ and $$\alpha+\beta \ne -1$$ at a vector of points x for order n. The points x must lie on the interval $$[-1,1]$$.

Returns

a vector of $$P^{(\alpha, \beta)}_n$$ evaluated at all x.

The polynomials are normalized to be orthonormal with respect to the Jacobi weight $$(1-x)^\alpha(1+x)^\beta$$.

Observe that choosing $$\alpha=\beta=0$$ will yield the Legendre polynomials.

modepy.grad_jacobi(alpha, beta, n, x)

Evaluate the derivative of jacobi(), with the same meanings and restrictions for all arguments.

## Dimension-independent basis getters for simplices¶

modepy.simplex_onb_with_mode_ids(dims, n)

Return a list of orthonormal basis functions in dimension dims of maximal total degree n.

Returns

a tuple (mode_ids, basis), where basis is a class:tuple of functions, each of which accepts arrays of shape (dims, npts) and return the function values as an array of size npts. ‘Scalar’ evaluation, by passing just one vector of length dims, is also supported. mode_ids is a tuple of the same length as basis, where each entry is a tuple of integers describing the order of the mode along the coordinate axes.

See the following publications:

• Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

• Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

• Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

modepy.simplex_onb(dims, n)

Return a list of orthonormal basis functions in dimension dims of maximal total degree n.

Returns

a class:tuple of functions, each of which accepts arrays of shape (dims, npts) and return the function values as an array of size npts. ‘Scalar’ evaluation, by passing just one vector of length dims, is also supported.

See the following publications:

• Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

• Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

• Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

Changed in version 2013.2: Made return value a tuple, to make bases hashable.

modepy.grad_simplex_onb(dims, n)

Return the gradients of the functions returned by simplex_onb().

Returns

a tuple of functions, each of which accepts arrays of shape (dims, npts) and returns a tuple of length dims containing the derivatives along each axis as an array of size npts. ‘Scalar’ evaluation, by passing just one vector of length dims, is also supported.

See the following publications:

• Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

• Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

• Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

Changed in version 2013.2: Made return value a tuple, to make bases hashable.

modepy.simplex_monomial_basis_with_mode_ids(dims, n)

Return a list of monomial basis functions in dimension dims of maximal total degree n.

Returns

a tuple (mode_ids, basis), where basis is a class:tuple of functions, each of which accepts arrays of shape (dims, npts) and return the function values as an array of size npts. ‘Scalar’ evaluation, by passing just one vector of length dims, is also supported. mode_ids is a tuple of the same length as basis, where each entry is a tuple of integers describing the order of the mode along the coordinate axes.

New in version 2018.1.

modepy.simplex_monomial_basis(dims, n)

Return a list of monomial basis functions in dimension dims of maximal total degree n.

Returns

a class:tuple of functions, each of which accepts arrays of shape (dims, npts) and return the function values as an array of size npts. ‘Scalar’ evaluation, by passing just one vector of length dims, is also supported.

New in version 2016.1.

modepy.grad_simplex_monomial_basis(dims, n)

Return the gradients of the functions returned by simplex_monomial_basis().

Returns

a tuple of functions, each of which accepts arrays of shape (dims, npts) and returns a tuple of length dims containing the derivatives along each axis as an array of size npts. ‘Scalar’ evaluation, by passing just one vector of length dims, is also supported.

New in version 2016.1.

## Dimension-independent basis getters for tensor-product bases¶

modepy.tensor_product_basis(dims, basis_1d)

Adapt any iterable basis_1d of 1D basis functions into a dims-dimensional tensor product basis.

Returns

a tuple of callables representing a dims-dimensional basis

New in version 2017.1.

## Dimension-specific functions¶

modepy.modes.pkdo_2d(order, rs)

Evaluate a 2D orthonormal (with weight 1) polynomial on the unit simplex.

Parameters
• order – A tuple (i, j) representing the order of the polynomial.

• rsrs, rs are arrays of $$(r,s)$$ coordinates. (See Coordinates on the triangle)

Returns

a vector of values of the same length as the rs arrays.

See the following publications:

• Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

• Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

• Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

modepy.modes.grad_pkdo_2d(order, rs)

Evaluate the derivatives of pkdo_2d().

Parameters
• order – A tuple (i, j) representing the order of the polynomial.

• rsrs, rs are arrays of $$(r,s)$$ coordinates. (See Coordinates on the triangle)

Returns

a tuple of vectors (dphi_dr, dphi_ds), each of the same length as the rs arrays.

See the following publications:

• Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

• Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

• Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

modepy.modes.pkdo_3d(order, rst)

Evaluate a 2D orthonormal (with weight 1) polynomial on the unit simplex.

Parameters
• order – A tuple (i, j, k) representing the order of the polynomial.

• rsrst, rst, rst are arrays of $$(r,s,t)$$ coordinates. (See Coordinates on the tetrahedron)

Returns

a vector of values of the same length as the rst arrays.

See the following publications:

• Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

• Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

• Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

modepy.modes.grad_pkdo_3d(order, rst)

Evaluate the derivatives of pkdo_3d().

Parameters
• order – A tuple (i, j, k) representing the order of the polynomial.

• rsrs, rs, rs are arrays of $$(r,s,t)$$ coordinates. (See Coordinates on the tetrahedron)

Returns

a tuple of vectors (dphi_dr, dphi_ds, dphi_dt), each of the same length as the rst arrays.

See the following publications:

• Proriol, Joseph. “Sur une famille de polynomes á deux variables orthogonaux dans un triangle.” CR Acad. Sci. Paris 245 (1957): 2459-2461.

• Koornwinder, T. “Two-variable analogues of the classical orthogonal polynomials.” Theory and Applications of Special Functions. 1975, pp. 435-495.

• Dubiner, Moshe. “Spectral Methods on Triangles and Other Domains.” Journal of Scientific Computing 6, no. 4 (December 1, 1991): 345–390. http://dx.doi.org/10.1007/BF01060030

## Monomials¶

modepy.modes.monomial(order, rst)

Evaluate the monomial of order order at the points rst.

Parameters
• order – A tuple (i, j,…) representing the order of the polynomial.

• rstrst, rst are arrays of $$(r,s,...)$$ coordinates. (See Coordinates on the triangle)

modepy.modes.grad_monomial(order, rst)

Evaluate the derivative of the monomial of order order at the points rst.

Parameters
• order – A tuple (i, j,…) representing the order of the polynomial.

• rstrst, rst are arrays of $$(r,s,...)$$ coordinates. (See Coordinates on the triangle)

Returns

a tuple of vectors (dphi_dr, dphi_ds, dphi_dt), each of the same length as the rst arrays.

New in version 2016.1.