Skip to content

# nschloe/orthopy

Orthogonal polynomials in all shapes and sizes.
Python Makefile
Latest commit 9175018 Jul 12, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information. .circleci Jul 2, 2019 orthopy test Jul 12, 2019 .bandit Feb 14, 2018 .flake8 Jun 4, 2018 .gitignore Jun 4, 2018 LICENSE.txt Jul 2, 2019 Makefile Jul 12, 2019 README.md Jul 12, 2019 codecov.yml Aug 20, 2017 setup.py Jul 12, 2019 test_requirements.txt Dec 16, 2017

### README.md

All about orthogonal polynomials.

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

`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

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

All polynomials are normalized on the quadrilateral.

### Disk

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

All polynomials are normalized on the unit disk.

### 2D space with weight function exp(-r2)

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

All polynomials are normalized over the measure.

### Sphere

Complex-valued spherical harmonics, plotted with cplot coloring.

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

### Hexahedron

`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`.

### 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`.

### 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))```
``````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.