Finding a matrix from its diagonal and the off-diagonal elements of its inverse? This question comes from https://stats.stackexchange.com/questions/457375/recover-full-covariance-matrix-from-covariance-diagonal-and-precision-off-diagon  where it have not found answers. So, let $\Sigma$ be an $N\times N$ covariance (that is, positive semidefinite) matrix, but we do only know its diagonal and the off-diagonal elements of its inverse $\Sigma^{-1}$ (known as precision matrix).
How can we find $\Sigma$ effectively?
 A: Following the ideas from my answer to Carlo's question, let $M(z_1, \ldots, z_n)$ be the symmetric matrix with $M(z_1, \ldots, z_n)_{ij} = \Sigma_{ij}$ for $i \neq j$ and $M(z_1, \ldots, z_n)_{ii} = z_i$.
Use any sort of numerical optimization algorithm to maximize
$$\log \det M(z_1, \ldots, z_n) - \sum_{i=1}^n \Sigma^{-1}_{ii} z_i$$
on the open set of $(z_1, \ldots, z_n)$ where $M(z_1, \ldots, z_n)$ is positive definite. The function in question is concave, so the optimum is unique and shouldn't be hard to find. This $M(z_1,\ldots, z_n)$ will have the desired property.
The equations one gets seems to have fairly high degree, so I would not attempt a symbolic solution.
A: In the linked question the OP also asks for the special case that the off-diagonal elements of $\Sigma^{-1}$ have a rank-one structure, $(\Sigma^{-1})_{ij}=u_i v_j$ for $i\neq j$. In that case the covariance matrix can be reconstructed as follows.
Denote $\Sigma^{-1}=A+uv^\top$, with $u,v$ known rank-$N$ vectors and $A={\rm diag}\,(d_1,d_2,\ldots d_N)$ an unknown diagonal matrix. According to the Sherman–Morrison formula, the covariance matrix $\Sigma$ then has diagonal elements
$$\Sigma_{ii}= x_i - {x_i^2 u_iv_i \over 1 +\sum_{n=1}^N u_nv_n x_n },\;\;i=1,2,\ldots N,$$
with $\;\;x_n=1/d_n$. These are $N$ equations where the $N$ unknowns $x_n$ appear quadratically.
This method of solution is efficient, but I do not have a proof that the solution with a positive definite $\Sigma$ is unique.
