ZERNIPAX: A Fast and Accurate Zernike Polynomial Calculator in Python
Yigit Gunsur Elmacioglu, Rory Conlin, Daniel W. Dudt, Dario Panici, Egemen Kolemen
TL;DR
This work introduces ZERNIPAX, a fast and accurate Python package for evaluating Zernike polynomials on the unit disk by harnessing Jacobi polynomials and their stable recursion. Implemented with JAX, it provides CPU and GPU pathways that dramatically reduce computation time while maintaining high numerical accuracy, especially for high-order modes. The approach explicitly addresses numerical stability issues inherent in direct evaluation and leverages automatic differentiation for integration with optimization workflows. The results demonstrate substantial speedups over existing open-source tools and enable real-time or optimization-driven applications in optics, astrophysics, and plasma physics. The release emphasizes open-source availability and practicality for high-fidelity simulations across diverse scientific domains.
Abstract
Zernike polynomials serve as an orthogonal basis on the unit disc, and have proven to be effective in optics simulations, astrophysics, and more recently in plasma simulations. Unlike Bessel functions, Zernike polynomials are inherently finite and smooth at the disc center (r=0), ensuring continuous differentiability along the axis. This property makes them particularly suitable for simulations, requiring no additional handling at the origin. We developed ZERNIPAX, an open-source Python package capable of utilizing CPU/GPUs, leveraging Google's JAX package and available on GitHub as well as the Python software repository PyPI. Our implementation of the recursion relation between Jacobi polynomials significantly improves computation time compared to alternative methods by use of parallel computing while still performing more accurately for high-mode numbers.
