# Comparative Analysis of the Methods for Fiber Bragg Structures Spectrum Modeling
## 2 Modeling Methods
### Layer Sweep Method
\begin{bmatrix}1&-1&-1&0&0&0&0&\ldots&0&0\\ -w_{1}&-w_{0}&w_{0}&0&0&0&0&\ldots&0&0\\ 0&a_{1}&b_{1}&c_{1}&d_{1}&0&0&\ldots&0&0\\ 0&e_{1}&f_{1}&g_{1}&h_{1}&0&0&\ldots&0&0\\ \ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots\\ 0&0&0&a_{i}&b_{i}&c_{i}&d_{i}&\ldots&0&0\\ 0&0&0&e_{i}&f_{i}&g_{i}&h_{i}&\ldots&0&0\\ \ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots\\ 0&0&0&0&0&0&0&a_{N}&b_{N}&c_{N}\\ 0&0&0&0&0&0&0&e_{N}&f_{N}&g_{N}\end{bmatrix}\begin{bmatrix}r_{0}\\ t_{1}\\ t_{2}\\ r_{2}\\ \ldots\\ t_{i}\\ r_{i}\\ t_{N+1}\end{bmatrix} = \begin{bmatrix}-1\\ -w_{1}\\ 0\\ 0\\ 0\\ 0\\ 0\\ 0\end{bmatrix} \,, \tag{15}\]  
where the following denotations are introduced:  
\[ \begin{array}{llll}a_{i}=\exp(-\mu_{i}z_{i})&b_{i}=\exp(j\kappa_{i}z_{i})&c_ {i}=-\exp(-j\kappa_{i+1}z_{i})&d_{i}=-\exp(j\kappa_{i+1}z_{i})\\ e_{i}=w_{i+1}\exp(-j\kappa_{i}z_{i})&f_{i}=-w_{i+1}\exp(j\kappa_{i}z_{i})&g_ {i}=-w_{i}\exp(-j\kappa_{i+1}z_{i})&h_{i}=w_{i}\exp(j\kappa_{i+1}z_{i})\end{array} \,. \tag{16}\]  
A system of linear equations formulated in the matrix form can be solved using the Gaussian method by reducing the matrix of coefficients to a triangular form. Given the specific shape of the matrix elements, each internal row contains only four elements; moreover, rows containing elements in the same positions are grouped by two. Thus, the coefficient matrix is a five-diagonal matrix containing, in addition to the main diagonal, two over-diagonals, and two under-diagonals. Besides that, the two over- and under-diagonals further from the central diagonal are sparse. For systems of linear equations with a matrix of coefficients of three-, four-, and five-diagonal form, the sweep method can be applied, which involves the successive transformation of the matrix rows, thus bringing it to a triangular form. Reduction the coefficient matrix to a diagonal form immediately allows one to determine the value of the unknown standing at the top of the triangle. The matrix of coefficients in (15) can be reduced with equal ease both to the upper triangular form and to the lower triangular form. In the case of reducing the matrix to the upper triangular form, the value of the transmittance of the last layer is automatically calculated. In the case of the lower triangular form, it becomes possible to calculate the reflection coefficient of the zeroth layer. The reduction of the matrix of coefficients in (15) to the lower triangular form can be performed using the backward sweep formulas for the recurrence relation, setting the initial value of \(\gamma\) in the following form:  
\[\gamma_{N}=1+\frac{w_{N}-w_{N-1}}{w_{N}+w_{N+1}}\exp(-j2k_{N}(z_{N}-z_{N-1}))\, \tag{17}\]  
then, in the reverse cycle, the remaining values of \(\gamma_{i}\) are determined using the recursive relation:  
\[\gamma_{i}=1+\frac{(w_{i}-w_{i+1})\gamma_{i+1}+2w_{i+1}}{(w_{i}+w_{i+1})\gamma _{i+1}-2w_{i+1}}\exp(-j2k_{i}(z_{i}-z_{i-1})),\ \ i=\overline{N-1,-1,1}\, \tag{18}\]  
which ultimately allows calculating the transmittance and reflectance for the zeroth layer:  
\[\left\{ \begin{array}{ll}t_{0}^{\text{A}}=1\\ r_{0}^{\text{A}}=\frac{(w_{1}+w_{0})\gamma_{1}-2w_{1}}{(w_{1}-w_{0})\gamma_{1 }-2w_{1}}\end{array} \right.. \tag{19}\]