# Synthesis of Four-Link Initial Kinematic Chains with Spherical Pairs for Spatial Mechanisms
## 2 Materials and Methods
This equation simplifies terms involving the coordinates \(X_{A}\), \(Y_{A}\), \(Z_{A}\), and the radius \(R\), and is related to the weighted sum of squared distances:  
\[\sum_{i=1}^{N}\left[X_{Ai}^{2}X_{A}+X_{Ai}Y_{Ai}Y_{A}+Z_{Ai}X_{Ai}Z_{A}+ \frac{1}{2}\Big{(}R^{2}-X_{A}^{2}-Y_{A}^{2}-Z_{A}^{2}\Big{)}X_{Ai}\right]= \frac{1}{2}{\sum_{i=1}^{N}\left(X_{Ai}^{2}+Y_{Ai}^{2}+Z_{Ai}^{2}\right)}X_{Ai} \tag{26}\]  
This equation represents a similar relationship for the \(Y_{A}\) coordinates:  
\[\sum_{i=1}^{N}\Delta_{qi}^{(1)}(Y_{Ai}-Y_{A})=0 \tag{20}\]0  
This equation applies the same principle to the \(Z_{A}\) coordinates:  
\[\sum_{i=1}^{N}\Delta_{qi}^{(1)}(Y_{Ai}-Y_{A})=0 \tag{20}\]1  
This equation represents the relationship between the coordinates and the sum of squared values:  
\[\sum_{i=1}^{N}\Delta_{qi}^{(1)}(Y_{Ai}-Y_{A})=0 \tag{20}\]2  
This equation expresses a term \(H_{1}\) in terms of the radius \(R\) and coordinates \(X_{A}\), \(Y_{A}\), \(Z_{A}\). \[\sum_{i=1}^{N}\Delta_{qi}^{(1)}(Y_{Ai}-Y_{A})=0 \tag{20}\]3  
These equations are designed to relate the parameters \(X_{A}\), \(Y_{A}\), \(Z_{A}\), and \(R\) by simplifying the weighted sums over the \(N\) positions of the solids. To solve them, we typically:  
- Substitute the expressions for each term and simplify the sum at position N;  
- Solve the resulting system of linear equations to find the values of \(X_{A}\), \(Y_{A}\), \(Z_{A}\), and \(R\)Since these equations appear to be interrelated, solving them requires finding the optimal values of the parameters that balance these equations [19]. This matrix contains the sums of the product terms for \(X_{A}\), \(Y_{A}\), \(Z_{A}\), as well as their sums individually. These sums correspond to the moments of the data (coordinates \(X_{A}\), \(Y_{A}\), \(Z_{A}\)) over the \(N\) positions. The system of equations is given by  
\[ \begin{bmatrix}\sum_{i=1}^{N}X_{Ai}^{2}&\sum_{i=1}^{N}X_{Ai}Y_{Ai}&\sum_{i=1}^{ N}X_{Ai}Z_{Ai}&\sum_{i=1}^{N}X_{Ai}\\ \sum_{i=1}^{N}X_{Ai}Y_{Ai}&\sum_{i=1}^{N}Y_{Ai}&\sum_{i=1}^{N}Y_{Ai}Z_{Ai}&\sum_ {i=1}^{N}Y_{Ai}\\ \sum_{i=1}^{N}X_{Ai}Z_{Ai}&\sum_{i=1}^{N}Y_{Ai}Z_{Ai}&\sum_{i=1}^{N}Z_{Ai}^{2} &\sum_{i=1}^{N}Z_{Ai}\\ \sum_{i=1}^{N}X_{Ai}&\sum_{i=1}^{N}Y_{Ai}&\sum_{i=1}^{N}Z_{Ai}&N\end{bmatrix}  \times \begin{bmatrix}X_{A}\\ Y_{A}\\ Z_{A}\\ H_{1}\end{bmatrix} =\frac{1}{2} \begin{bmatrix}\sum_{i=1}^{N}R_{A_{i}}^{2}X_{A_{ i}}\\ \sum_{i=1}^{N}R_{A_{i}}^{2}Z_{A_{i}}\\ \sum_{i=1}^{N}R_{A_{i}}^{2}\end{bmatrix}  \tag{31}\]  
Using Cramer's Rule, the solution for the unknowns \(X_{A}\), \(Y_{A}\), \(Z_{A}\), \(H_{1}\) is given by  
\[(X_{A},Y_{A},Z_{A},H_{1})=\frac{1}{D_{1}}(D_{X_{A}},D_{Y_{A}},D_{Z_{A}},D_{H_ {1}}),\ (\text{at }D_{1}\ \
eq\ 0) \tag{32}\]  
where \(D_{1}\) is the determinant of the coefficient matrix on the left-hand side. \(D_{X_{A}}\), \(D_{Y_{A}}\), \(D_{Z_{A}}\), \(D_{H_{1}}\) are the determinants of the matrices obtained by replacing the corresponding columns of the coefficient matrix with the right-hand side vector (i.e., the values for \(X_{A}\), \(Y_{A}\), \(Z_{A}\), \(H_{1}\)). \(R_{Ai}^{2}\) is the squared distance from the origin for each point \(A\), which is calculated as  
\[R_{Ai}^{2}=X_{Ai}^{2}+Y_{Ai}^{2}+Z_{Ai}^{2} \tag{33}\]  
The goal is to solve the system of linear equations for \(X_{A}\), \(Y_{A}\), \(Z_{A}\), \(H_{1}\). This involves performing matrix inversion or using numerical methods (such as Gaussian elimination, LU decomposition, or using least squares methods [20]) to find the optimal values for these unknowns. Now, we have another system to solve for the parameters \(x_{B}\), \(y_{B}\), \(z_{B}\), and \(H_{2}\) that is structured similarly to the previous one:  
\[