# Find matrix $S$ such that $diag(S)=d$ and $S^{-1}_{ij}=P_{ij}$ $\forall i \neq j$

I want to find a matrix $S$ with a fixed diagonal $d$ whose inverse matches $P$ on all of its off-diagonal elements.

You can assume $S$ and $P$ are positive definite, and $d>0$ (all elements of $d$ are positive).

Where this problem arises is in the following optimization:

$$\max_{S ~ s.t. ~ diag(S)=d} ~ -S \circ P + \ln | S |$$

where $\circ$ is a matrix dot product operator (multiply corresponding elements and add it all up). If it weren't for the condition that $diag(S)=d$, the solution to the maximization would be $S=P^{-1}$. However, because of the condition, we need $S^{-1}$ to match $P$ on all the off diagonal elements, while still keeping its diagonal equal to $d$.

The only solution I can think of is to just do the optimization numerically (via gradient descent or Convex Optimization / Semidefinite Programming), which is too costly computationally.

• Why not compute $P^{-1}$ and replace the diagonal elements of $P^{-1}$ with $d$? Mar 25, 2018 at 21:29
• @BrianBorchers I need $diag(S)=d$, NOT $diag(S^{-1})=d$ Mar 25, 2018 at 21:31
• can you guarantee existence of a solution? have you tried for small matrices?
– Surb
Mar 25, 2018 at 21:34
• @Surb the original optimization problem is convex, so will have one solution. And I just confirmed, for the 2x2 case, that the solution will be $S_{12} = \frac{1 + \sqrt{1+4 d_1 d_2 P_{12}^2}}{2 P_{12}}$ Mar 25, 2018 at 21:40
• What happens in the $2 \times 2$ case if $P_{12} = 0$? Mar 25, 2018 at 21:50