I have an $N\times N$ matrix $\mathbb X$ with entries:
$$X_{ij} = x_i\delta_{ij} + y_i(\delta_{i+m,j}+\delta_{i,j+m})$$
where $1 \le m \le N$, and $x_i,y_i$ are given numbers.
Is there an analytical formula for the inverse of $\mathbb X$? I've found numerically that $\mathbb X^{-1}$ is also sparse, with non-zeros on the main diagonal and a few other diagonals.
Please note that your matrix $X$ is actually the result of the row and column permutation of a block diagonal matrix with $m$ tridiagonal blocks. You can permute the rows and columns such that the original rows/columns $$ 1,1+m,1+2m,\ldots,1+\left\lfloor\frac{N-1}{m}\right\rfloor m,\\ 2,2+m,2+2m,\ldots,2+\left\lfloor\frac{N-2}{m}\right\rfloor m,\\ \vdots \\ m,m+m,m+2m,\ldots,m+\left\lfloor\frac{N-m}{m}\right\rfloor m $$ form the new rows/columns $1,\ldots,N.$ You will get some tridiagonal blocks of size $\left\lfloor\frac Nm\right\rfloor$ and some tridiagonal blocks of size $\left\lceil\frac Nm\right\rceil,$ which you can invert in isolation using the formula given in this link about tridiagonal matrices. In the end, you only have to undo the permutations.