Solve system for elements of a matrix I have a system of $n$ equations which follows a particular pattern as follows (showing the case $n=3$):
$$\phi = a_1 + \psi_2 a_2 + \psi_3 a_3 \\
\phi = \psi_1 a_1 + a_2 + \psi_3 a_3\\
\phi = \psi_1 a_1 + \psi_2 a_2 + a_3$$
The scalars $\phi$ and the $a_i$ are known, and I need to solve for the $\psi_i$. All scalars are $\in \mathbb{R}$.
So I am trying to rewrite it into a matrix equation, and getting mixed up with constructing the matrix, and then solving, somewhat similar to this and this previous questions.
So I've got this far:
$$\phi \begin{Bmatrix} 1\\1\\1 \end{Bmatrix} = 
\begin{bmatrix} 
1 & \psi_2 & \psi_3 \\ 
\psi_1 & 1 & \psi_3 \\ 
\psi_1 & \psi_2 & 1
\end{bmatrix}
\begin{Bmatrix} a_1\\a_2\\a_3\ \end{Bmatrix}
$$
which more generally can become:
$$\phi\boldsymbol{\unicode{x1D7D9}}_{n\times 1} = \boldsymbol{\Psi}_{n\times n} \boldsymbol{a}_{n\times 1}$$
so to solve for the vector $\boldsymbol{\psi} = \left[\psi_1, ..., \psi_n\right]^T$ and inspired by this I try to decompose $\boldsymbol{\Psi}$ as follows:
$$ \boldsymbol{\Psi} = \left[ \textrm{diag}(\boldsymbol{\psi} )(\boldsymbol{\unicode{x1D7D9}}_{n\times n}) - \boldsymbol{I}_{n\times n}\right]^T + \boldsymbol{I}_{n\times n} $$
but this both feels messy, and also doesn't seem to make finding $\boldsymbol{\psi}$ any easier. The system might also be overdetermined.
Any ideas appreciated!
 A: $
\def\o{{\tt1}}
\def\M{\Psi}
\def\LR#1{\left(#1\right)}
\def\BR#1{\Big(#1\Big)}
\def\op#1{\operatorname{#1}}
\def\Diag#1{\op{Diag}\LR{#1}}
\def\a{{\o a^T}}
$Let $x$ denote the unknown vector and $\o$ the all-ones vector, then
$$\eqalign{
\M &= I + \o x^T - \Diag{x} \\
}$$
This decomposition allows your linear system to be algebraically manipulated and solved
$$\eqalign{
\phi\o &= \M a \\
 &= a + \o\LR{x^Ta} - \Diag{x}\,a \\
 &= a + \LR{\a}x - \Diag{a}\,x \\
\LR{\phi\o-a} &= \BR{\a - \Diag{a}}\,x \\
x &= \BR{\a - \Diag{a}}^{\bf+}\LR{\phi\o-a} \\
}$$
where the pseudoinverse is used since the matrix in parentheses can be singular.
A: If I understand you correctly, your matrix is
$$ 0 \psi_1 + a_2 \psi_2  + a_3 \psi_3  = \phi -a_1\\
 a_1\psi_1  + 0 \psi_2 + a_3 \psi_3 = \phi -a_2\\
 a_1 \psi_1 + a_2 \psi_2  + 0 \psi_3 = \phi -a_3$$
Using Gaussian Elimination, we arrive at
$$\begin{bmatrix} 1 & 0 & 0 & \dfrac{a_1-a_2-a_3+\phi}{2 a_1}\\0 & 1 & 0 & \dfrac{-a_1+a_2-a_3+\phi}{2 a_2} \\ 0 & 0 & 1 & \dfrac{-a_1-a_2+a_3+\phi}{2 a_3} \end{bmatrix}$$
Note that any $a_i$ equal to zero causes issues.
