# Least Square fit with Double Zernike Polynomials

I need to describe the optical aberrations of my set-up with Zernike polynomials. To do this, I want to fit the first 15 polynomials in the following way on my data:

$$\chi^2 = \sum_k\left(\beta_k^x - \sum_{n=2}^M C_n\frac{\partial P_n}{\partial x}\right)^2 + \sum_k\left(\beta_k^y - \sum_{n=2}^M C_n\frac{\partial P_n}{\partial y}\right)^2$$ where $\beta_x$ and $\beta_y$ are my data, $P_n$ are the Zernike polynomials, and $C_n$ are the coefficients. Because the coefficients $C_n$ for both the $x$ and $y$ derivative of the polynomial needs to be the same, I do not think I can use a normal polynomial least square. I need to do this in Labwindows/CVI.

Does anyone have an idea how to approach this problem?

If I read this correctly, you can rewrite your problem as an ordinary least square problem $\left\|Ax-b\right\|$, where A is the stacked Vandermonde-Matrix of the derivatives of the Zernike polynomials and $b$ the stacked measured data.
$$\chi^2 =\left \|\begin{pmatrix} \frac{\partial P_n}{\partial x}\\ \frac{\partial P_n}{\partial y} \end{pmatrix}C-\begin{pmatrix}\beta^x\\\beta^y\end{pmatrix}\right\|^2$$