# A Recursive Least-Squares Algorithm for the Identification of Trilinear Forms
## 2 Third-Order Tensors
A rank-1 tensor (of dimension \(L_{1}\times L_{2}\times L_{3}\)) is defined as:  
\[\mathbf{\mathcal{B}}=\mathbf{b}_{1}\circ\mathbf{b}_{2}\circ\mathbf{b}_{3}, \tag{1}\]  
where \(\mathbf{b}_{1}\), \(\mathbf{b}_{2}\), and \(\mathbf{b}_{3}\) are vectors of lengths \(L_{1}\), \(L_{2}\), and \(L_{3}\), respectively, \(\circ\) is the vector outer product, and the elements of \(\mathbf{\mathcal{B}}\) are given by \(\left(\mathbf{\mathcal{B}}\right)_{l_{1}l_{2}l_{3}}=b_{1,l_{1}}b_{2,l_{2}}b_{3,l_{ 3}}\), where \(b_{i,l_{i}}\) are the elements of the vector \(\mathbf{b}_{i}\), with \(i=1,2,3\) and \(l_{i}=1,2,\ldots,L_{i}\). In this case, it can be easily verified that:  
\[\mathrm{vec}\left(\mathbf{\mathcal{B}}\right)=\mathbf{b}_{3}\otimes\mathbf{b}_{2} \otimes\mathbf{b}_{1}, \tag{2}\]  
where \(\otimes\) denotes the Kronecker product [24]. In this context, the rank of a tensor \(\mathbf{\mathcal{A}}\), denoted \(\mathrm{rank}\left(\mathbf{\mathcal{A}}\right)\), is defined as the minimum number of rank-1 tensors that generate \(\mathbf{\mathcal{A}}\) as their sum. For example, if:  
\[\mathbf{\mathcal{A}}=\sum_{r=1}^{R}\mathbf{a}_{1r}\circ\mathbf{a}_{2r}\circ\mathbf{ a}_{3r}, \tag{3}\]  
where \(\mathbf{a}_{1r}\), \(\mathbf{a}_{2r}\), and \(\mathbf{a}_{3r}\) are vectors of lengths \(L_{1}\), \(L_{2}\), and \(L_{3}\), respectively, then \(\mathrm{rank}\left(\mathbf{\mathcal{A}}\right)=R\) when \(R\) is minimal and (3) is called the canonical polyadic decomposition (CPD) of \(\mathbf{\mathcal{A}}\). Another important operation is the multiplication of a tensor with a matrix [1; 2], which can also be defined in different ways. For example, the mode-1 product between the tensor \(\mathbf{\mathcal{A}}\in\mathbb{R}^{L_{1}\times L_{2}\times L_{3}}\) and the matrix \(\mathbf{M}_{1}\in\mathbb{R}^{M_{1}\times L_{1}}\) gives the tensor:  
\[\mathbf{\mathcal{U}}=\mathbf{\mathcal{A}}\times_{1}\mathbf{M}_{1},\ \mathbf{\mathcal{U}}\in\mathbb{R}^{M_{1}\times L_{2}\times L_{3}}, \tag{4}\]whose entries are \(u_{m_{1}l_{2}l_{3}}=\sum_{l_{1}=1}^{L_{1}}a_{l_{1}l_{2}l_{3}}m_{m_{1}l_{1}}\) (for \(m_{1}=1,2,\ldots,M_{1}\)) and \(\mathbf{U}_{[1]}=\mathbf{M}_{1}\mathbf{A}_{[1]}\). Similarly, the mode-2 product between the same tensor \(\mathbf{\mathcal{A}}\) and the matrix \(\mathbf{M}_{2}\in\mathbb{R}^{M_{2}\times L_{2}}\) leads to the tensor:  
\[\underline{\mathbf{\mathcal{U}}}=\mathbf{\mathcal{A}}\times_{2}\mathbf{M}_{2},\ \underline{\mathbf{\mathcal{U}}}\in\mathbb{R}^{L_{1}\times M_{2}\times L_{3}}, \tag{5}\]  
with the entries \(\underline{u}_{l_{1}m_{2}l_{3}}=\sum_{l_{2}=1}^{L_{2}}a_{l_{1}l_{2}l_{3}}m_{m _{2}l_{2}}\) (for \(m_{2}=1,2,\ldots,M_{2}\)) and \(\underline{\mathbf{U}}_{[2]}=\mathbf{M}_{2}\mathbf{A}_{[2]}\). Finally, the mode-3 product between the tensor \(\mathbf{\mathcal{A}}\) and the matrix \(\mathbf{M}_{3}\in\mathbb{R}^{M_{3}\times L_{3}}\) results in the tensor:  
\[\overline{\mathbf{\mathcal{U}}}=\mathbf{\mathcal{A}}\times_{3}\mathbf{M}_{3},\ \overline{\mathbf{\mathcal{U}}}\in\mathbb{R}^{L_{1}\times L_{2}\times M_{3}}, \tag{6}\]  
having the entries \(\overline{u}_{l_{1}l_{2}m_{3}}=\sum_{l_{3}=1}^{L_{3}}a_{l_{1}l_{2}l_{3}}m_{m_{ 3}l_{3}}\) (for \(m_{3}=1,2,\ldots,M_{3}\)), while \(\overline{\mathbf{U}}_{[3]}=\mathbf{M}_{3}\mathbf{A}_{[3]}\). Clearly, we can multiply the tensor \(\mathbf{\mathcal{A}}\) with the three previously defined matrices \(\mathbf{M}_{1}\), \(\mathbf{M}_{2}\), and \(\mathbf{M}_{3}\).