4

Let $u$ and $v$ be a column vector of same dimension.

  • 1.) Can anyone give some properties about the operations of function, such as $\text{diag}(u)+\text{diag}(v)=\text{diag}(u+v)$?
  • 2.) Is there any mathematical representation to express the function diag?

Thanks a lot.

Amzoti
  • 56,093
  • 1
    Let $e_i$ be a vector with all zero entries except the i-th entry equals one.

    $diag(u) = \sum_i u_i e_ie^T_i$

    Can this help you?

    – Rein May 08 '13 at 05:01
  • 1
    It's an isomorphism between $\mathbb{F}^n$ and the subspace of $n\times n$ diagonal matrices. – EuYu May 08 '13 at 05:03
  • Assuming you mean diag to be placing the vector on the diagonals, there can be many properties. What you mentioned is true : It's linear. What is your motivation for asking this question?

    To answer your second question:

    You can simply use : $$A_{ij}=\cases{u_i\qquad i=j\0\qquad O/W}$$ You can use the basis vector representation in the comments as well.

    – Inquest May 08 '13 at 05:04
  • Btw it is better to register an account to ask question so that you can answer the comments. – Rein May 08 '13 at 05:07
  • I too would like to know more properties of this function. I think one is $\mathrm{diag}(u)Av = \mathrm{diag}(v)Au$ for vectors $u$,$v$ and symmetric matrix $A$. – Ben Farmer Aug 23 '18 at 15:16
  • Ok no, that isn't true, nevermind. – Ben Farmer Aug 23 '18 at 16:43
  • 2
    I guess $\mathrm{diag}(u)v = \mathrm{diag}(v)u$ though. – Ben Farmer Aug 23 '18 at 16:49

2 Answers2

2

The previous answers are using the definition of the $diag$ that is the mapping $\mathbb{R}^n \rightarrow \mathbb{R}^{n\times n}$. Which can be represented as,

\begin{align*} diag(u)= \left( u {\bf 1}^{\sf T}\right) \odot {\bf I} \end{align*}

where $u \in \mathbb{R}^n$ is a column vector, ${\bf 1}$ is a column vecotr of all ones, ${\bf I} \in \mathbb{R}^{n\times n}$ is the identity matrix, and $\odot$ is the elementwise (or Hadamard) product. This definition will have proofs very similar to the following.

Assuming the operator being talked about is the $diag$ operator that maps $\mathbb{R}^{n\times n}\rightarrow \mathbb{R}^{n\times n}$, specifically the operator that `selects' the diagonal of a matrix. Then it can be represented as:

\begin{align*} diag(A)={\bf I} \odot A \end{align*}

where $A\in \mathbb{R}^{n\times n}$, $\bf I$ is the identity matrix, and $\odot$ is the elementwise (or Hadamard) product. This can be quite useful for deriving any properties of the operator that is needed. Additionally, the Hadamard product has plenty of properties that can be used to infer properties of the $diag $ operator. In order to show the properties you ask for in the question, the main thing to note would be the Hadamard product functions identically to multiplication for scalars. Namely, associativity, this is unlike normal matrix multiplication. To see this note:

$$ {\bf I} \odot A \rightarrow {\bf I}_{\{i,j\}}A_{\{i,j\}}\\ $$

Where the lower indices represent a matrix element. The right-hand side of this equation technically represents $n^2$ scalar equations which when `stacked' correctly result in the left-hand side. Note that the right-hand side splits into two possibilities, $A_{\{i,j\}}$ if and only if $i=j$, otherwise $0$. For proving the properties asked for the indexed notation is simpler to work with. Take a matrix $B \in \mathbb{R}^{n\times n}$, then

$$ A + B \rightarrow A_{\{i,j\}} + B_{\{i,j\}} $$ Therefore looking at the sum of their diagonals

\begin{align*} diag(A)+diag(B) = {\bf I} \odot A + {\bf I} \odot B &\rightarrow {\bf I}_{\{i,j\}}A_{\{i,j\}} + {\bf I}_{\{i,j\}}B_{\{i,j\}} \\\ % &= {\Big \{}^{ \mbox{if $i=j$ } A_{\{i,j\}} + B_{\{i,j\}}}_{\mbox{otherwise 0}} \\\ &= {\bf I}_{\{i,j\}}\left(A_{\{i,j\}} + B_{\{i,j\}}\right)\\\ &\rightarrow diag(A+B) \end{align*}

Similarly, treating the objects similarly can be used for further proof. Additionally note that timesing the left and right of $\left({\bf I} \odot A\right)$ with a column vector of ones will result in the trace of a matrix. Specifically,

\begin{align*} Trace\left(A\right) = {\bf 1}^{\sf T}diag\left( A \right){\bf 1} ={\bf 1}^{\sf T}\left({\bf I} \odot A \right){\bf 1} \end{align*}

Therefore it is simple to see that the previously prooved property of the diag function also holds for the trace,

$$ Trace(A) + Trace(B) = Trace(A+B) $$

p32fr4
  • 119
  • 1
    interesting! Would you mind showing for example how to use your representation to prove the properties in the question? – Matifou Sep 13 '20 at 23:49
  • I updated to include a proof of the property wanted, there are certainly other ways of doing this probably simpler too, this way was just the first to pop into my head! – p32fr4 Sep 21 '20 at 08:45
  • 1
    thanks a lo, very interesting!! – Matifou Sep 21 '20 at 15:47
2

Compilation of comments:

1) The operator $\mathrm{diag}$ is a linear isomorphism between $\mathbb F^n$ and the subspace of $n\times n$ diagonal matrices. (EuYu) If both spaces are equipped with natural inner products, $\mathrm{diag}$ becomes an isometric isomorphism.

2) $\operatorname{diag}(u) = \sum_i u_i e_ie^T_i$ (Rein), where you can put $u_i=e_i^T u$ if you prefer.

40 votes
  • 9,736