Generating a new matrix from an old one by an algebraic relationship
How about
With[{inds = DeleteCases[Range@Length@M, 2]},
Table[M[[i, j]] + If[i != j, 1, 0] M[[i, 2]] M[[2, j]],
{i, inds}, {j, inds}]
]
% // MatrixForm
Note that N
is a built-in symbol, so you should avoid using it (and, to be safe, you might want to avoid using single-letter capital variable names in general). A safe alternative is to use NN
instead.