Join the official 2019 Python Developers Survey

Tools for orthogonal polynomials, Gaussian quadrature

## Project description

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
```for level in orthopy.triangle.Iterator(x, "normal", symbolic=False):
# `level` contains all evalutations of the orthogonal polynomials with the next
# degree at the points x
pass

# or for the entire tree up to degree 4
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.   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
```for level in orthopy.disk.Iterator(x, symbolic=False):
# `level` contains all evalutations of the orthogonal polynomials with the next
# degree at the points x
pass

# or for the entire tree up to degree 4
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.

```for level in orthopy.sphere.Iterator(polar, azimuthal, standardization="quantum mechanic", symbolic=False):
# `level` contains all evalutations of the spherical harmonics with the next
# degree at the points x
pass

# or for the entire tree up to degree n
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`.

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

### Testing

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

``````pytest
``````

### Relevant publications

orthopy is published under the MIT license.

## Project details

This version 0.6.2 0.6.1 0.6.0 0.5.3 0.5.2 0.5.1 0.5.0 0.4.1 0.4.0 0.3.4 0.3.3 0.3.2 0.3.1 0.3.0 0.2.1 0.2.0 0.1.7 0.1.6 0.1.5 0.1.4 0.1.3 0.1.2 0.1.1 0.1.0 0.0.1