We compute the guided modes of a gyrotropic rib waveguide in the semivectorial approximation. The principal component of the magnetic field is expanded into a two-dimensional Fourier series on a rectangular computational window. The expansion coefficients are determined by the Galerkin method, giving rise to a generalized eigenvalue problem with symmetric matrices, typically of rank 300. The method is easy to implement, is reasonably fast, and compares well with the finite-difference or spectral-index method. The quasi-TM mode equation is the condition of stationarity for a bilinear functional. The latter allows one to derive an expression for the differential nonreciprocal phase shift as a first-order perturbation.