Tools for orthogonal polynomials, Gaussian quadrature

## Project description

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(-r^{2})

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.

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

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(-r^{2})

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[0]`

.

### nD space with weight function exp(-r^{2})

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

### Relevant publications

- Robert C. Kirby, Singularity-free evaluation of collapsed-coordinate orthogonal polynomials, ACM Transactions on Mathematical Software (TOMS), Volume 37, Issue 1, January 2010
- Abedallah Rababah, Recurrence Relations for Orthogonal Polynomials on Triangular Domains, MDPI Mathematics 2016, 4(2)
- Yuan Xu, Orthogonal polynomials of several variables, archiv.org, January 2017

### License

orthopy is published under the MIT license.

## Project details

## Release history Release notifications

## Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|

Filename, size orthopy-0.6.2-py3-none-any.whl (26.8 kB) | File type Wheel | Python version py3 | Upload date | Hashes View hashes |

Filename, size orthopy-0.6.2.tar.gz (26.8 kB) | File type Source | Python version None | Upload date | Hashes View hashes |