Skip to main content

orthopy

All about orthogonal polynomials.

PyPi Version PyPI pyversions GitHub stars Downloads

Discord orthogonal

orthopy provides various orthogonal polynomial classes for lines, triangles, disks, spheres, n-cubes, the nD space with weight function exp(-r2) and more. All computations are done using numerically stable recurrence schemes. Furthermore, all functions are fully vectorized and can return results in exact arithmetic.

Installation

Install orthopy from PyPI with

pip install orthopy

How to get a license

Licenses for personal and academic use can be purchased here. You'll receive a confirmation email with a license key. Install the key with

plm add <your-license-key>

on your machine and you're good to go.

For commercial use, please contact support@mondaytech.com.

Basic usage

The main function of all submodules is the iterator Eval which evaluates the series of orthogonal polynomials with increasing degree at given points using a recurrence relation, e.g.,

import orthopy

x = 0.5

evaluator = orthopy.c1.legendre.Eval(x, "classical")
for _ in range(5):
    print(next(evaluator))
1.0  # P_0(0.5)
0.5  # P_1(0.5)
-0.125  # P_2(0.5)
-0.4375  # P_3(0.5)
-0.2890625  # P_4(0.5)

Other ways of getting the first n items are

evaluator = Eval(x, "normal")
vals = [next(evaluator) for _ in range(n)]

import itertools

vals = list(itertools.islice(Eval(x, "normal"), n))

Instead of evaluating at only one point, you can provide any array for x; the polynomials will then be evaluated for all points at once. You can also use sympy for symbolic computation:

import itertools
import orthopy
import sympy

x = sympy.Symbol("x")

evaluator = orthopy.c1.legendre.Eval(x, "classical")
for val in itertools.islice(evaluator, 5):
    print(sympy.expand(val))
1
x
3*x**2/2 - 1/2
5*x**3/2 - 3*x/2
35*x**4/8 - 15*x**2/4 + 3/8

All Eval methods have a scaling argument which can have three values:

  • "monic": The leading coefficient is 1.
  • "classical": The maximum value is 1 (or (n+alpha over n)).
  • "normal": The integral of the squared function over the domain is 1.

For univariate ("one-dimensional") integrals, every new iteration contains one function. For bivariate ("two-dimensional") domains, every level will contain one function more than the previous, and similarly for multivariate families. See the tree plots below.

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

Legendre Chebyshev 1 Chebyshev 2

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

import orthopy

orthopy.c1.legendre.Eval(x, "normal")
orthopy.c1.chebyshev1.Eval(x, "normal")
orthopy.c1.chebyshev2.Eval(x, "normal")
orthopy.c1.gegenbauer.Eval(x, "normal", lmbda)
orthopy.c1.jacobi.Eval(x, "normal", alpha, beta)

The plots above are generated with

import orthopy

orthopy.c1.jacobi.show(5, "normal", 0.0, 0.0)
# plot, savefig also exist

Recurrence coefficients can be explicitly retrieved by

import orthopy

rc = orthopy.c1.jacobi.RecurrenceCoefficients(
    "monic",  # or "classical", "normal"
    alpha=0,
    beta=0,
    symbolic=True,
)
print(rc.p0)
for k in range(5):
    print(rc[k])
1
(1, 0, None)
(1, 0, 1/3)
(1, 0, 4/15)
(1, 0, 9/35)
(1, 0, 16/63)

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

(Generalized) Laguerre polynomials.

evaluator = orthopy.e1r.Eval(x, alpha=0, scaling="normal")

1D space with weight function exp(-r2)

Hermite polynomials come in two standardizations:

  • "physicists" (against the weight function exp(-x ** 2)
  • "probabilists" (against the weight function 1 / sqrt(2 * pi) * exp(-x ** 2 / 2)
evaluator = orthopy.e1r2.Eval(
    x,
    "probabilists",  # or "physicists"
    "normal",
)

Associated Legendre "polynomials"

Not all of those are polynomials, so they should really be called associated Legendre functions. The kth iteration contains 2k+1 functions, indexed from -k to k. (See the color grouping in the above plot.)

evaluator = orthopy.c1.associated_legendre.Eval(
    x, phi=None, standardization="natural", with_condon_shortley_phase=True
)

Triangle (T2)

orthopy's triangle orthogonal polynomials are evaluated in terms of barycentric coordinates, so the X.shape[0] has to be 3.

import orthopy

bary = [0.1, 0.7, 0.2]
evaluator = orthopy.t2.Eval(bary, "normal")

Disk (S2)

Xu Zernike Zernike 2

orthopy contains several families of orthogonal polynomials on the unit disk: After Xu, Zernike, and a simplified version of Zernike polynomials.

import orthopy

x = [0.1, -0.3]

evaluator = orthopy.s2.xu.Eval(x, "normal")
# evaluator = orthopy.s2.zernike.Eval(x, "normal")
# evaluator = orthopy.s2.zernike2.Eval(x, "normal")

Sphere (U3)

Complex-valued spherical harmonics, (black=zero, green=real positive, pink=real negative, blue=imaginary positive, yellow=imaginary negative). The functions in the middle are real-valued. The complex angle takes n turns on the nth level.

evaluator = orthopy.u3.EvalCartesian(
    x,
    scaling="quantum mechanic",  # or "acoustic", "geodetic", "schmidt"
)

evaluator = orthopy.u3.EvalSpherical(
    theta_phi,  # polar, azimuthal angles
    scaling="quantum mechanic",  # or "acoustic", "geodetic", "schmidt"
)

n-Cube (Cn)

C1 (Legendre) C2 C3

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

evaluator = orthopy.cn.Eval(X, alpha=0, beta=0)
values, degrees = next(evaluator)

nD space with weight function exp(-r2) (Enr2)

E1r2 E2r2 E3r2

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

evaluator = orthopy.enr2.Eval(
    x,
    standardization="probabilists",  # or "physicists"
)
values, degrees = next(evaluator)

Other tools

  • Generating recurrence coefficients for 1D domains with Stieltjes, Golub-Welsch, Chebyshev, and modified Chebyshev.

  • The the sanity of recurrence coefficients with test 3 from Gautschi's article: computing the weighted sum of orthogonal polynomials:

    orthopy.tools.gautschi_test_3(moments, alpha, beta)
    
  • Clenshaw algorithm for computing the weighted sum of orthogonal polynomials:

    vals = orthopy.c1.clenshaw(a, alpha, beta, t)
    

Relevant publications

Metadata

Release files for orthopy 0.10.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for orthopy 0.10.12
File Actions
orthopy-0.10.12-cp315-none-any.whl CPython 3.15 none any Details for orthopy-0.10.12-cp315-none-any.whl
orthopy-0.10.12-cp314-none-any.whl CPython 3.14 none any Details for orthopy-0.10.12-cp314-none-any.whl
orthopy-0.10.12-cp313-none-any.whl CPython 3.13 none any Details for orthopy-0.10.12-cp313-none-any.whl
orthopy-0.10.12-cp312-none-any.whl CPython 3.12 none any Details for orthopy-0.10.12-cp312-none-any.whl
orthopy-0.10.12-cp311-none-any.whl CPython 3.11 none any Details for orthopy-0.10.12-cp311-none-any.whl
orthopy-0.10.12-cp310-none-any.whl CPython 3.10 none any Details for orthopy-0.10.12-cp310-none-any.whl

Total release size: 1.0 MB

Release files / orthopy-0.10.12-cp315-none-any.whl

Download URL orthopy-0.10.12-cp315-none-any.whl
Size 195.8 kB
Tags CPython 3.15
SHA-256 checksum
How to use checksums
edf6f3d71993576d53588ed07aa592498d41ba4bcf8d4f6523b532fc80d743ac
BLAKE2b-256 checksum
How to use checksums
2c23b99f5e17b8e174d9c363d22e9a6cb9976a402a78b4a81dc8024a62d73d16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / orthopy-0.10.12-cp314-none-any.whl

Download URL orthopy-0.10.12-cp314-none-any.whl
Size 194.1 kB
Tags CPython 3.14
SHA-256 checksum
How to use checksums
c0f16f3e078f58c60239a632a377f987196e4d01b59e9d525b3c7056bc6c111d
BLAKE2b-256 checksum
How to use checksums
9a16aeac82844a05b6d132ba4aca3732bcaae13b6f4e4cbc09443871fee6d1a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / orthopy-0.10.12-cp313-none-any.whl

Download URL orthopy-0.10.12-cp313-none-any.whl
Size 173.3 kB
Tags CPython 3.13
SHA-256 checksum
How to use checksums
453d8e6fe9eabf097150d17875f5ea340f997b398cb9bf43c2697f61510c392b
BLAKE2b-256 checksum
How to use checksums
2d32126ba4dd373b70cf75479b04f0634d177bc3015bf6a4422fed232b3e4686
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / orthopy-0.10.12-cp312-none-any.whl

Download URL orthopy-0.10.12-cp312-none-any.whl
Size 172.2 kB
Tags CPython 3.12
SHA-256 checksum
How to use checksums
16663869aab96ecb9e63d7163c2d7abe77479197a304e8660bf9cb69854652b4
BLAKE2b-256 checksum
How to use checksums
61da7d4891043fa92ebba6e857b07edcd09fb3a7e271a5a7dc3b9cfc61e1871b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / orthopy-0.10.12-cp311-none-any.whl

Download URL orthopy-0.10.12-cp311-none-any.whl
Size 191.5 kB
Tags CPython 3.11
SHA-256 checksum
How to use checksums
0b9103f0aab0e4d43bb8b22e1c8c08f7db6cb898177c9f30801a35e174689075
BLAKE2b-256 checksum
How to use checksums
8de3f144306ae9ae87f5b7bf1fe405e7b11eb25f3c22f88baee9d0c036e47af9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / orthopy-0.10.12-cp310-none-any.whl

Download URL orthopy-0.10.12-cp310-none-any.whl
Size 118.0 kB
Tags CPython 3.10
SHA-256 checksum
How to use checksums
e0d49e256f85b4abb93e034da0ce2fc52b515c57822d08158faec93ec4932cc4
BLAKE2b-256 checksum
How to use checksums
49b2791fcb0fac3939284cf37377d798f4f05d9f0bb9b19d65d3f45d3073600e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Security for orthopy 0.10.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for orthopy-0.10.12-cp315-none-any.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page