Skip to content
Orthogonal polynomials in all shapes and sizes.
Python Makefile
Branch: master
Clone or download
Latest commit 9175018 Jul 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci circleci: remove gmsh dependency Jul 2, 2019
orthopy
test apply isort Jul 12, 2019
.bandit add bandit config Feb 14, 2018
.flake8 add flake8 config Jun 4, 2018
.gitignore more gitignore Jun 4, 2018
LICENSE.txt update year Jul 2, 2019
Makefile version bump Jul 12, 2019
README.md readme update Jul 12, 2019
codecov.yml add codecov.yml Aug 20, 2017
setup.py add cplot dependency Jul 12, 2019
test_requirements.txt remove quadpy from test requirements Dec 16, 2017

README.md

orthopy

All about orthogonal polynomials.

CircleCI codecov Code style: black orthogonal PyPi Version DOI GitHub stars

orthopy provides various orthogonal polynomial classes for lines, triangles, quadrilaterals, disks, spheres, hexahedra, and n-cubes. All computations are done using numerically stable recurrence schemes. Furthermore, all functions are fully vectorized and can return results in exact arithmetic.

Note: In previous versions, orthopy contained tools for working with Gauss quadrature rules as well. Those have moved over to quadpy.

Line segment [-1, +1] with weight function (1-x)α (1-x)β

Jacobi, Gegenbauer (α=β), Chebyshev 1 (α=β=-1/2), Chebyshev 2 (α=β=1/2), Legendre (α=β=0) polynomials.

vals = orthopy.line_segment.tree_jacobi(x, 4, alpha, beta, 'normal', symbolic=False)

Recurrence coefficients can be explicitly retrieved by

p0, a, b, c = orthopy.line_segment.recurrence_coefficients.jacobi(n, a, b, 'monic')

Possible choices for the standardization are 'monic', 'p(1)=(n+alpha over n)', and 'normal'.

Associated Legendre polynomials

vals = orthopy.line_segment.tree_alp(
    x, 4, phi=None, standardization='natural', with_condon_shortley_phase=True,
    symbolic=False
    )

1D half-space with weight function xα exp(-r)

(Generalized) Laguerre polynomials.

vals = orthopy.e1r.tree(x, 4, alpha=0, standardization='normal', symbolic=False)

1D space with weight function exp(-r2)

Hermite polynomials.

vals = orthopy.e1r2.tree(x, 4, 'normal', symbolic=False)

All polynomials are normalized over the measure.

Triangle

n=1, k=0 n=2, k=1 n=3, k=1
vals = orthopy.triangle.tree(x, 4, 'normal', symbolic=False)

Available standardizations are

  • 'normal' (normalized polynomials, i.e., the integral of the squared function equals 1) and
  • '1' where the polynomial is 1 in at least one corner of the triangle.

Quadrilateral

n=1, k=0 n=2, k=1 n=3, k=1
vals = orthopy.quadrilateral.tree(x, 4, symbolic=False)

All polynomials are normalized on the quadrilateral.

Disk

n=1, k=0 n=2, k=1 n=4, k=3
vals = orthopy.disk.tree(x, 4, symbolic=False)

All polynomials are normalized on the unit disk.

2D space with weight function exp(-r2)

n=1, k=0 n=2, k=1 n=3, k=1
vals = orthopy.e2r2.tree(x, 4, symbolic=False)

All polynomials are normalized over the measure.

Sphere

n=1, k=0 n=2, k=1 n=5, k=3

Complex-valued spherical harmonics, plotted with cplot coloring.

vals = orthopy.sphere.tree_sph(
    polar, azimuthal, n, standardization='quantum mechanic', symbolic=False
    )

Hexahedron

n=1, k=0 n=2, k=1 n=5, k=5
vals = orthopy.hexahedron.tree(x, 3, symbolic=False)

All polynomials are normalized on the hexahedron.

n-Cube

vals = orthopy.ncube.tree(x, 6, symbolic=False)

All polynomials are normalized on the n-dimensional cube. The dimensionality is determined by X.shape[0].

nD space with weight function exp(-r2)

vals = orthopy.enr2.tree(x, 4, symbolic=False)

All polynomials are normalized over the measure. The dimensionality is determined by X.shape[0].

Other tools

  • Clenshaw algorithm for computing the weighted sum of orthogonal polynomials:
    vals = orthopy.line_segment.clenshaw(a, alpha, beta, t)

Symbolic and numerical computation

By default, all operations are performed numerically. However, if symbolic=True is specified, all computations are performed symbolically. This can be used, for example, to get explicit representations of the polynomials:

import numpy
import orthopy
import sympy

b0, b1, b2 = sympy.Symbol('b0'), sympy.Symbol('b1'), sympy.Symbol('b2')

tree = orthopy.triangle.tree(numpy.array([b0, b1, b2]), 3, 'normal', symbolic=True)

print(sympy.expand(tree[3][1]))
42*sqrt(6)*b0*b2**2 - 24*sqrt(6)*b0*b2 + 2*sqrt(6)*b0 - 42*sqrt(6)*b1*b2**2
+ 24*sqrt(6)*b1*b2 - 2*sqrt(6)*b1

Installation

orthopy is available from the Python Package Index, so with

pip install -U orthopy

you can install/upgrade.

Testing

To run the tests, simply check out this repository and run

pytest

License

orthopy is published under the MIT license.

You can’t perform that action at this time.