# Synthesis of Four-Link Initial Kinematic Chains with Spherical Pairs for Spatial Mechanisms
## 3 Algorithm and Methodology  
The method is an iterative optimization algorithm for solving the system of equations related to the coordinates and distances in the context of the kinematic chain problem. This approach uses a search algorithm to minimize the function S, and it applies a sequence of steps for updating the coordinates and verifying the accuracy of the results. Let us break down the algorithm step by step:  
1. Initial reference points: we start by giving arbitrary initial points \(B^{(0)}\in Q_{1}\) and \(C^{(0)}\in Q_{2}\) as the starting guess for the positions of points \(B\) and \(C\). 2. Solve for \(A\) and \(R_{1}\): using the initial points \(B^{(0)}\) and \(C^{(0)}\), we solve the system of linear equations to determine the coordinates \(X_{A}^{(1)}\), \(Y_{A}^{(1)}\), \(Z_{A}^{(1)}\) and the radius \(R_{1}^{(1)}\). 3. Update point \(A\): now, set the updated point \(A^{(1)}\in Q\) (the reference frame for solid \(Q\)) and use the initial \(C^{(0)}\in Q_{2}\) to continue the iteration. 4. Solve for \(B\) and \(R_{2}\): using the updated point \(A^{(1)}\) and the initial point \(C^{(0)}\), we solve the system of equations to determine the updated coordinates \(x_{B}^{(1)}\), \(y_{B}^{(1)}\), \(z_{B}^{(1)}\) and the radius \(R_{2}^{(1)}\). 5. Update point \(B\): set the updated point \(B^{(1)}\in Q_{1}\), then continue the iteration with the updated reference frame. 6. Solve for \(C\) and \(R_{3}\): using the updated point \(A^{(1)}\) and \(B^{(1)}\), we solve the system of equations to determine the updated coordinates \(x_{C}^{(1)}\), \(y_{C}^{(1)}\), \(z_{C}^{(1)}\) and the radius \(R_{3}^{(1)}\). 7. Check the convergence condition: we then check if the difference between the updated and previous values of \(X_{A}\), \(Y_{A}\), \(Z_{A}\), and \(R\) meets the convergence criteria: \(\left|X_{A}^{i+1}-X_{A}^{i}\right|\leq\varepsilon\), \(\left|Y_{A}^{i+1}-Y_{A}^{i}\right|\leq\varepsilon\), \(\left|Z_{A}^{i+1}-Z_{A}^{i}\right|\leq\varepsilon\), \(\left|R^{i+1}-R^{i}\right|\leq\varepsilon\), where \(\varepsilon=10^{-4}\) is the specified accuracy. If these conditions are satisfied, the iterative process is considered complete. If the convergence condition is met (i.e., the changes are within the tolerance \(\varepsilon\)), the iteration is complete. 8. If this condition is satisfied, the iterating is completed. 9. Iterate if needed: if the convergence condition is not satisfied, we proceed to step 1 by updating the reference points \(B^{(0)}\) and \(C^{(0)}\) with the newly calculated points \(B^{(1)}\) and \(C^{(1)}\) and repeat the process. 10. Accuracy check: after the iterations converge, we check the accuracy of the prescribed function by analyzing the position of the initial kinematic chain \(ABCD\). This is achieved by verifying the function reproduction: \(\overline{r}_{D_{0}}=T_{10}\cdot T_{21}\cdot T_{32}\cdot\overline{r}_{D_{3}}\), where \(T_{10}\), \(T_{21}\), \(T_{32}\) are the transformation matrices, and \(\overline{r}_{D_{0}}\), \(\overline{r}_{D_{3}}\) are position vectors in the reference frames. 11. Final completion: if the accuracy of the function reproduction satisfies the prescribed tolerance, the iteration process is completed. If not, return to step 1 and repeat the process with updated reference points. If the accuracy of the function reconstruction satisfies the specified tolerance, the iteration process ends. Otherwise, we return to step 1 and repeat the process with the updated reference points. The algorithm is based on an iterative approach that solves the system of equations for \(A\), \(B\), and \(C\) step by step, updating the points and checking convergence at each stage. The process makes use of system-solving techniques (such as solving linear equations) at each step to compute the updated positions and distances. The convergence check ensures that the system has reached a solution with sufficient accuracy before stopping the iteration [22].