# Optical Pupil Shift Correction Method for Large Ground-Based Optical Telescopes
## 3 Calculation of Optical Pupil Shift and Active Compensation
### Nonlinear Least-Squares Fitting to Calculate Secondary Mirror Position  
The determination of the current position of the secondary mirror is crucial to the compensation process. In the telescope system model, the position of the secondary mirror is represented as several discrete nodes on its surface. Least-squares fitting was employed to obtain the best-fit quadratic surface formed by the discrete nodes on the mirror surface, the origin of which is the current position of the secondary mirror. The process of fitting is as follows.  
In the geometric model, we assumed \(n\) number of \(a\) vectors, each of which corresponds to \(m\) measurements of \(Y\). The expression relation is expressed as  
\[Y=F(a)+q, \tag{4}\]  
where \(F\) is the continuous differentiable function of vectors \(a\) and \(q\) is the error vector.  
For given secondary mirror surface measurements \(Y\), the nonlinear least-squares fitting expression for \(a\) is  
\[\text{min}q^{T}q=\big{[}Y-F(a)\big{]}^{T}\big{[}Y-F(a)\big{]}, \tag{5}\]  
Figure 6: The process of optical pupil shift compensation.  
[PERSON]'s method was used to solve these nonlinear estimates in the following iterative format.  
\[\left.\frac{\partial F}{\partial a}\right|_{a_{k}}=Y-F(a_{k}), \tag{6}\]  
\[a_{k+1}=a_{k}+\lambda\Delta a, \tag{7}\]  
where the expression on the left-hand side is the Jacobi matrix.  
\[J_{mn}=\frac{\partial E_{m}}{\partial a_{n}}, \tag{8}\]  
To solve this problem, the pointing vector \(F\) at the nearest point of the surface sampling points toward the ideal surface, and its partial derivative matrix value, which is the input condition for the nonlinear fit, was calculated.  
A schematic of the quadratic surface in three-dimensional space is illustrated in Equation (8). The best-fit spherical center position is \(Y_{c}\) and the best-fit radius is \(R\), which can be expressed by the following equation:  
\[\|Y-Y_{c}\|^{2}-Q=R^{2}, \tag{9}\]  
where \(Q\) is the second-order surface fitting error. In this study, the second-order surface coefficient of the secondary mirror was \(-1.054\) and the curvature was \(1030\) mm. The primary and secondary mirror spacing were up to \(5600\) mm; on this basis, the secondary surface fitting error is negligible; therefore, Equation (9) can be simplified as  
\[\|Y-Y_{c}\|^{2}=R^{2}, \tag{10}\]  
For each sampling point \(Y_{i}\), the quadratic surface with its corresponding point \(Y_{i}^{\prime}\) is expressed as  
\[Y_{i}^{\prime}=Y_{i}+R\frac{Y_{i}-Y_{c}}{\|Y_{i}-Y_{c}\|},i=1,2,\cdots,m, \tag{11}\]  
The deviation of the sampling point \(Y_{i}\) from its counterpart \(Y_{i}^{\prime}\) is expressed as  
\[Y_{i}^{{}^{\prime\prime}}=Y_{i}-Y_{i}^{\prime}=\big{[}\|Y_{i}-Y_{c}\|-R\big{]} \frac{Y_{i}-Y_{c}}{\|Y_{i}-Y_{c}\|}, \tag{12}\]  
The expression for the Jacobi matrix by [PERSON]'s method from the expression of \(Y_{i}^{\prime}\) is  
\[J=\frac{\partial}{\partial}\bigg{[}Y_{c}+R\frac{Y_{i}-Y_{c}}{\|Y_{i}-Y_{c}\|} \bigg{]}, \tag{13}\]  
From these expressions and initial data, the aspheric-fitted linear equation system expression for the secondary mirror is expressed as  
\[\begin{bmatrix}J_{X_{1}^{\prime},R}&J_{X_{1}^{\prime},X_{C}}&J_{X_{1}^{\prime },Y_{C}}&J_{X_{1}^{\prime},Z_{C}}\\ J_{Y_{1}^{\prime},R}&J_{Y_{1}^{\prime},X_{C}}&J_{Y_{1}^{\prime},Y_{C}}&J_{Y_{1} ^{\  
\[R=\sqrt{\frac{1}{n}\sum_{i=1}^{n}\left|Y_{i}-\overline{Y_{i}}\right|^{2}}, \tag{16}\]