# Inverting a principal submatrix

$P$ is an $n \times n$ nonsingular matrix that I would like to study. However, before I get to look at $P$, an evil mathematician comes along and adds corresponding rows and columns, full of random entries, to $P$ (by "corresponding," I mean that if he adds a new row to $P$ in the $n^{th}$ position, then he will also add a new column to $P$ in the $n^{th}$ position).

The result is an $m \times m$ matrix $Q$, of which $P$ is a principal submatrix. I get to see $Q$. I also get a big hint: a vector $v \in \mathbb{R}^m$ with the property that $v_i = P^{-1}_{i*} * 1^T$ (i.e. the sum of the $i^{th}$ row of $P^{-1}$) if row/col $i$ in $Q$ was an original row of $P$, or $v_j = 0$ if row/col $j$ were fabricated by the evil mathematician.

Given this information, I would like to find a function $f$ such that $f(Q, v)$ is an $m \times m$ matrix with $f_{ij}$ gives the corresponding entry in $P^{-1}$ if $i, j$ were original row/cols of $P$ ($f_{ij}$ can be anything at all if $i$ or $j$ was fabricated). Additionally, I'd like $f$ to be analytic: the algorithmic function look at the $0$s of $v$, delete the fabricated rows from $Q$, invert the matrix, add the fabricated rows back as $0$s is useless to me because it cannot be differentiated with respect to $Q$ or $v$.

Here is an example. Let $$P = \begin{pmatrix} 1 & 4 \\ 2 & 3 \\ \end{pmatrix}$$ with $$P^{-1} = \begin{pmatrix} -\frac{3}{5} & \frac{4}{5} \\ \frac{2}{5} & -\frac{1}{5} \\ \end{pmatrix}$$ Evil Mathematician adds two row/col pairs: $$Q = \begin{pmatrix} 1 & 7 & 4 & 7 \\ 7 & 7 & 7 & 7 \\ 2 & 7 & 3 & 7 \\ 7 & 7 & 7 & 7 \\ \end{pmatrix}$$ He has kindly chosen $7$ as the random value each time; in general, he might choose a different random value for each new entry. We now get to know that $v = (\frac{1}{5}, 0, \frac{1}{5}, 0)$. We now want our function $f$ to produce the matrix: $$f(Q, v) = \begin{pmatrix} -\frac{3}{5} & ? & \frac{4}{5} & ? \\ ? & ? & ? & ? \\ \frac{2}{5} & ? & -\frac{1}{5} & ? \\ ? & ? & ? & ? \\ \end{pmatrix}$$ The ?'s can be anything (and different ?'s can represent different values).