2
$\begingroup$

I have the following matrix equation

$$AX=B$$

given $8 \times 3$ matrices $A$ and $B$. $X$ is a $3 \times 3$ diagonal matrix whose main diagonal contains the $3$ unknowns.

Whenever I solve for $X$ using least squares $X= (A^TA)^{-1} A^T B$, I get a square matrix that is not diagonal. Any idea on how I can force the least squares solution matrix to be diagonal?

$\endgroup$

1 Answer 1

1
$\begingroup$

Are you are looking for the diagonal matrix $X$ with $\|AX-B\|_F$ minimal, where $F$ is the Frobenius norm? Then $\|AX-B\|^2_F=|a_1 x_{11}-b_1|^2+\dots+|a_3 x_{33}-b_3|^2$, where $a_1,\dots,a_3$ and $b_1,\dots,b_3$ are the columns of $A$ resp. $B$ and $x_{11},\dots,x_{33}$ the diagonal entries of $X$. Then the solution would simply be $x_{ii}=\frac{\langle a_i,b_i\rangle }{|a_i|^2} $ and therefore $$X=diag(x_{11},\dots,x_{33})=diag\left(\frac{\langle a_1,b_1\rangle }{|a_1|^2},\dots, \frac{\langle a_1,b_1\rangle }{|a_1|^2}\right).$$

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.