prysm.polynomials#

Common Routines#

Various polynomials of optics.

prysm.polynomials.sum_of_2d_modes(modes, weights)#

Compute a sum of 2D modes.

Parameters:
  • modes (iterable) – seq of ndarray of shape (k, m, n); a list of length k with elements of shape (m,n) works

  • weights (numpy.ndarray) – weight of each mode

Returns:

ndarray of shape (m, n) that is the sum of modes as given

Return type:

numpy.ndarry

prysm.polynomials.sum_of_2d_modes_adjoint(modes, databar)#

Apply the adjoint of sum_of_2d_modes with respect to weights.

Parameters:
  • modes (iterable) – seq of ndarray of shape (k, m, n); a list of length k with elements of shape (m,n) works

  • databar (numpy.ndarray) – partial gradient propagated to the return of sum_of_2d_modes

Returns:

cumulative gradient through to the weights vector given to sum_of_2d_modes

Return type:

numpy.ndarry

prysm.polynomials.hopkins(a, b, c, r, t, H)#

Hopkins’ aberration expansion.

This function uses the “W020” or “W131” like notation, with Wabc separating into the a, b, c arguments. To produce a sine term instead of cosine, make a the negative of the order. In other words, for W222S you would use hopkins(2, 2, 2, …) and for W222T you would use hopkins(-2, 2, 2, …).

Parameters:
Returns:

polynomial evaluated at this point

Return type:

numpy.ndarray

prysm.polynomials.lstsq(modes, data)#

Least-Squares fit of modes to data.

Parameters:
  • modes (iterable) – modes to fit; seq of ndarray of shape (m, n)

  • data (numpy.ndarray) – data to fit, of shape (m, n) place NaN values in data for points to ignore

Returns:

fit coefficients

Return type:

numpy.ndarray

prysm.polynomials.normalize_modes(modes, mask, to='std')#

Scale modes such that they have unit RMS.

Parameters:
  • modes (ndarray) – mode shape (m, n) or modes shape (k, m, n) to scale

  • mask (ndarray) – 2D boolean array, True in the interior of the appropriate domain

  • to (str) – what to normalize modes by, use std for “RMS” or ptp for PV

Returns:

scaled modes

Return type:

ndarray

prysm.polynomials.orthogonalize_modes(modes, mask)#

Use a Gram-Schmidt like process to orthogonalize modes over mask.

Parameters:
  • modes (ndarray) – array of shape (k, m, n) to scale

  • mask (ndarray) – 2D boolean array, True in the interior of the appropriate domain

Returns:

orthogonal modes

Return type:

ndarray

Zernike#

Zernike polynomials.

prysm.polynomials.zernike.zernike_norm(n, m)#

Norm of a Zernike polynomial with n, m indexing.

prysm.polynomials.zernike.zero_separation(n)#

Zero separation in normalized r based on radial order n.

prysm.polynomials.zernike.zernike_nm(n, m, r, t, norm=True)#

Zernike polynomial of radial order n, azimuthal order m at point r, t.

Parameters:
  • n (int) – radial order

  • m (int) – azimuthal order

  • r (ndarray) – radial coordinates

  • t (ndarray) – azimuthal coordinates

  • norm (bool, optional) – if True, orthonormalize the result (unit RMS) else leave orthogonal (zero-to-peak = 1)

Returns:

zernike mode of order n,m at points r,t

Return type:

ndarray

prysm.polynomials.zernike.zernike_nm_seq(nms, r, t, norm=True)#

Zernike polynomial of radial order n, azimuthal order m at point r, t.

Parameters:
  • nms (iterable of tuple of int,) – seq of (n, m); looks like [(1,1), (3,1), …]

  • r (ndarray) – radial coordinates

  • t (ndarray) – azimuthal coordinates

  • norm (bool, optional) – if True, orthonormalize the result (unit RMS) else leave orthogonal (zero-to-peak = 1)

Returns:

shape (k, n, m), with k = len(nms)

Return type:

ndarray

prysm.polynomials.zernike.zernike_sum(coefs, nms, x, y, norm=True)#

Evaluate a weighted Zernike sum on Cartesian unit-disk coordinates.

prysm.polynomials.zernike.zernike_nm_der(n, m, r, t, norm=True)#

Derivatives of Zernike polynomial of radial order n, azimuthal order m, w.r.t r and t.

Parameters:
  • n (int) – radial order

  • m (int) – azimuthal order

  • r (ndarray) – radial coordinates

  • t (ndarray) – azimuthal coordinates

  • norm (bool, optional) – if True, orthonormalize the result (unit RMS) else leave orthogonal (zero-to-peak = 1)

Returns:

dZ/dr, dZ/dt

Return type:

ndarray, ndarray

prysm.polynomials.zernike.zernike_nm_der_seq(nms, r, t, norm=True)#

Derivatives of Zernike polynomial of radial order n, azimuthal order m, w.r.t r and t.

Parameters:
  • nms (iterable) – seq of [(n, m)] radial and azimuthal orders

  • m (int) – azimuthal order

  • r (ndarray) – radial coordinates

  • t (ndarray) – azimuthal coordinates

  • norm (bool, optional) – if True, orthonormalize the result (unit RMS) else leave orthogonal (zero-to-peak = 1)

Returns:

shape begins with (len(nms), 2) followed by r.shape leading dimension is derivative w.r.t each term second dimension is (radial, azimuthal) trailing dimensions match the inputs (r, t) in shape

Return type:

ndarray

prysm.polynomials.zernike.zernike_nm_der_xy(n, m, x, y, norm=True)#

Cartesian partial derivatives of Zernike Z_n^m w.r.t. x and y.

Computed directly in (x, y) without going through polar coordinates, so the result is smooth everywhere on the disk including the origin.

Parameters:
  • n (int) – radial order

  • m (int) – azimuthal order

  • x (ndarray) – x coordinate (same normalization as r in zernike_nm; unit disk)

  • y (ndarray) – y coordinate

  • norm (bool, optional) – if True, orthonormalize the result (unit RMS) else leave orthogonal (zero-to-peak = 1)

Returns:

dZ/dx, dZ/dy

Return type:

ndarray, ndarray

prysm.polynomials.zernike.zernike_nm_der_xy_seq(nms, x, y, norm=True)#

Cartesian partial derivatives for a sequence of Zernike polynomials.

Parameters:
  • nms (iterable) – seq of [(n, m)] radial and azimuthal orders

  • x (ndarray) – x coordinate

  • y (ndarray) – y coordinate

  • norm (bool, optional) – if True, orthonormalize the result (unit RMS)

Returns:

shape begins with (len(nms), 2) followed by x.shape; leading dim is mode index, second dim is (dZ/dx, dZ/dy)

Return type:

ndarray

prysm.polynomials.zernike.zernike_sum_der_xy(coefs, nms, x, y, norm=True)#

Synthesize a Zernike-coefficient sum and its xy partial derivatives in one Clenshaw pass.

Computes W(x, y) = sum_i coefs[i] * Z_{n_i, m_i}(x, y) along with dW/dx and dW/dy. Never materializes individual mode arrays: per pixel, peak memory is O(max radial coefs at any single absolute m) instead of O(len(nms)).

Singularity-free at the origin (uses the same J(rho^2) * H(x,y) factoring as zernike_nm_der_xy).

Parameters:
  • coefs (iterable of float) – coefficients, parallel to nms

  • nms (iterable of (int, int)) – (n, m) pairs identifying each Zernike mode; order is irrelevant, and duplicate (n, m) entries are summed

  • x (ndarray) – x coordinate (unit-disk normalization, same convention as r in zernike_nm)

  • y (ndarray) – y coordinate

  • norm (bool, optional) – if True, treat coefs as orthonormal Zernike weights (unit RMS basis); if False, treat them as zero-to-peak weights

Returns:

  • W (ndarray) – sum surface

  • dWdx (ndarray) – dW/dx

  • dWdy (ndarray) – dW/dy

prysm.polynomials.zernike.nm_to_fringe(n, m)#

Convert (n,m) two term index to Fringe index.

prysm.polynomials.zernike.nm_to_ansi_j(n, m)#

Convert (n,m) two term index to ANSI single term index.

prysm.polynomials.zernike.ansi_j_to_nm(idx)#

Convert ANSI single term to (n,m) two-term index.

prysm.polynomials.zernike.noll_to_nm(idx)#

Convert Noll Z to (n, m) two-term index.

prysm.polynomials.zernike.fringe_to_nm(idx)#

Convert Fringe Z to (n, m) two-term index.

prysm.polynomials.zernike.zernikes_to_magnitude_angle_nmkey(coefs)#

Convert Zernike polynomial set to a magnitude and phase representation.

Parameters:

coefs (list of tuples) – a list looking like[(1,2,3),] where (1,2) are the n, m indices and 3 the coefficient

Returns:

dict keyed by tuples of (n, absolute m) with values of (rho, phi) where rho is the magnitudes, and phi the phase

Return type:

dict

prysm.polynomials.zernike.zernikes_to_magnitude_angle(coefs)#

Convert Zernike polynomial set to a magnitude and phase representation.

This function is identical to zernikes_to_magnitude_angle_nmkey, except its keys are strings instead of (n, absolute m)

Parameters:

coefs (list of tuples) – a list looking like[(1,2,3),] where (1,2) are the n, m indices and 3 the coefficient

Returns:

dict keyed by friendly name strings with values of (rho, phi) where rho is the magnitudes, and phi the phase

Return type:

dict

prysm.polynomials.zernike.nm_to_name(n, m)#

Convert an (n,m) index into a human readable name.

Parameters:
  • n (int) – radial polynomial order

  • m (int) – azimuthal polynomial order

Returns:

a name, np.g. Piston or Primary Spherical

Return type:

str

prysm.polynomials.zernike.top_n(coefs, n=5)#

Identify the top n terms in the wavefront expansion.

Parameters:
  • coefs (dict) – keys of (n,m), values of magnitudes, e.g. {(3,1): 2} represents 2 of primary coma

  • n (int, optional) – identify the top n terms.

Returns:

list of tuples (magnitude, index, term)

Return type:

list

prysm.polynomials.zernike.barplot(coefs, names=None, orientation='h', buffer=1, zorder=3, number=True, offset=0, width=0.8, fig=None, ax=None)#

Create a barplot of coefficients and their names.

Parameters:
  • coefs (iterable) – sequence of Zernike coefficients

  • names (dict) – with keys of Zn, values of names (e.g. Primary Coma X)

  • orientation (str, {'h', 'v', 'horizontal', 'vertical'}) – orientation of the plot

  • buffer (float, optional) – buffer to use around the left and right (or top and bottom) bars

  • zorder (int, optional) – zorder of the bars. Use zorder > 3 to put bars in front of gridlines

  • number (bool, optional) – if True, plot numbers along the y=0 line showing indices

  • offset (float, optional) – offset to apply to bars, useful for before/after Zernike breakdowns

  • width (float, optional) – width of bars, useful for before/after Zernike breakdowns

  • fig (matplotlib.figurnp.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns:

  • fig (matplotlib.figurnp.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

prysm.polynomials.zernike.barplot_magnitudes(coefs, nms, errorbars=None, orientation='h', sort=False, buffer=1, zorder=3, offset=0, width=0.8, fig=None, ax=None)#

Create a barplot of magnitudes of coefficient pairs and their names.

e.g., astigmatism will get one bar.

Parameters:
  • coefs (ndarray) – 1D list of coefficients of the modes

  • nms (ndarray) – 1D list of ANSI (n,m) for each coef

  • errorbars (ndarray) – list of errors associated with each coefficient

  • orientation (str, {'h', 'v', 'horizontal', 'vertical'}) – orientation of the plot

  • sort (bool, optional) – whether to sort the zernikes in descending order

  • buffer (float, optional) – buffer to use around the left and right (or top and bottom) bars

  • zorder (int, optional) – zorder of the bars. Use zorder > 3 to put bars in front of gridlines

  • offset (float, optional) – offset to apply to bars, useful for before/after Zernike breakdowns

  • width (float, optional) – width of bars, useful for before/after Zernike breakdowns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns:

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

XY#

XY polynomials.

prysm.polynomials.xy.xy_j_to_mn(j)#

Convert a mono-index j into the m and n powers.

Does not precisely follow Code V; the j=1 term is piston, which does not exist in Code V.

prysm.polynomials.xy.xy(m, n, x, y, cartesian_grid=True)#

Contemporary XY monomial for a given m, n.

Parameters:
  • m (int) – x order

  • n (int) – y order

  • x (ndarray) – x coordinates

  • y (ndarray) – y coordinates

  • cartesian_grid (bool, optional) – if True, the input grid is assumed to be cartesian, i.e., x and y axes are aligned to the array dimensions arr[y,x] to accelerate the computation

Returns:

x^m times y^n evaluated on the input grid

Return type:

ndarray

prysm.polynomials.xy.xy_der_x(m, n, x, y, cartesian_grid=True)#

Partial derivative w.r.t. x of the XY monomial x^m times y^n.

Returns m times x^(m-1) times y^n; zero everywhere when m == 0.

Parameters:
  • m (int) – x order

  • n (int) – y order

  • x (ndarray) – x coordinates

  • y (ndarray) – y coordinates

  • cartesian_grid (bool, optional) – if True, the input grid is assumed to be cartesian, i.e., x and y axes are aligned to the array dimensions arr[y,x] to accelerate the computation

Returns:

d/dx of x^m times y^n evaluated on the input grid

Return type:

ndarray

prysm.polynomials.xy.xy_der_y(m, n, x, y, cartesian_grid=True)#

Partial derivative w.r.t. y of the XY monomial x^m * y^n.

Returns n times x^m times y^(n-1); zero everywhere when n == 0.

Parameters:
  • m (int) – x order

  • n (int) – y order

  • x (ndarray) – x coordinates

  • y (ndarray) – y coordinates

  • cartesian_grid (bool, optional) – if True, the input grid is assumed to be cartesian, i.e., x and y axes are aligned to the array dimensions arr[y,x] to accelerate the computation

Returns:

d/dy of x^m times y^n evaluated on the input grid

Return type:

ndarray

prysm.polynomials.xy.xy_der_xy(m, n, x, y, cartesian_grid=True)#

Mixed partial derivative d^2/dxdy of the XY monomial x^m * y^n.

Returns m times n times x^(m-1) times y^(n-1); zero everywhere when m == 0 or n == 0.

Parameters:
  • m (int) – x order

  • n (int) – y order

  • x (ndarray) – x coordinates

  • y (ndarray) – y coordinates

  • cartesian_grid (bool, optional) – if True, the input grid is assumed to be cartesian, i.e., x and y axes are aligned to the array dimensions arr[y,x] to accelerate the computation

Returns:

d^2/dxdy of x^m times y^n evaluated on the input grid

Return type:

ndarray

prysm.polynomials.xy.xy_seq(mns, x, y, cartesian_grid=True)#

Contemporary XY monomial seq.

Parameters:
  • mns (iterable of length 2 vectors) – seq [(m1, n1), (m2, n2), …]

  • x (ndarray) – x coordinates

  • y (ndarray) – y coordinates

  • cartesian_grid (bool, optional) – if True, the input grid is assumed to be cartesian, i.e., x and y axes are aligned to the array dimensions arr[y,x] to accelerate the computation

Returns:

has shape (len(mns), broadcast(x, y).shape), in the same order as mns

Return type:

ndarray

prysm.polynomials.xy.xy_der_x_seq(mns, x, y, cartesian_grid=True)#

Partial derivative w.r.t. x of the XY monomial seq.

Parameters mirror xy_seq. The (m, n) output is m times x^(m-1) times y^n; entries with m == 0 are zero.

Returns:

has shape (len(mns), broadcast(x, y).shape); d/dx of x^m times y^n in the same order as mns

Return type:

ndarray

prysm.polynomials.xy.xy_der_y_seq(mns, x, y, cartesian_grid=True)#

Partial derivative w.r.t. y of the XY monomial seq.

Parameters mirror xy_seq. The (m, n) output is n times x^m times y^(n-1); entries with n == 0 are zero.

Returns:

has shape (len(mns), broadcast(x, y).shape); d/dy of x^m times y^n in the same order as mns

Return type:

ndarray

prysm.polynomials.xy.xy_der_xy_seq(mns, x, y, cartesian_grid=True)#

Mixed partial derivative d^2/dxdy of the XY monomial seq.

Parameters mirror xy_seq. The (m, n) output is m*n times x^(m-1) times y^(n-1); entries where m == 0 or n == 0 are zero.

Returns:

has shape (len(mns), broadcast(x, y).shape); d^2/dxdy of x^m times y^n in the same order as mns

Return type:

ndarray

prysm.polynomials.xy.xy_sum(coefs, mns, x, y, cartesian_grid=True)#

Evaluate a weighted sum of XY monomials.

prysm.polynomials.xy.xy_sum_der_xy(coefs, mns, x, y, cartesian_grid=True)#

Evaluate a weighted XY sum and its Cartesian first derivatives.

Q (Forbes)#

Tools for working with Q (Forbes) polynomials.

prysm.polynomials.qpoly.g_qbfs(n_minus_1)#

g(m-1) from oe-18-19-19700 eq. (A.15).

prysm.polynomials.qpoly.h_qbfs(n_minus_2)#

h(m-2) from oe-18-19-19700 eq. (A.14).

prysm.polynomials.qpoly.f_qbfs(n)#

f(m) from oe-18-19-19700 eq. (A.16).

prysm.polynomials.qpoly.Qbfs(n, x)#

Qbfs polynomial of order n at point(s) x.

Parameters:
  • n (int) – polynomial order

  • x (numpy.array) – point(s) at which to evaluate

Returns:

Qbfs_n(x)

Return type:

ndarray

prysm.polynomials.qpoly.change_basis_Qbfs_to_Pn(cs)#

Perform the change of basis from Qbfs to the auxiliary polynomial Pn.

The auxiliary polynomial is defined in A.4 of oe-18-19-19700 and is the shifted Chebyshev polynomials of the third kind.

Qbfs polynomials u^2(1-u^2)Qbfs_n(u^2) can be expressed as u^2(1-u^2)Pn(u^2) u in Forbes’ parlance is the normalized radial coordinate, so given points r in the range [0,1], use this function and then polynomials.cheby3(n, r*r). The u^2 (1 - u^2) is baked into the Qbfs function and will need to be applied by the caller for Cheby3.

Parameters:

cs (iterable) – seq of polynomial coefficients, from order n=0..len(cs)-1

Returns:

array of same type as cs holding the coefficients that represent the same surface as a sum of shifted Chebyshev polynomials of the third kind

Return type:

ndarray

prysm.polynomials.qpoly.clenshaw_qbfs(cs, usq, alphas=None)#

Use Clenshaw’s method to compute a Qbfs surface from its coefficients.

Parameters:
  • cs (iterable of float) – coefficients for a Qbfs surface, from order 0..len(cs)-1

  • usq (ndarray) – radial coordinate(s) to evaluate, squared, notionally in the range [0,1] the variable u^2 from oe-18-19-19700

  • alphas (ndarray, optional) – array to store the alpha sums in, the surface is u^2(1-u^2) times 2 times (alphas[0]+alphas[1]) if not None, alphas should be of shape (len(s), x.shape) see _initialize_alphas if you desire more information

Returns:

Qbfs surface, the quantity u^2(1-u^2) S(u^2) from Eq. (3.13) note: excludes the division by phi, since c and rho are unknown

Return type:

ndarray

prysm.polynomials.qpoly.clenshaw_qbfs_der(cs, usq, j=1, alphas=None)#

Use Clenshaw’s method to compute Nth order derivatives of a sum of Qbfs polynomials.

Excludes base sphere and u^2(1-u^2) prefix

As an end-user, you are likely more interested in compute_zprime_Qbfs.

Parameters:
  • cs (iterable of float) – coefficients for a Qbfs surface, from order 0..len(cs)-1

  • usq (ndarray) – radial coordinate(s) to evaluate, squared, notionally in the range [0,1] the variable u^2 from oe-18-19-19700

  • j (int) – derivative order

  • alphas (ndarray, optional) –

    array to store the alpha sums in, if x = u * u, then S = (x times (1 - x)) times 2 times (alphas[0][0] + alphas[0][1]) S’ = … .. the same, but alphas[1][0] and alphas[1][1] S’’ = … … … … … … [2][0] … … ..[1][1] etc

    if not None, alphas should have shape (j+1, len(cs)) followed by x.shape see _initialize_alphas if you desire more information

Returns:

the alphas array

Return type:

ndarray

prysm.polynomials.qpoly.product_rule(u, v, du, dv)#

The product rule of calculus, d/dx uv = u dv v du.

prysm.polynomials.qpoly.compute_z_zprime_Qbfs(coefs, u, usq)#

Compute the surface sag and first radial derivative of a Qbfs surface.

Excludes base sphere.

from Eq. 3.13 and 3.14 of oe-18-19-19700.

Parameters:
  • coefs (iterable) – surface coefficients for Q0..QN, N=len(coefs)-1

  • u (ndarray) – normalized radial coordinates (rho/rho_max)

  • usq (ndarray) – u^2

  • c (float) – best fit sphere curvature use c=0 for a flat base surface

Returns:

S, Sprime in Forbes’ parlance

Return type:

ndarray, ndarray

prysm.polynomials.qpoly.compute_z_Qbfs(coefs, u, usq)#

Sag-only sibling of compute_z_zprime_Qbfs.

clenshaw_qbfs already returns u^2 (1 - u^2) S(u^2), the full sag, so this is just a thin name-parity wrapper that mirrors compute_z_zprime_Qbfs’s signature.

prysm.polynomials.qpoly.compute_z_zprime_Qcon(coefs, u, usq)#

Compute the surface sag and first radial derivative of a Qcon surface.

Excludes base sphere.

from Eq. 5.3 and 5.3 of oe-18-13-13851.

Parameters:
  • coefs (iterable) – surface coefficients for Q0..QN, N=len(coefs)-1

  • u (ndarray) – normalized radial coordinates (rho/rho_max)

  • usq (ndarray) – u^2

Returns:

S, Sprime in Forbes’ parlance

Return type:

ndarray, ndarray

prysm.polynomials.qpoly.Qbfs_seq(ns, x)#

Qbfs polynomials of orders ns at point(s) x.

Parameters:
  • ns (Iterable of int) – polynomial orders

  • x (numpy.array) – point(s) at which to evaluate

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.qpoly.Qbfs_der(n, x)#

Partial derivative w.r.t. x of the Qbfs polynomial of order n.

Uses the parallel auxiliary recurrence on y = x^2 to evaluate both Q_n(y) and Q’_n(y) = dQ_n/dy, then chains through the leading x^2(1 - x^2) envelope:

dQbfs_n/dx = (2x - 4x^3) Q_n(x^2) + (2x^3 - 2x^5) Q’_n(x^2)

Parameters:
  • n (int) – polynomial order

  • x (ndarray) – point(s) at which to evaluate, notionally in [0, 1]

Returns:

d/dx Qbfs_n(x)

Return type:

ndarray

prysm.polynomials.qpoly.Qbfs_der_seq(ns, x)#

Partial derivative w.r.t. x of Qbfs polynomials of orders ns.

Companion to Qbfs_seq; see Qbfs_der for the derivation.

Parameters:
  • ns (Iterable of int) – polynomial orders (assumed sorted ascending)

  • x (ndarray) – point(s) at which to evaluate

Returns:

has shape (len(ns),) followed by x.shape; the i-th plane is d/dx Qbfs_{ns[i]}(x)

Return type:

ndarray

prysm.polynomials.qpoly.Qcon(n, x)#

Qcon polynomial of order n at point(s) x.

Parameters:
  • n (int) – polynomial order

  • x (numpy.array) – point(s) at which to evaluate

Returns:

Qcon_n(x)

Return type:

ndarray

Notes

The argument x is notionally uniformly spaced 0..1. The Qcon polynomials are obtained by computing c = x^4. A transformation is then made, x => 2x^2 - 1 and the Qcon polynomials are defined as the jacobi polynomials with alpha=0, beta=4, the same order n, and the transformed x. The result of that is multiplied by c to yield a Qcon polynomial. Sums can more quickly be calculated by deferring the multiplication by c.

prysm.polynomials.qpoly.Qcon_seq(ns, x)#

Qcon polynomials of orders ns at point(s) x.

Parameters:
  • ns (Iterable of int) – polynomial orders

  • x (numpy.array) – point(s) at which to evaluate

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.qpoly.Qcon_der(n, x)#

Partial derivative w.r.t. x of the Qcon polynomial of order n.

Qcon_n(x) = x^4 * P_n(2x^2 - 1) where P_n is the Jacobi polynomial with alpha=0, beta=4. Differentiating:

dQcon_n/dx = 4 x^3 P_n(2x^2 - 1) + 4 x^5 P'_n(2x^2 - 1)
Parameters:
  • n (int) – polynomial order

  • x (ndarray) – point(s) at which to evaluate, notionally in [0, 1]

Returns:

d/dx Qcon_n(x)

Return type:

ndarray

prysm.polynomials.qpoly.Qcon_der_seq(ns, x)#

Partial derivative w.r.t. x of Qcon polynomials of orders ns.

Companion to Qcon_seq; see Qcon_der for the derivation.

Parameters:
  • ns (Iterable of int) – polynomial orders (assumed sorted ascending)

  • x (ndarray) – point(s) at which to evaluate

Returns:

has shape (len(ns),) followed by x.shape; the i-th plane is d/dx Qcon_{ns[i]}(x)

Return type:

ndarray

prysm.polynomials.qpoly.abc_q2d(n, m)#

A, B, C terms for 2D-Q polynomials. oe-20-3-2483 Eq. (A.3).

Parameters:
  • n (int) – radial order

  • m (int) – azimuthal order

Returns:

A, B, C

Return type:

float, float, float

prysm.polynomials.qpoly.G_q2d(n, m)#

G term for 2D-Q polynomials. oe-20-3-2483 Eq. (A.15).

Parameters:
  • n (int) – radial order

  • m (int) – azimuthal order

Returns:

G

Return type:

float

prysm.polynomials.qpoly.F_q2d(n, m)#

F term for 2D-Q polynomials. oe-20-3-2483 Eq. (A.13).

Parameters:
  • n (int) – radial order

  • m (int) – azimuthal order

Returns:

F

Return type:

float

prysm.polynomials.qpoly.g_q2d(n, m)#

Lowercase g term for 2D-Q polynomials. oe-20-3-2483 Eq. (A.18a).

Parameters:
  • n (int) – radial order less one (n - 1)

  • m (int) – azimuthal order

Returns:

g

Return type:

float

prysm.polynomials.qpoly.f_q2d(n, m)#

Lowercase f term for 2D-Q polynomials. oe-20-3-2483 Eq. (A.18b).

Parameters:
  • n (int) – radial order

  • m (int) – azimuthal order

Returns:

f

Return type:

float

prysm.polynomials.qpoly.Q2d(n, m, r, t)#

2D Q polynomial, aka the Forbes polynomials.

Parameters:
  • n (int) – radial polynomial order

  • m (int) – azimuthal polynomial order

  • r (ndarray) – radial coordinate, slope orthogonal in [0,1]

  • t (ndarray) – azimuthal coordinate, radians

Returns:

array containing Q2d_n^m(r,t) the leading coefficient u^m or u^2 (1 - u^2) and sines/cosines are included in the return

Return type:

ndarray

prysm.polynomials.qpoly.Q2d_seq(nms, r, t)#

Seq of 2D-Q polynomials.

Parameters:
  • nms (iterable of tuple) – (n,m) for each desired term

  • r (ndarray) – radial coordinates

  • t (ndarray) – azimuthal coordinates

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.qpoly.Q2d_der(n, m, r, t)#

Polar partial derivatives of the 2D Q polynomial Q2d_n^m.

Parameters:
  • n (int) – radial order

  • m (int) – azimuthal order (sign controls cosine vs sine prefix; m=0 is the purely-radial Qbfs case)

  • r (ndarray) – radial coordinate in [0, 1]

  • t (ndarray) – azimuthal coordinate, radians

Returns:

d/dr Q2d_n^m, d/dt Q2d_n^m

Return type:

ndarray, ndarray

prysm.polynomials.qpoly.Q2d_der_xy(n, m, x, y)#

Cartesian partial derivatives of the 2D Q polynomial Q2d_n^m.

Computed directly in (x, y) via the harmonic decomposition r^abs(m) cos(m t) = Re((x + i y)^abs(m)) (and Im for m<0), so the result is smooth at the origin with no 1/r singularity.

Parameters:
  • n (int) – radial order

  • m (int) – azimuthal order

  • x (ndarray) – Cartesian x coordinate (same normalization as r in Q2d)

  • y (ndarray) – Cartesian y coordinate

Returns:

dQ/dx, dQ/dy

Return type:

ndarray, ndarray

prysm.polynomials.qpoly.Q2d_der_seq(nms, r, t)#

Polar partial derivatives of a sequence of Q2d polynomials.

Companion to Q2d_seq; per-m recurrence is shared across all radial orders for that m.

Parameters:
  • nms (iterable of tuple) – (n, m) for each desired term

  • r (ndarray) – radial coordinates

  • t (ndarray) – azimuthal coordinates

Returns:

arrays of shape (len(nms),) followed by r.shape; the first is d/dr, the second is d/dt, in the same order as nms

Return type:

ndarray, ndarray

prysm.polynomials.qpoly.Q2d_der_xy_seq(nms, x, y)#

Cartesian partial derivatives of a sequence of Q2d polynomials.

Companion to Q2d_der_xy; per-m recurrence and per-am harmonic powers are shared across all radial orders for that m.

Parameters:
  • nms (iterable of tuple) – (n, m) for each desired term

  • x (ndarray) – Cartesian x coordinate

  • y (ndarray) – Cartesian y coordinate

Returns:

arrays of shape (len(nms),) followed by x.shape; the first is d/dx, the second is d/dy, in the same order as nms

Return type:

ndarray, ndarray

prysm.polynomials.qpoly.change_of_basis_Q2d_to_Pnm(cns, m)#

Perform the change of basis from Q_n^m to the auxiliary polynomial P_n^m.

The auxiliary polynomial is defined in A.1 of oe-20-3-2483 and is the an unconventional variant of Jacobi polynomials.

For terms where m=0, see change_basis_Qbfs_to_Pn. This function only concerns those terms within the sum u^m a_n^m cos(mt) + b_n^m sin(mt) Q_n^m(u^2) sum

Parameters:
  • cns (iterable) – seq of polynomial coefficients, from order n=0..len(cs)-1 and a given m (not absolute m, but m, i.e. either “-2” or “+2” but not both)

  • m (int) – azimuthal order

Returns:

array of same type as cs holding the coefficients that represent the same surface as a sum of shifted Chebyshev polynomials of the third kind

Return type:

ndarray

prysm.polynomials.qpoly.abc_q2d_clenshaw(n, m)#

Special twist on A.3 for B.7.

prysm.polynomials.qpoly.clenshaw_q2d(cns, m, usq, alphas=None)#

Use Clenshaw’s method to compute the alpha sums for a piece of a Q2D surface.

Parameters:
  • cns (iterable of float) – coefficients for a Qbfs surface, from order 0..len(cs)-1

  • m (int) – azimuthal order for the cns

  • usq (ndarray) – radial coordinate(s) to evaluate, squared, notionally in the range [0,1] the variable u^2 from oe-18-19-19700

  • alphas (ndarray, optional) – array to store the alpha sums in, the surface is u^2(1-u^2) times 2 times (alphas[0]+alphas[1]) if not None, alphas should have shape (len(s),) followed by x.shape see _initialize_alphas if you desire more information

Returns:

array containing components to compute the surface sag sum(cn Qn) is .5 alphas[0] - 2/5 alphas[3] if m=1 and N>2, and .5 alphas[0] otherwise.

Return type:

alphas

prysm.polynomials.qpoly.clenshaw_q2d_der(cns, m, usq, j=1, alphas=None)#

Use Clenshaw’s method to compute Nth order derivatives of a Q2D surface.

This function is to be consumed by the other parts of prysm, and simply does the “alphas” computations (B.10) and adjacent Eqns

See compute_zprime_Q2D for this calculation integrated

Parameters:
  • cns (iterable of float) – coefficients for a Qbfs surface, from order 0..len(cs)-1

  • m (int) – azimuthal order

  • usq (ndarray) – radial coordinate(s) to evaluate, squared, notionally in the range [0,1] the variable u from oe-18-19-19700

  • j (int) – derivative order

  • alphas (ndarray, optional) – array to store the alpha sums in, if not None, alphas should have shape (j+1, len(cs)) followed by x.shape see _initialize_alphas if you desire more information

Returns:

the alphas array

Return type:

ndarray

prysm.polynomials.qpoly.compute_z_zprime_Q2d(cm0, ams, bms, u, t)#

Compute the surface sag and first radial and azimuthal derivative of a Q2D surface.

Excludes base sphere.

from Eq. 2.2 and Appendix B of oe-20-3-2483.

Parameters:
  • cm0 (iterable) – surface coefficients when m=0 (inside curly brace, top line, Eq. B.1) span n=0 .. len(cms)-1 and mus tbe fully dense

  • ams (iterable of iterables) – ams[0] are the coefficients for the m=1 cosine terms, ams[1] for the m=2 cosines, and so on. Same order n rules as cm0

  • bms (iterable of iterables) –

    same as ams, but for the sine terms ams and bms must be the same length - that is, if an azimuthal order m is presnet in ams, it must be present in bms. The azimuthal orders need not have equal radial expansions.

    For example, if ams extends to m=3, then bms must reach m=3 but, if the ams for m=3 span n=0..5, it is OK for the bms to span n=0..3, or any other value, even just [0].

  • u (ndarray) – normalized radial coordinates (rho/rho_max)

  • t (ndarray) – azimuthal coordinate, in the range [0, 2pi]

Returns:

surface sag, radial derivative of sag, azimuthal derivative of sag

Return type:

ndarray, ndarray, ndarray

prysm.polynomials.qpoly.compute_z_Q2d(cm0, ams, bms, u, t)#

Sag-only sibling of compute_z_zprime_Q2d.

prysm.polynomials.qpoly.Q2d_nm_c_to_a_b(nms, coefs)#

Re-structure Q2D coefficients to the form needed by compute_z_zprime_Q2d.

Parameters:
  • nms (iterable) – seq of [(n1, m1), (n2, m2), …] negative m encodes “sine term” while positive m encodes “cosine term”

  • coefs (iterable) – same length as nms, coefficients for mode n_m

Returns:

list 1 is cms, the “Qbfs” coefficients (m=0) list 2 is the “a” coefficients (cosine terms) list 3 is the “b” coefficients (sine terms)

lists 2 and 3 are lists-of-lists and begin from m=1 to m=M, containing an empty list if that order was not present in the input

Return type:

list, list, list

Jacobi#

High performance / recursive jacobi polynomial calculation.

prysm.polynomials.jacobi.weight(alpha, beta, x)#

The weight function of the jacobi polynomials for a given alpha, beta value.

prysm.polynomials.jacobi.recurrence_abc(n, alpha, beta)#

See A&S online - https://dlmf.nist.gov/18.9 .

Pn = (an-1 x + bn-1) Pn-1 - cn-1 * Pn-2

This function makes a, b, c for the given n, i.e. to get a(n-1), do recurrence_abc(n-1)

prysm.polynomials.jacobi.jacobi(n, alpha, beta, x)#

Jacobi polynomial of order n with weight parameters alpha and beta.

Parameters:
  • n (int) – polynomial order

  • alpha (float) – first weight parameter

  • beta (float) – second weight parameter

  • x (ndarray) – x coordinates to evaluate at

Returns:

jacobi polynomial evaluated at the given points

Return type:

ndarray

prysm.polynomials.jacobi.jacobi_with_der(n, alpha, beta, x)#

Jacobi polynomial and first derivative of order n.

This uses the differentiated three-term recurrence directly, so callers that need both P_n and P_n’ do not need separate Jacobi recurrences.

Parameters:
  • n (int) – polynomial order

  • alpha (float) – first weight parameter

  • beta (float) – second weight parameter

  • x (ndarray) – x coordinates to evaluate at

Returns:

P_n and dP_n/dx evaluated at the given points

Return type:

ndarray, ndarray

prysm.polynomials.jacobi.jacobi_seq(ns, alpha, beta, x)#

Jacobi polynomials of orders ns with weight parameters alpha and beta.

Parameters:
  • ns (iterable) – sorted polynomial orders to return, e.g. [1, 3, 5, 7, …]

  • alpha (float) – first weight parameter

  • beta (float) – second weight parameter

  • x (ndarray) – x coordinates to evaluate at

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.jacobi.jacobi_seq_with_der(ns, alpha, beta, x)#

Jacobi polynomials and first derivatives for orders ns.

Parameters:
  • ns (iterable) – sorted polynomial orders to return

  • alpha (float) – first weight parameter

  • beta (float) – second weight parameter

  • x (ndarray) – x coordinates to evaluate at

Returns:

P_n and dP_n/dx arrays, each shaped as (len(ns),) followed by x.shape

Return type:

ndarray, ndarray

prysm.polynomials.jacobi.jacobi_der(n, alpha, beta, x)#

First derivative of Pn with respect to x, at points x.

Parameters:
  • n (int) – polynomial order

  • alpha (float) – first weight parameter

  • beta (float) – second weight parameter

  • x (ndarray) – x coordinates to evaluate at

Returns:

jacobi polynomial evaluated at the given points

Return type:

ndarray

prysm.polynomials.jacobi.jacobi_der_seq(ns, alpha, beta, x)#

First partial derivative of Pn w.r.t. x for order ns, i.e. P_n’.

Parameters:
  • ns (iterable) – sorted orders to return, e.g. [1, 2, 3, 10] returns P1’, P2’, P3’, P10’

  • alpha (float) – first weight parameter

  • beta (float) – second weight parameter

  • x (ndarray) – x coordinates to evaluate at

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.jacobi.jacobi_sum_clenshaw(s, alpha, beta, x, alphas=None)#

Compute a weighted sum of Jacobi polynomials using Clenshaw’s method.

Parameters:
  • s (iterable) – weights in ascending order, beginning with P0, then P1, etc. must be fully dense when iterated

  • alpha (float) – first Jacobi shape parameter

  • beta (float) – second Jacobi shape parameter

  • x (ndarray or float_like) – coordinates to evaluate the sum at, orthogonal over [-1,1]

  • alphas (ndarray, optional) – array to store the alpha sums in, alphas[0] contains the sum and is returned if not None, alphas should be of shape (len(s), x.shape) see _initialize_alphas if you desire more information

Returns:

weighted sum of Jacobi polynomials

Return type:

ndarray

prysm.polynomials.jacobi.jacobi_sum_clenshaw_der(s, alpha, beta, x, j=1, alphas=None)#

Compute a weighted sum of partial derivatives w.r.t. x of Jacobi polynomials using Clenshaw’s method.

Notes

If the polynomial values and their derivatives are desired, pass alphas instead of leaving it None. alphas[0,0] will contain the sum of the polynomials, alphas[1,0] the sum of the first derivative, and so on.

Parameters:
  • s (iterable) – weights in ascending order, beginning with P0, then P1, etc. must be fully dense when iterated

  • alpha (float) – first Jacobi shape parameter

  • beta (float) – second Jacobi shape parameter

  • x (ndarray or float_like) – coordinates to evaluate the sum at, orthogonal over [-1,1]

  • j (int) – derivative order to compute

  • alphas (ndarray, optional) –

    array to store the alpha sums in, alphas[n] is the nth order derivative alpha terms with n=0 being the non-derivative terms.

    for a given n, the value of alphas[0] is the nth derivative of the surface sum if not None, alphas should have shape (j+1, len(s)) followed by x.shape see _initialize_alphas if you desire more information

Returns:

alphas array, see alphas parameter documentation for meaning

Return type:

ndarray

prysm.polynomials.jacobi.jacobi_radial_sum(coefs, ns, alpha, beta, x, y, normalization_radius)#

Evaluate a weighted radial Jacobi polynomial sum on x, y points.

prysm.polynomials.jacobi.jacobi_radial_sum_der_xy(coefs, ns, alpha, beta, x, y, normalization_radius)#

Evaluate a radial Jacobi sum and its Cartesian derivatives.

Chebyshev#

Chebyshev polynomials.

prysm.polynomials.cheby.cheby1(n, x)#

Chebyshev polynomial of the first kind of order n.

Parameters:
  • n (int) – order to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

prysm.polynomials.cheby.cheby1_seq(ns, x)#

Chebyshev polynomials of the first kind of orders ns.

Faster than chevy1 in a loop.

Parameters:
  • ns (Iterable of int) – orders to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.cheby.cheby1_der(n, x)#

Partial derivative w.r.t. x of Chebyshev polynomial of the first kind of order n.

Parameters:
  • n (int) – order to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

prysm.polynomials.cheby.cheby1_der_seq(ns, x)#

Partial derivative w.r.t. x of Chebyshev polynomials of the first kind of orders ns.

Faster than chevy1_der in a loop.

Parameters:
  • ns (Iterable of int) – orders to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.cheby.cheby2(n, x)#

Chebyshev polynomial of the second kind of order n.

Parameters:
  • n (int) – order to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

prysm.polynomials.cheby.cheby2_seq(ns, x)#

Chebyshev polynomials of the second kind of orders ns.

Faster than chevy1 in a loop.

Parameters:
  • ns (Iterable of int) – orders to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.cheby.cheby2_der(n, x)#

Partial derivative w.r.t. x of Chebyshev polynomial of the second kind of order n.

Parameters:
  • n (int) – order to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

prysm.polynomials.cheby.cheby2_der_seq(ns, x)#

Partial derivative w.r.t. x of Chebyshev polynomials of the second kind of orders ns.

Faster than chevy2_der in a loop.

Parameters:
  • ns (Iterable of int) – orders to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.cheby.cheby3(n, x)#

Chebyshev polynomial of the third kind of order n.

Parameters:
  • n (int) – order to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

prysm.polynomials.cheby.cheby3_seq(ns, x)#

Chebyshev polynomials of the third kind of orders ns.

Faster than chevy1 in a loop.

Parameters:
  • ns (Iterable of int) – orders to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.cheby.cheby3_der(n, x)#

Partial derivative w.r.t. x of Chebyshev polynomial of the third kind of order n.

Parameters:
  • n (int) – order to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

prysm.polynomials.cheby.cheby3_der_seq(ns, x)#

Partial derivative w.r.t. x of Chebyshev polynomials of the third kind of orders ns.

Faster than chevy1_der in a loop.

Parameters:
  • ns (Iterable of int) – orders to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.cheby.cheby4(n, x)#

Chebyshev polynomial of the fourth kind of order n.

Parameters:
  • n (int) – order to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

prysm.polynomials.cheby.cheby4_seq(ns, x)#

Chebyshev polynomials of the fourth kind of orders ns.

Faster than chevy1 in a loop.

Parameters:
  • ns (Iterable of int) – orders to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.cheby.cheby4_der(n, x)#

Partial derivative w.r.t. x of Chebyshev polynomial of the fourth kind of order n.

Parameters:
  • n (int) – order to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

prysm.polynomials.cheby.cheby4_der_seq(ns, x)#

Partial derivative w.r.t. x of Chebyshev polynomials of the fourth kind of orders ns.

Faster than chevy1_der in a loop.

Parameters:
  • ns (Iterable of int) – orders to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.cheby.cheby1_2d_sum(coefs, mns, x, y)#

Evaluate a weighted tensor-product Chebyshev-T sum.

prysm.polynomials.cheby.cheby1_2d_sum_der_xy(coefs, mns, x, y, x_norm=1.0, y_norm=1.0)#

Evaluate a weighted Chebyshev-T sum and Cartesian derivatives.

Legendre#

Legendre polynomials.

prysm.polynomials.legendre.legendre(n, x)#

Legendre polynomial of order n.

Parameters:
  • n (int) – order to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

Returns:

legendre polynomial evaluated at the given points

Return type:

ndarray

prysm.polynomials.legendre.legendre_seq(ns, x)#

Legendre polynomials of orders ns.

Faster than legendre in a loop.

Parameters:
  • ns (int) – orders to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.legendre.legendre_der(n, x)#

Partial derivative w.r.t. x of Legendre polynomial of order n.

Parameters:
  • n (int) – order to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

Returns:

d/dx of legendre polynomial evaluated at the given points

Return type:

ndarray

prysm.polynomials.legendre.legendre_der_seq(ns, x)#

Partial derivative w.r.t. x of Legendre polynomials of orders ns.

Faster than legendre_der in a loop.

Parameters:
  • ns (int) – orders to evaluate

  • x (ndarray) – point(s) at which to evaluate, orthogonal over [-1,1]

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

Hermite#

Hermite Polynomials.

He (Probabilist’s) and H (Physicist’s) Hermite polynomials share a single three-term recurrence parameterized by an integer kind:

kind = 1 => Probabilist’s He (Ax = x, C = n-1) kind = 2 => Physicist’s H (Ax = 2x, C = 2(n-1))

Equivalently, Ax = kind * x and C = kind * (n-1) for both families. The derivative also collapses to a single formula:

P’_n = kind * n * P_{n-1}

prysm.polynomials.hermite.hermite_He(n, x)#

Probabilist’s Hermite polynomial He_n at points x.

prysm.polynomials.hermite.hermite_He_seq(ns, x)#

Probabilist’s Hermite polynomials He_n at sorted orders ns and points x.

prysm.polynomials.hermite.hermite_He_der(n, x)#

First derivative of He_n at points x.

prysm.polynomials.hermite.hermite_He_der_seq(ns, x)#

First derivative of He_n at sorted orders ns and points x.

prysm.polynomials.hermite.hermite_H(n, x)#

Physicist’s Hermite polynomial H_n at points x.

prysm.polynomials.hermite.hermite_H_seq(ns, x)#

Physicist’s Hermite polynomials H_n at sorted orders ns and points x.

prysm.polynomials.hermite.hermite_H_der(n, x)#

First derivative of H_n at points x.

prysm.polynomials.hermite.hermite_H_der_seq(ns, x)#

First derivative of H_n at sorted orders ns and points x.

Dicksons#

Dickson Polynomials.

prysm.polynomials.dickson.dickson1(n, alpha, x)#

Dickson Polynomial of the first kind of order n.

Parameters:
  • n (int) – polynomial order

  • alpha (float) – shape parameter if alpha = -1, the dickson polynomials are Fibonacci Polynomials if alpha = 0, the dickson polynomials are the monomials x^n if alpha = 1, the dickson polynomials and cheby1 polynomials are related by D_n(2x) = 2T_n(x)

  • x (ndarray) – coordinates to evaluate the polynomial at

Returns:

D_n(x)

Return type:

ndarray

prysm.polynomials.dickson.dickson2(n, alpha, x)#

Dickson Polynomial of the second kind of order n.

Parameters:
  • n (int) – polynomial order

  • alpha (float) – shape parameter if alpha = -1, the dickson polynomials are Lucas Polynomials

  • x (ndarray) – coordinates to evaluate the polynomial at

Returns:

E_n(x)

Return type:

ndarray

prysm.polynomials.dickson.dickson1_seq(ns, alpha, x)#

Sequence of Dickson Polynomial of the first kind of orders ns.

Parameters:
  • ns (iterable of int) – rising polynomial orders, assumed to be sorted

  • alpha (float) – shape parameter if alpha = -1, the dickson polynomials are Fibonacci Polynomials if alpha = 0, the dickson polynomials are the monomials x^n if alpha = 1, the dickson polynomials and cheby1 polynomials are related by D_n(2x) = 2T_n(x)

  • x (ndarray) – coordinates to evaluate the polynomial at

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

prysm.polynomials.dickson.dickson1_der(n, alpha, x)#

Partial derivative w.r.t. x of the Dickson polynomial of the first kind of order n.

Uses the differentiated recurrence D’_n = D_{n-1} + x D’_{n-1} - alpha D’_{n-2} with D’_0 = 0, D’_1 = 1.

Parameters:
  • n (int) – polynomial order

  • alpha (float) – shape parameter (see dickson1)

  • x (ndarray) – coordinates to evaluate the derivative at

Returns:

d/dx D_n(x)

Return type:

ndarray

prysm.polynomials.dickson.dickson1_der_seq(ns, alpha, x)#

Partial derivative w.r.t. x of Dickson Polynomials of the first kind for orders ns.

Parameters:
  • ns (iterable of int) – rising polynomial orders, assumed to be sorted

  • alpha (float) – shape parameter (see dickson1)

  • x (ndarray) – coordinates to evaluate the derivative at

Returns:

has shape (len(ns),) followed by x.shape; the i-th plane is d/dx D_{ns[i]}(x)

Return type:

ndarray

prysm.polynomials.dickson.dickson2_der(n, alpha, x)#

Partial derivative w.r.t. x of the Dickson polynomial of the second kind of order n.

The recurrence for E_n and its derivative share the same coefficients as for D_n; only the n=0 seed differs (E_0 = 1 vs D_0 = 2), but E’_0 = D’_0 = 0.

Parameters:
  • n (int) – polynomial order

  • alpha (float) – shape parameter (see dickson2)

  • x (ndarray) – coordinates to evaluate the derivative at

Returns:

d/dx E_n(x)

Return type:

ndarray

prysm.polynomials.dickson.dickson2_der_seq(ns, alpha, x)#

Partial derivative w.r.t. x of Dickson Polynomials of the second kind for orders ns.

Parameters:
  • ns (iterable of int) – rising polynomial orders, assumed to be sorted

  • alpha (float) – shape parameter (see dickson2)

  • x (ndarray) – coordinates to evaluate the derivative at

Returns:

has shape (len(ns),) followed by x.shape; the i-th plane is d/dx E_{ns[i]}(x)

Return type:

ndarray

prysm.polynomials.dickson.dickson2_seq(ns, alpha, x)#

Sequence of Dickson Polynomial of the second kind of orders ns.

Parameters:
  • ns (iterable of int) – rising polynomial orders, assumed to be sorted

  • alpha (float) – shape parameter if alpha = -1, the dickson polynomials are Lucas Polynomials

  • x (ndarray) – coordinates to evaluate the polynomial at

Returns:

has shape (len(ns),) followed by x.shape e.g., for 5 modes and x of dimension 100x100, return has shape (5, 100, 100)

Return type:

ndarray

Laguerre#

Laguerre polynomials.

prysm.polynomials.laguerre.laguerre(n, alpha, x)#

Generalized Laguerre polynomial of order n.

Parameters:
  • n (int) – polynomial order

  • alpha (float) – shaping parameter

  • x (numpy.ndarray) – coordinates to evaluate at; the laguerre polynomials are orthogonal on the interval [0,inf)

Returns:

generalized laguerre polynomial evaluated at the given points

Return type:

numpy.ndarray

prysm.polynomials.laguerre.laguerre_seq(ns, alpha, x)#

Generalized Laguerre polynomial of orders ns.

Parameters:
  • ns (sequence) – polynomial orders, ascending order

  • alpha (float) – shaping parameter

  • x (numpy.ndarray) – coordinates to evaluate at; the laguerre polynomials are orthogonal on the interval [0,inf)

Returns:

shape (k, len(x)) generalized laguerre polynomials evaluated at the given points

Return type:

numpy.ndarray

prysm.polynomials.laguerre.laguerre_der(n, alpha, x)#

d/dx of Laguerre polynomial of order n.

Parameters:
  • n (int) – polynomial order

  • alpha (float) – shaping parameter

  • x (numpy.ndarray) – coordinates to evaluate at; the laguerre polynomials are orthogonal on the interval [0,inf)

Returns:

d/dx of generalized laguerre polynomial evaluated at the given points

Return type:

numpy.ndarray

prysm.polynomials.laguerre.laguerre_der_seq(ns, alpha, x)#

d/dx of Generalized Laguerre polynomial of orders ns.

Parameters:
  • ns (sequence) – polynomial orders, ascending order

  • alpha (float) – shaping parameter

  • x (numpy.ndarray) – coordinates to evaluate at; the laguerre polynomials are orthogonal on the interval [0,inf)

Returns:

shape (k, len(x)) d/dx of generalized laguerre polynomials evaluated at the given points

Return type:

numpy.ndarray