Zernike polynomials are often used to describe optical aberrations in a circular pupil. To aid working with these polynomials, I released ZernikePolynomials.jl. This Julia package has three purposes:

- Helping with conversion of the indices used to describe the polynomials into different sequential orderings;
- Generating these polynomials as functions and evaluating them;
- Estimating the coefficients from data when an optical aberration can be described as a linear combination of these polynomials.

I’ve plotted the first 21 Zernike polynomials below together with the tuple of integers that specify them.

## Package functions

There are several ways to label the polynomials (see the Wikipedia page). The following ways are supported:

- a tuple of integers ,
- a sequential index called Noll’s index,
- the sequential OSA/ANSI index.

The standard way is to use the tuple . When a sequential index is provided to a function, this package defaults to the OSA/ANSI indexing.

The conversion functions are:

`mn2OSA`

,`OSA2mn`

`mn2Noll`

,`Noll2mn`

`Noll2OSA`

,`OSA2NOll`

By default the polynomials are normalized according to (Thibos, Applegate, Schwiegerling, & Webb, 2002).
The normalization constants can be obtained with the function `normalization(m,n)`

. Note that the Wikipedia page uses a different normalization.

A specific polynomial can be obtained as a function using `Zernike()`

. The returned function can be evaluated on polar coordinates or cartesian coordinates depending on the keyword argument `coord`

supplied to `Zernike`

(defaults to polar coordinates). See `?Zernike`

for further documentation.

The Zernike polynomials can easily be evaluated on a grid using the function `evaluateZernike`

by supplying a range of x coordinates (the polynomial is evaluated on a square grid), a vector of indices (OSA indices by default) of the polynomials and a vector of coefficients. See `?evaluateZernike`

for further documentation.

Given a (measured or estimated) phase, the function `Zernikecoefficients`

can be used to estimate the optimal coefficients in a least squares sense of the weighted sum of Zernike polynomials that optimally approximate this phase. See `?Zernikecoefficients`

for further documentation.

## Further documentation

Documentation can be found using `?functionname`

in the Julia REPL and over at the GitHub repository page.

## Bibliography

- Thibos, L. N., Applegate, R. A., Schwiegerling, J. T., & Webb, R. (2002). Standards for reporting the optical aberrations of eyes.
*Journal of Refractive Surgery*,*18*(5), S652–S660.