# Zernike polynomials

The first 15 Zernike polynomials, ordered vertically by radial degree and horizontally by azimuthal degree

In mathematics, the Zernike polynomials are a sequence of polynomials that are orthogonal on the unit disk. Named after optical physicist Frits Zernike, winner of the 1953 Nobel Prize in Physics, and the inventor of phase contrast microscopy, they play an important role in beam optics.[1][2]

## Definitions

There are even and odd Zernike polynomials. The even ones are defined as

$Z^{m}_n(\rho,\varphi) = R^m_n(\rho)\,\cos(m\,\varphi) \!$

and the odd ones as

$Z^{-m}_n(\rho,\varphi) = R^m_n(\rho)\,\sin(m\,\varphi), \!$

where m and n are nonnegative integers with n ≥ m, φ is the azimuthal angle, ρ is the radial distance $0\le\rho\le 1$, and Rmn are the radial polynomials defined below. Zernike polynomials have the property of being limited to a range of −1 to +1, i.e. $|Z^{m}_n(\rho,\varphi)| \le 1$. The radial polynomials Rmn are defined as

$R^m_n(\rho) = \sum_{k=0}^{\tfrac{n-m}{2}} \frac{(-1)^k\,(n-k)!}{k!\left (\tfrac{n+m}{2}-k \right )! \left (\tfrac{n-m}{2}-k \right)!} \;\rho^{n-2\,k}$

for nm even, and are identically 0 for nm odd.

### Other representations

Rewriting the ratios of factorials in the radial part as products of binomials shows that the coefficients are integer numbers:

$R_n^m(\rho)=\sum_{k=0}^{\tfrac{n-m}{2}}(-1)^k \binom{n-k}{k} \binom{n-2k}{\tfrac{n-m}{2}-k} \rho^{n-2k}$.

A notation as terminating Gaussian hypergeometric functions is useful to reveal recurrences, to demonstrate that they are special cases of Jacobi polynomials, to write down the differential equations, etc.:

\begin{align} R_n^m(\rho) &= \binom{n}{\tfrac{n+m}{2}}\rho^n \ {}_2F_{1}\left(-\tfrac{n+m}{2},-\tfrac{n-m}{2};-n;\rho^{-2}\right) \\ &= (-1)^{\tfrac{n+m}{2}}\binom{\tfrac{n+m}{2}}{\tfrac{n-m}{2}}\rho^m \ {}_2F_{1}\left(1+n,1-\tfrac{n-m}{2};1+\tfrac{n+m}{2};\rho^2\right) \end{align}

for nm even.

The Zernike polynomials also satisfy the following recurrence relation depends neither on the degree nor on the azimuthal order of the radial polynomials.[3]

\begin{align} R_n^m(\rho)+R_{n-2}^m(\rho)=\rho\left[R_{n-1}^{\left|m-1\right|}(\rho)+R_{n-1}^{m+1}(\rho)\right] \end{align}

### Noll's sequential indices

Applications often involve linear algebra, where integrals over products of Zernike polynomials and some other factor build the matrix elements. To enumerate the rows and columns of these matrices by a single index, a conventional mapping of the two indices n and m to a single index j has been introduced by Noll.[4] The table of this association $Z_n^m \rightarrow Z_j$ starts as follows (sequence A176988 in OEIS)

 n,m j n,m j 0,0 1,1 1,−1 2,0 2,−2 2,2 3,−1 3,1 3,−3 3,3 1 2 3 4 5 6 7 8 9 10 4,0 4,2 4,−2 4,4 4,−4 5,1 5,−1 5,3 5,−3 5,5 11 12 13 14 15 16 17 18 19 20

The rule is that the even Z (with even azimuthal part m, $\cos(m\varphi)$) obtain even indices j, the odd Z odd indices j. Within a given n, lower values of m obtain lower j.

## Properties

### Orthogonality

The orthogonality in the radial part reads

$\int_0^1 \rho \sqrt{2n+2}R_n^m(\rho)\,\sqrt{2n'+2}R_{n'}^{m}(\rho)\,d\rho = \delta_{n,n'}.$

Orthogonality in the angular part is represented by

$\int_0^{2\pi} \cos(m\varphi)\cos(m'\varphi)\,d\varphi=\epsilon_m\pi\delta_{|m|,|m'|},$
$\int_0^{2\pi} \sin(m\varphi)\sin(m'\varphi)\,d\varphi=(-1)^{m+m'}\pi\delta_{|m|,|m'|};\quad m\neq 0,$
$\int_0^{2\pi} \cos(m\varphi)\sin(m'\varphi)\,d\varphi=0,$

where $\epsilon_m$ (sometimes called the Neumann factor because it frequently appears in conjunction with Bessel functions) is defined as 2 if $m=0$ and 1 if $m\neq 0$. The product of the angular and radial parts establishes the orthogonality of the Zernike functions with respect to both indices if integrated over the unit disk,

$\int Z_n^m(\rho,\varphi)Z_{n'}^{m'}(\rho,\varphi) \, d^2r =\frac{\epsilon_m\pi}{2n+2}\delta_{n,n'}\delta_{m,m'},$

where $d^2r=\rho\,d\rho\,d\varphi$ is the Jacobian of the circular coordinate system, and where $n-m$ and $n'-m'$ are both even.

A special value is

$R_n^m(1)=1, \,$

### Zernike transform

Any sufficiently smooth real-valued phase field over the unit disk $G(\rho,\varphi)$ can be represented in terms of its Zernike coefficients (odd and even), just as periodic functions find an orthogonal representation with the Fourier series. We have

$G(\rho,\varphi) = \sum_{m,n}\left[ a_{m,n} Z^{m}_n(\rho,\varphi) + b_{m,n} Z^{-m}_n(\rho,\varphi) \right],$

where the coefficients can be calculated using inner products. On the space of $L^2$ functions on the unit disk, there is an inner product defined by

$\langle F, G \rangle := \int F(\rho,\varphi)G(\rho,\varphi)\rho d\rho d\varphi.$

The Zernike coefficients can then be expressed as follows:

\begin{align} a_{m,n} &= \frac{2n+2}{\epsilon_m\pi} \left \langle G(\rho,\varphi),Z^{m}_n(\rho,\varphi) \right \rangle, \\ b_{m,n} &= \frac{2n+2}{\epsilon_m\pi} \left \langle G(\rho,\varphi),Z^{-m}_n(\rho,\varphi) \right \rangle. \end{align}

Alternatively, one can use the known values of phase function G on the circular grid to form a system of equations. The phase function is retrieved by the unknown-coefficient weighted product with (known values) of Zernike polynomial across the unit grid. Hence, coefficients can also be found by solving linear system, for instance by matrix inversion. Fast algorithms to calculate the forward and inverse Zernike transform use symmetry properties of trigonometric functions, separability of radial and azimuthal parts of Zernike polynomials, and their rotational symmetries.

### Symmetries

The parity with respect to reflection along the x axis is

$Z_n^{m}(\rho,\varphi)=(-1)^m Z_n^{m}(\rho,-\varphi).$

The parity with respect to point reflection at the center of coordinates is

$Z_n^m(\rho,\varphi) = (-1)^m Z_n^m(\rho,\varphi+\pi),$

where $(-1)^m$ could as well be written $(-1)^n$ because $n-m$ is even for the relevant, non-vanishing values. The radial polynomials are also either even or odd, depending on order n or m:

$R_n^m(\rho)=(-1)^n R_n^m(-\rho)=(-1)^m R_n^m(-\rho).$

The periodicity of the trigonometric functions implies invariance if rotated by multiples of $2\pi/m$ radian around the center:

$Z_n^m \left (\rho, \varphi+ \tfrac{2\pi k}{m} \right )=Z_n^m(\rho,\varphi),\qquad k= 0, \pm 1,\pm 2,\cdots.$

## Examples

The first few radial polynomials are:

$R^0_0(\rho) = 1 \,$
$R^1_1(\rho) = \rho \,$
$R^0_2(\rho) = 2\rho^2 - 1 \,$
$R^2_2(\rho) = \rho^2 \,$
$R^1_3(\rho) = 3\rho^3 - 2\rho \,$
$R^3_3(\rho) = \rho^3 \,$
$R^0_4(\rho) = 6\rho^4 - 6\rho^2 + 1 \,$
$R^2_4(\rho) = 4\rho^4 - 3\rho^2 \,$
$R^4_4(\rho) = \rho^4 \,$
$R^1_5(\rho) = 10\rho^5 - 12\rho^3 + 3\rho \,$
$R^3_5(\rho) = 5\rho^5 - 4\rho^3 \,$
$R^5_5(\rho) = \rho^5 \,$
$R^0_6(\rho) = 20\rho^6 - 30\rho^4 + 12\rho^2 - 1 \,$
$R^2_6(\rho) = 15\rho^6 - 20\rho^4 + 6\rho^2 \,$
$R^4_6(\rho) = 6\rho^6 - 5\rho^4 \,$
$R^6_6(\rho) = \rho^6. \,$

### Zernike polynomials

The first few Zernike modes, ordered by Noll index $j$ are[4] shown below. They are normalized such that

$\int_0^{2\pi} \int_0^1 Z_j^2\,\rho\,d\rho\,d\theta = \pi.$
Noll index ($j$) Radial degree ($n$) Azimuthal degree ($m$) $Z_j$ Classical name
1 0 0 $1$ Piston
2 1 1 $2 \rho \cos \theta$ Tip (lateral position) (X-Tilt)
3 1 −1 $2 \rho \sin \theta$ Tilt (lateral position) (Y-Tilt)
4 2 0 $\sqrt{3} (2 \rho^2 - 1)$ Defocus (longitudinal position)
5 2 −2 $\sqrt{6} \rho^2 \sin 2 \theta$ Astigmatism
6 2 2 $\sqrt{6} \rho^2 \cos 2 \theta$ Astigmatism
7 3 −1 $\sqrt{8} (3 \rho^3 - 2\rho) \sin \theta$ Coma
8 3 1 $\sqrt{8} (3 \rho^3 - 2\rho) \cos \theta$ Coma
9 3 −3 $\sqrt{8} \rho^3 \sin 3 \theta$ Trefoil
10 3 3 $\sqrt{8} \rho^3 \cos 3 \theta$ Trefoil
11 4 0 $\sqrt{5} (6 \rho^4 - 6 \rho^2 +1)$ Third-order spherical
12 4 2 $\sqrt{10} (4 \rho^4 - 3\rho^2) \cos 2 \theta$
13 4 −2 $\sqrt{10} (4 \rho^4 - 3\rho^2) \sin 2 \theta$
14 4 4 $\sqrt{10} \rho^4 \cos 4 \theta$
15 4 −4 $\sqrt{10} \rho^4 \sin 4 \theta$

## Applications

The functions are a basis defined over the circular support area, typically the pupil planes in classical optical imaging at visible and infrared wavelengths through systems of lenses and mirrors of finite diameter. Their advantages are the simple analytical properties inherited from the simplicity of the radial functions and the factorization in radial and azimuthal functions; this leads, for example, to closed form expressions of the two-dimensional Fourier transform in terms of Bessel functions. Their disadvantage, in particular if high n are involved, is the unequal distribution of nodal lines over the unit disk, which introduces ringing effects near the perimeter $\rho\approx 1$, which often leads attempts to define other orthogonal functions over the circular disk.

In precision optical manufacturing, Zernike polynomials are used to characterize higher-order errors observed in interferometric analyses, in order to achieve desired system performance.

In optometry and ophthalmology, Zernike polynomials are used to describe aberrations of the cornea or lens from an ideal spherical shape, which result in refraction errors.

They are commonly used in adaptive optics where they can be used to effectively cancel out atmospheric distortion. Obvious applications for this are IR or visual astronomy and satellite imagery. For example, one of the Zernike terms (for m = 0, n = 2) is called 'de-focus'. By coupling the output from this term to a control system, an automatic focus can be implemented.

Another application of the Zernike polynomials is found in the Extended Nijboer-Zernike (ENZ) theory of diffraction and aberrations.

Zernike polynomials are widely used as basis functions of image moments. Since Zernike polynomials are orthogonal to each other, Zernike moments can represent properties of an image with no redundancy or overlap of information between the moments. Although Zernike moments are significantly dependent on the scaling and the translation of the object in a region of interest (ROI), their magnitudes are independent of the rotation angle of the object.[5] Thus, they can be utilized to extract features from images that describe the shape characteristics of an object. For instance, Zernike moments are utilized as shape descriptors to classify benign and malignant breast masses.[6][7]

## Higher dimensions

The concept translates to higher dimensions D if multinomials $x_1^ix_2^j\cdots x_D^k$ in Cartesian coordinates are converted to hyperspherical coordinates, $\rho^s, s\le D$, multiplied by a product of Jacobi polynomials of the angular variables. In $D=3$ dimensions, the angular variables are spherical harmonics, for example. Linear combinations of the powers $\rho^s$ define an orthogonal basis $R_n^{(l)}(\rho)$ satisfying

$\int_0^1 \rho^{D-1}R_n^{(l)}(\rho)R_{n'}^{(l)}(\rho)d\rho = \delta_{n,n'}$.

(Note that a factor $\sqrt{2n+D}$ is absorbed in the definition of R here, whereas in $D=2$ the normalization is chosen slightly differently. This is largely a matter of taste, depending on whether one wishes to maintain an integer set of coefficients or prefers tighter formulas if the orthogonalization is involved.) The explicit representation is

\begin{align} R_n^{(l)}(\rho) &= \sqrt{2n+D}\sum_{s=0}^{\tfrac{n-l}{2}} (-1)^s {\tfrac{n-l}{2} \choose s}{n-s-1+\tfrac{D}{2} \choose \tfrac{n-l}{2}}\rho^{n-2s} \\ &=(-1)^{\tfrac{n-l}{2}} \sqrt{2n+D} \sum_{s=0}^{\tfrac{n-l}{2}} (-1)^s {\tfrac{n-l}{2} \choose s} {s-1+\tfrac{n+l+D}{2} \choose \tfrac{n-l}{2}} \rho^{2s+l} \\ &=(-1)^{\tfrac{n-l}{2}} \sqrt{2n+D} {\tfrac{n+l+D}{2}-1 \choose \tfrac{n-l}{2}} \rho^l \ {}_2F_1 \left ( -\tfrac{n-l}{2},\tfrac{n+l+D}{2}; l+\tfrac{D}{2}; \rho^2 \right ) \end{align}

for even $n-l\ge 0$, else identical to zero.