# replacement – Repeated ReplacePart On Each Element of a Square Matrix for Eigenvalue Difference

I have a large $$ntimes n$$ square matrix, whose elements are all either 0 or 1. I want to see by how much the single largest eigenvalue of the matrix (which Mathematica gives as the first element in the list from `Eigenvalues`) changes when I change each element of the matrix individually, so that I can produce a list of this eigenvalue difference for each element. A $$10times 10$$ matrix would thus give a list of 100 eigenvalue differences. By “changing each element”, I mean switching the element to 1 if it’s a 0 or to 0 if it’s a 1 in the original.

For instance, if the matrix is `{{0, 1, 0}, {1, 0, 1}, {1, 0, 0}}`, finding the largest eigenvalue of `{{1, 1, 0}, {1, 0, 1}, {1, 0, 0}}`, then that of `{{0, 0, 0}, {1, 0, 1}, {1, 0, 0}}`, then that of `{{0, 1, 1}, {1, 0, 1}, {1, 0, 0}}` etc…

I experimented with Loops but since $$i$$ and $$j$$ need to increase independently I couldn’t resolve that issue. I also thought of combining `ReplacePart` and `If` but can’t find a neat way of doing this for very large matrices.