Definition and conventions#

Definition of the Zernike polynomials#

The Zernike polynomials [Zernike1934] \(Z_{n}^{m}(\rho, \theta)\) are defined on the unit disk \((0 \leq \rho \leq 1, \theta)\) for a radial order \(n \geq 0\) and an azimuthal frequency \(m\) with \(|m| \leq n\) and \(n - m\) even:

\[\begin{split}Z_{n}^{m}(\rho, \theta) = \begin{cases} R_{n}^{m}(\rho) \cos(m \theta) & \text{if } m \geq 0 \\ R_{n}^{|m|}(\rho) \sin(|m| \theta) & \text{if } m < 0 \end{cases}\end{split}\]

where \(R_{n}^{m}\) is the radial polynomial (\(m \geq 0\)):

\[R_{n}^{m}(\rho) = \sum_{k=0}^{(n-m)/2} \frac{(-1)^k (n-k)!}{k! \left(\frac{n+m}{2} - k\right)! \left(\frac{n-m}{2} - k\right)!} \rho^{n-2k}\]

The radial polynomials satisfy \(R_{n}^{m}(1) = 1\), and \(R_{n}^{m}(\rho) = \rho^{m} P(\rho^2)\) with \(P\) a polynomial of degree \(\frac{n-m}{2}\). The Zernike polynomials are therefore polynomials of degree \(n\) in the Cartesian coordinates \((\rho \cos\theta, \rho \sin\theta)\).

Note

If \(|m| > n\) or \(n - m\) is odd, the polynomial is set to zero. A negative order \(n\) is an error.

The sign convention for \(m < 0\) (the sine term is \(+\sin(|m|\theta)\)) is the one of the OSA/ANSI standard Z80.28 [Thibos2002]. Some authors use \(-\sin(m\theta)\) with \(m < 0\), which is the same function, or associate the sine with \(m > 0\), which changes the sign or the role of some polynomials: the conventions of a set of coefficients must always be checked.

Indexing conventions#

A single index \(j\) is often used instead of the pair \((n, m)\). Three orderings are available with the argument indexing of pyzernike.zernike_index_to_order() and pyzernike.zernike_order_to_index(), and all the functions working on vectors of coefficients use the OSA/ANSI ordering.

OSA/ANSI (first index 0) [Thibos2002]: the polynomials are sorted by radial order \(n\), then by azimuthal frequency \(m\) from \(-n\) to \(n\):

\[j = \frac{n(n + 2) + m}{2}\]

Noll (first index 1) [Noll1976]: the polynomials are sorted by radial order \(n\), then by \(|m|\). The even indices are given to the cosine terms (\(m > 0\)) and the odd indices to the sine terms (\(m < 0\)):

\[\begin{split}j = \frac{n(n + 1)}{2} + |m| + s \quad \text{with} \quad s = \begin{cases} 0 & \text{if } m > 0 \text{ and } n \bmod 4 \in \{0, 1\}, \text{ or } m < 0 \text{ and } n \bmod 4 \in \{2, 3\} \\ 1 & \text{otherwise} \end{cases}\end{split}\]

Fringe (first index 1), also called University of Arizona ordering: the polynomials are sorted by \(\frac{n + |m|}{2}\), then by decreasing \(|m|\), the cosine term before the sine term:

\[\begin{split}j = \left(1 + \frac{n + |m|}{2}\right)^2 - 2|m| + \begin{cases} 1 & \text{if } m < 0 \\ 0 & \text{otherwise} \end{cases}\end{split}\]

The OSA/ANSI and Noll orderings contain exactly all the polynomials up to the order \(N\) in their first \(P = \frac{(N+1)(N+2)}{2}\) indices. The Fringe ordering is not sorted by radial order: for example, \(Z_{4}^{0}\) (index 9) comes before \(Z_{3}^{3}\) (index 10).

The first polynomials in the three orderings#

\((n, m)\)

OSA/ANSI

Noll

Fringe

Name

\((0, 0)\)

0

1

1

Piston

\((1, -1)\)

1

3

3

Tilt (vertical)

\((1, 1)\)

2

2

2

Tilt (horizontal)

\((2, -2)\)

3

5

6

Oblique astigmatism

\((2, 0)\)

4

4

4

Defocus

\((2, 2)\)

5

6

5

Vertical astigmatism

\((3, -3)\)

6

9

11

Vertical trefoil

\((3, -1)\)

7

7

8

Vertical coma

\((3, 1)\)

8

8

7

Horizontal coma

\((3, 3)\)

9

10

10

Oblique trefoil

\((4, 0)\)

12

11

9

Primary spherical aberration

Vectors of coefficients are converted between the orderings with pyzernike.zernike_coefficients_convert() (see Coefficients of a sum of polynomials).

Normalization and orthogonality#

The Zernike polynomials are orthogonal on the unit disk. With the inner product averaged over the disk:

\[\langle f, g \rangle = \frac{1}{\pi} \int_{0}^{2\pi} \int_{0}^{1} f(\rho, \theta) \, g(\rho, \theta) \, \rho \, d\rho \, d\theta\]

they satisfy:

\[\begin{split}\langle Z_{n}^{m}, Z_{n'}^{m'} \rangle = \frac{\delta_{nn'} \delta_{mm'}}{\left(N_{n}^{m}\right)^2} \quad \text{with} \quad N_{n}^{m} = \sqrt{(2 - \delta_{m0})(n + 1)} = \begin{cases} \sqrt{n + 1} & \text{if } m = 0 \\ \sqrt{2(n + 1)} & \text{if } m \neq 0 \end{cases}\end{split}\]

The factors \(N_{n}^{m}\) are the normalization factors of Noll [Noll1976], given by pyzernike.zernike_normalization(). The normalized polynomials \(N_{n}^{m} Z_{n}^{m}\) are orthonormal, and are computed by all the functions with the argument normalize=True. By default (normalize=False), the polynomials are not normalized, so that \(R_{n}^{m}(1) = 1\).

The normalization has two practical consequences for a function \(f = \sum_j c_j Z_j\):

  • The coefficients depend on the normalization: \(c_j Z_j = c'_j (N_j Z_j)\), so \(c'_j = c_j / N_j\).

  • Only the piston \(Z_0^0 = 1\) has a non-zero mean, so the variance of \(f\) on the disk is \(\sigma^2 = \sum_{j > 0} c_j^2 / N_j^2\), i.e. \(\sum_{j > 0} c_j^2\) for the normalized polynomials (see pyzernike.zernike_rms()).

Note

The normalization factors are defined for the full Zernike polynomials only: the radial polynomials (pyzernike.radial_polynomial()) are never normalized.