## 2 Formulation for Modeling
### Main Formulas for Inverse Wave Estimation  
References [7,8] presented the essential formulas, including the output matrix as Equation (11) i.e., the use of vessel's hydrodynamics for wave spectrum estimation by utilizing the Kalman filter. Equations (1) and (2) are used as the system model equations. The state transitional matrix \(\phi_{k}\) is identity and \(X\) is the complex wave amplitude in this case. As in Equation (10), this model has an important premise. It assumes that the measured vessel motion is the result of incoming waves that were weighted by a transfer function [7]. The vessel's transfer functions are complex, which means that they have amplitude and phase. The amplitude of transfer function is called response amplitude operator (RAO). \[z(t)\cong\text{Re}(\sum_{j=1}^{n_{f}}TF_{j}\times(x_{2j-1}+ix_{2j})(\cos( \omega_{j}t)+i\sin(\omega_{j}t))) \tag{10}\]  
where  
z: vessel motion  
\(x_{2j-1}\): real part of complex wave amplitude  
\(x_{2j}\): imaginary part of complex wave amplitude  
\(\omega\): intrinsic frequency of harmonic  
\(n_{f}\): number of harmonics to estimate  
\(TF_{j}\): complex-valued transfer function for frequency j  
The matrix type of \(H\) becomes  
\[H_{kl}=\left[ \begin{array}{c}\text{Re}(TF_{jl})\cos(\omega_{j}k\triangle t )-\text{Im}(TF_{jl})\sin(\omega_{j}k\triangle t)\\ -\text{Im}(TF_{jl})\cos(\omega_{j}k\triangle t)-\text{Re}(TF_{jl})\sin(\omega _{j}k\triangle t)\end{array} \right]^{\prime} \tag{11}\]  
where  
\(j\): \(j\)th frequency \(k\): \(k\)th time instant  
\(l\): \(l\)th response  
\(H_{jlk}\): output matrix  
\(\triangle t\): time step interval  
In [8], the conventional Equations (5), (6), and (9) were used for prediction and estimation. However, in the prediction of \(x\), Equation (13) was used instead of Equation (8) i.e., the average value for three-time instants is applied as the state prediction value, \(\hat{x}_{k+1}\). In addition, P was computed by Equation (12) instead of Equation (7). Equation (12) was used for stability reasons and it is called the 'Joseph Form' [14]. In fact, Equation (7) is derived from Equation (12). Accordingly, either can be used to calculate P.  
\[P_{k}=(I-K_{k}H_{k})P_{\overline{k}}(I-K_{k}H_{k})^{\prime}+KRK^{\prime} \tag{12}\]  
\[\hat{x}_{\overline{k}+1}=1/3\cdot(\hat{x}_{k}+\hat{x}_{k-1}+\hat{x}_{k-2}) \tag{13}\]  
According to [8], the adaptive approach has been considered, because it cannot be assured that the process is completely known and that the steady state is reached due to the change of sea condition and ship's heading. Equation (14) is the Adaptive R equation. The 'diag' means taking the diagonal from a matrix into a vector form and vice-versa. \[R=diag^{2}(E[z_{k}-H_{k}\hat{x}_{\overline{k}^{\prime}}(z_{k}-H_{k}\hat{x}_{ \overline{k}})^{\prime}])+H_{k}P_{\overline{k}}H_{k}^{\prime} \tag{14}\]  
The initial value of the state is as follows:  
\[\hat{x}_{\overline{1}}=0 \tag{15}\]  
In the present paper, the above Equations (1), (2), (5)-(11), and (15) are applied. The rest of the equations and other conditions are set to suit the vessel that is considered and computer specifications. Using the state, \(x\), which is an estimated value from the filter, the wave spectrum and wave elevation can be calculated from the following equations. The reconstruction of both wave spectra and wave elevation is possible since the state variable \(x\) and motion transfer function TF are complex variables:  
\[S_{z}(\omega_{i})=0.5\times\frac{1}{\Delta\omega_{i}}\times(\hat{x}_{2i-1}^{2} +\hat{x}_{2i}^{2}) \tag{16}\]  
\[\varsigma(t)=[\cos(\omega_{1}\cdot t),\;-\sin(\omega_{1}\cdot t)\;\ldots\; \cos(\omega_{n}\cdot t),\;-\sin(\omega_{n}\cdot t)][\hat{x}_{1}\hat{x}_{2}\; \ldots\;\hat{x}_{2n-1}\hat{x}_{2n}]^{\prime} \tag{17}\]  
where  
\(S_{z}(\omega)\): wave spectrum  
\(\Delta\omega\): frequency interval  
\(\varsigma\): wave elevation  
Regarding the determination of \(R\) and \(Q\) values, \(R\) can be determined based on the real sensor's performance before or while operating the filter.