Friday 19 December 2014

linear algebra - Extracting vector containing the elements of the main diagonal of a matrix





Is there any mathematical operation that would extract the elements of the main diagonal as a vector? i.e. multiply it by certain vectors or something like that. I'm using this in the context of linear systems.



In the specific case I'm looking at I have a relationship between the elements of three vectors as follows:



$ \bf{a} = \begin{bmatrix} a_{1} \\ a_{2} \\ a_{3} \\ a_{4} \end{bmatrix} $ , $ \bf{b} = \begin{bmatrix} b_{1} \\ b_{2} \\ b_{3} \\ b_{4} \end{bmatrix} $ , and $ \bf{c} = \begin{bmatrix} c_{1} \\ c_{2} \\ c_{3} \\ c_{4} \end{bmatrix} $




I also know that: $c_{i} = a_{i}b_{i} $ for $i \in [1, 4]$



Now I want to express this relationship as a vector equation. I understand that $\bf{a} \bf{b}^\top$ would give a square matrix with the elements of $\bf{c}$ on its main diagonal, but is there anyway to extract them as a vector?



EDIT: Let me clarify a bit. If I multiply $\bf{a}$ by $\bf{b}^\top$ I get the following matrix:



$\bf{a} \bf{b}^\top = \begin{bmatrix} \bf{a_1b_1} && a_1b_2 && a_1b_3 && a_1b_4 \\ a_2b_1 && \bf{a_2b_2} && a_2b_3 && a_2b_4 \\ a_3b_1 && a_3b_2 && \bf{a_3b_3} && a_3b_4 \\ a_4b_1 && a_4b_2 && a_4b_3 && \bf{a_4b_4} \end{bmatrix} $



The elements which have been made bold are the ones I'm interested in extracting as a vector. This vector would be $\bf{c}$.




If I multiply this by the all-ones vector, as some of the answers have suggested, I would get:



$\bf{a} \bf{b}^\top \bf{1}= \begin{bmatrix} \bf{a_1b_1} && a_1b_2 && a_1b_3 && a_1b_4 \\ a_2b_1 && \bf{a_2b_2} && a_2b_3 && a_2b_4 \\ a_3b_1 && a_3b_2 && \bf{a_3b_3} && a_3b_4 \\ a_4b_1 && a_4b_2 && a_4b_3 && \bf{a_4b_4} \end{bmatrix} \begin{bmatrix} 1 \\ 1 \\ 1 \\ 1 \end{bmatrix} = \begin{bmatrix} a_1b_1 + a_1b_2 + a_1b_3 + a_1b_4 \\ a_2b_1 + a_2b_2 + a_2b_3 + a_2b_4 \\ a_3b_1 + a_3b_2 + a_3b_3 + a_3b_4 \\ a_4b_1 + a_4b_2 + a_4b_3 + a_4b_4 \end{bmatrix}$



Which is not the vector I'm looking for (it isn't equal to $\bf{c}$).



EDIT 2: Multiplying by the $\bf{1}$ vector would obviously work if all off diagonal elements become zero. So if anyone knows of a way to do that without modifying the elements of the main diagonal that would also answer my question.



EDIT 3: The other question pointed out in the comments area is essentially the same and I have received similar answers but I was hoping for a simpler solution. I haven't marked it as duplicate to allow people to contribute in the future.




I was hoping for a solution that would be linear in $\bf{b}$ which I would substitute in place of $\bf{c}$ into the equation I'm trying to solve. In that case $\bf{b}$ would be my only unknown and I would be able to get an algebraic solution.


Answer



Well, it’s not pretty, but this will do it:



$$\sum_{i=1}^4\mathbf a^T\mathbf e_i\mathbf b^T\mathbf e_i\mathbf e_i$$ where the $\mathbf e_i$ are the standard basis vectors. Each term of the sum extracts the $i$th components of $\mathbf a$ and $\mathbf v$ and multiplies them together. You can also think of it as multiplying the projection of $\mathbf b$ onto $\mathbf e_i$ by $a_i$ or vice-versa.


No comments:

Post a Comment

real analysis - How to find $lim_{hrightarrow 0}frac{sin(ha)}{h}$

How to find $\lim_{h\rightarrow 0}\frac{\sin(ha)}{h}$ without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...