Hi:

I have written a function that could be incorporated to the
optics package. This new function calculates the Zernike
polynomials and their partial derivatives in Cartesian
coordinates, using a recursive algorithm described in reference
[1].

I'm sending an attachment with three files:

- zernikes_and_derivatives_cartesian_OSA.m, it is the main
function
- zernike_osa_ansi_to_mn.m, it's a small function needed by the
main function. It is similar to zernike_noll_to_mn.m, part of
package optics, but for "OSA/ANSI standard indices" instead of
"Noll's sequential indices".
- Zernikes_cartesian_OSA.pdf, where the recurrence relations are
explained, as well as the modifications to these relations that
I have made to accommodate the standard OSA. I wrote this file
for those who want to understand the algorithm used.

It's the first time I've sent anything, so it's possible there
was some loose end left.

The main function has been checked by comparing it with the
explicit expressions of the Zernike polynomials, and their partial
derivatives, and the results obtained are coherent. I.e. the
differences are either zero or very small, in the order of 1e-14.

I also compared my function with zernike_cartesian.m, a function of
the optics package written by Andreas Weber. The differences are
either zero or very small. To my disappointment, the average
execution times are similar. So the main improvement that introduces
my function is the calculation of partial derivatives.

[1] Andersen T.B., Efficient and robust recurrence relations for
the Zernike circle polynomials and their

derivatives in Cartesian coordinates. Optic Express 26 (15),
18878-18896 (2018).

Surely yours

JosÃ© Ramom