sum of the elements of a tridiagonal matrix and its inverse I have a tridiagonal matrix $A$ of dimension $n$ with terms $1+\theta^2$ on the diagonal and $\theta$ on the secondary diagonals:
$A=\begin{bmatrix}1+\theta^2 & \theta & 0 &...& 0\\ \theta & 1+\theta^2 & \theta &... &0 \\0 & \theta & 1+ \theta^2 &\theta... & 0 \\... \end{bmatrix} $
Two quantities of interest are the sum of its elements $S_1=1/n^2\sum A_{ij}$ and the inverse of the sum of the elements of $A^{-1}$, $S_2=\frac{1}{\sum (A^{-1})_{ij}}$, and how they compare to each other.
They will be equal to each other when the matrix is diagonal $\theta=0$ because they are both the identity matrix.
However I also noticed numerically that the relative difference between $S_1$ and $S_2$ gets very much smaller when $\theta>0$ than when $\theta<0$, but can't find a clear analytic reason why
Is there a good way to relate the sum of the elements of this simple matrix to those of its inverse and compare them analytically?
I tried the brute force approach of analytically calculating the elements of the inverse and summing them to compare but the ugly expressions I get do not clearly reflect the trend I discussed.
 A: Note: This is not a full solution; it's just some patterns and suggested approaches that generally work well for approaching similar problems. I use Mathematica here, but I think sympy or SageMath are good free alternatives.
In Wolfram Mathematica I can run
mat[n_, \[Theta]_] := 
 Table[If[j == k, 1 + \[Theta]^2, 
   If[Abs[j - k] == 1, \[Theta], 0]], {j, 1, n}, {k, 1, n}]

nn = 10;
Series[Total[Flatten[mat[nn, \[Theta]]]], {\[Theta], 0, nn + 1}]
Series[Total[Flatten[Inverse[mat[nn, \[Theta]]]]], {\[Theta], 0, nn + 1}]

to quickly see what the results look like for various $n$.
For example, for $n=10$ I find the inverse has entry sum $10 - 18 \theta + 24 \theta^2 - 28 \theta^3 + O(\theta^4)$, compared to the original matrix sum $10 + 18 \theta + 10 \theta^2$. Based on a few more examples, I make the following initial conjectures:

*

*The constant terms always match.

*The linear terms (coefficients on $\theta^1$) are each other's negatives.


There are also clear patterns in the overall inverse matrix:

Once you see what the patterns are, I assume it's not hard to prove them, but I also assume it'd be a significant slog. Probably best to start by just assuming these patterns and trying to solve the rest of the problem, and only come back to prove carefully if the pattern turns out to be helpful/important.
Overall, with such questions I find it very often useful to first use a computer algebra system to quickly check for patterns, formulate and test hypotheses, etc. Then I could always go back later and try to prove things once I have a pretty good idea of which hypotheses are probably true.
A: There are results in the references here in on the explicit inversion of Toeplitz matrices, and since your matrix clearly belongs to the former category, we can establish a simple analytic formula for the matrix elements of the inverse given by
$$A^{-1}_{ij}=\frac{(1-\theta^{2i})(1-\theta^{2(n-j+1)})}{(1-\theta^2)(1-\theta^{2(n+1)})}(-\theta)^{j-i}~,~ i\leq j$$
which can be summed via trigonometric sums, given that the matrix is symmetric to yield
$$\sum_{ij}(A^{-1})_{ij}=\frac{n (1 + \theta) + 
 2 \theta \frac{-1 + (-\theta)^n + (-\theta)^{1 + n} + \theta^{1 + 2 n}}{(-1 +
   \theta^{2 + 2 n})}}{(1 + \theta)^3}$$
Obviously
$$\frac{1}{n^2}\sum_{ij}A_{ij}=\frac{1}{n}(1+\theta^2)+\frac{2n-2}{n^2}\theta$$
Evidently, it is true that
$$\lim_{n\to \infty}\frac{1}{n^2}\sum_{ij}A_{ij}\sum_{ij}A^{-1}_{ij}=1~~, ~~\theta\neq 1$$
and $$\frac{1}{n^2}\sum_{ij}A_{ij}, (\sum_{ij}A^{-1}_{ij})^{-1}\sim \frac{\theta^2}{n}~~,~~~ \theta\to\infty$$
which verifies the intuition from the comments.
