I'm using this code to decompose a wave aberration function. I'm experiencing a problem with the decomposition. Why if I try to expand a function like
F = A*r^4
where A is constant, I get 2 non-negative coefficients: not only the coefficient corresponding to spherical aberrations but also that one who correspond to Field Curvature ?!?!
thanks

This is an extraordinarily slow way of fitting Zernike coefficients. See "Wavefront fitting with discrete orthogonal polynomials in a unit radius circle" by Malacara, et al, in Optical Engineering, Vol 29, No 6, pages 672-675 for a much more efficient, least-squares approach. You can speed the decomposition up significantly by using linear algebra functions rather than interp2() and dblquad().