Derivatives

Zernike.derivatives(Z::Polynomial, order::Int = 1) computes the nth order partial derivatives of Z(ρ, θ) and returns the two-tuple (∂Z/∂ρ, ∂Z/∂θ) containing the Derivative types.

Zernike.Gradient(Z::Polynomial) wraps the first-order partial derivatives and returns a callable ∇Z(ρ, θ).

The partials and gradient are also functors which can be evaluated over the pupil. In addition, partial derivatives can easily be plotted by simply calling them with no arguments and their Unicode representation extracted by calling them with the String type.

julia> ∂ρ, ∂θ = Zernike.derivatives(Z(4, 4));

julia> ∂ρ(); # plots it over the pupil when not suppressed

julia> ∂ρ(String)
"√(10)4ρ³cos(4θ)"

If the expansion coefficients of the derivatives are desired instead there are several methods available:

Zernike.grad(Z::Polynomial) and Zernike.lap(Z::Polynomial).

In addition, the gradient of a Wavefront can be computed with ∇(W); this del operator / nabla symbol is an alias for grad.

The W(∂x, ∂y) method accepts the gradient of a wavefront in a Zernike basis (e.g. the estimated Zernike expansion coefficients of the transverse aberration components from normalized Shack-Hartmann sensor data) and returns the expansion coefficients of the original wavefront error. The inputs must be in the format of 64-bit floating point vectors representing the normalized Zernike polyomial weights.

The three algorithms which compute the expansion coefficients of the gradient, the laplacian, and the original wavefront error from the gradient are based on formulas in Janssen (2014).