## 2 The Coarse-to-Fine Free-Form Surface Machining Error Decomposition and Compensation Process
### Principle of Machining Error Decomposition from Coarse to Fine
#### 2.3.2 Principle of the EMD Algorithm  
The EMD algorithm is a new adaptive signal time-frequency processing method proposed by [PERSON] in 1998 [26]. The algorithm can decompose an arbitrary signal into a number of IMF components, which is not only applicable to linear and smooth signals but also has good results in processing nonlinear and nonsmooth signals. Its essence is the decomposition of complex signals from high and low frequencies into individual intrinsic modal function components according to the time scale [27]. EMD decomposes the original signal into several IMFs, and each IMF has the following two characteristics:  
1. Within the entire signal, the number of extremum and zero crossing points must be the same, and the number of both must not differ by more than one at most;At any point within the signal, the upper envelope consisting of local maximum values and the lower envelope consisting of local minimum values both have an average value of 0, which is the local mean value. The specific decomposition steps of the EMD algorithm are as follows:  
1. Assuming that \(x(t)\) is the average of the upper and lower envelopes of the original signal \(m_{1}(t)\) and that \(h_{1}(t)\) is the difference between \(x(t)\) and \(m_{1}(t)\), it can be expressed by \[h_{1}(t)=x(t)-m_{1}(t)\] (9)  
Determine whether \(h_{1}(t)\) in Equation (9) satisfies the characteristics of the IMF component. If \(h_{1}(t)\) satisfies the condition, then \(h_{1}(t)\) is the first IMF component of \(x(t)\). The reason is that, in the actual decomposition process, overshooting and undershooting occur when fitting the envelope, and, in general, \(h_{1}(t)\) does not satisfy the conditions of the IMFs. 2. Treating \(h_{1}(t)\) as the signal to be decomposed and repeating step (1), it can be expressed by \[h_{11}(t)=h_{1}(t)-m_{11}(t)\] (10) After performing \(k\) decompositions, the following can be obtained: \[h_{1k}(t)=h_{1(k-1)}(t)-m_{1k}(t)\] (11) Decomposition ends when the final obtained \(h_{1k}(t)\) satisfies the two conditions of the IMF and \(h_{1k}(t)\) is the first IMF component of the original signal \(x(t)\), which is IMF1 and is denoted as \(c_{1}(t)\): \[c_{1}(t)=h_{1k}(t)\] (12)  
Since the upper and lower envelopes mean that \(m_{1k}(t)\) cannot be zero during the actual decomposition process, a stopping criterion must be determined to ensure that the decomposition process ends. For this reason, [PERSON] et al. proposed a stopping criterion for the decomposition as follows:  
\[SD=\frac{\sum\limits_{0}^{T}\Bigl{|}h_{1(k-1)}(t)-h_{1k}(t)\Bigr{|}^{2}}{ \frac{\sum\limits_{0}^{T}\Bigl{|}h_{1(k-1)}(t)\Bigr{|}^{2}}} \tag{13}\]  
A suitable thresholding is set before the decomposition is performed, and the decomposition is stopped immediately when SD is smaller than the set thresholding, typically \(SD\in[0.2,0.3]\). 1. Separate \(c_{1}(t)\) from \(x(t)\) in the original signal to obtain a new data sequence \(r_{1}(t)\): \[r_{1}(t)=x(t)-c_{1}(t)\] (14)  
Using \(r_{1}(t)\) to replace \(x(t)\) as the new original signal and repeating the above decomposition process yield the second component, IMF2, that qualifies as an IMF, which is \(c_{2}(t)\). The cycle is repeated \(n\) times to obtain \(n\) components eligible for the IMFs as follows:  
\[\left. \begin{array}{c}r_{2}(t)=r_{1}(t)-c_{2}(t)\\ \vdots\\ r_{n}(t)=r_{n-1(t)}-c_{n}(t)\end{array} \right\} \tag{15}\]
2. After decomposition, the original signal \(x(t)\) can be expressed as \[x(t)=\sum\limits_{i=1}^{n}c_{i}(t)+r_{n}(t)\] (16)2.3.3. Principle of the Wavelet Thresholding Method  
Currently, the wavelet transform, which has multiscale and decorrelation properties, is one of the most common time-frequency analysis methods. In the wavelet transform, the selection of the basis function, thresholding function, thresholding rule and number of decomposition layers is highly important.