# Diagonal Matrix from vector

1. Feb 15, 2008

### hotvette

Perhaps a silly question. I have a vector:

$$a=[a_1 \ a_2 \ a_3 \ ...\ a_n]^T$$

that I want to turn into a diagonal matrix. Is there an elegant way to represent this? I thought maybe something like:

$$a^TI$$

would do, but it doesn't. I suppose I can use the kronecker delta and subscript form:

$$b_{ij} = \delta_{ij}a_i$$

but how would this be done in matrix form?

2. Feb 16, 2008

### CompuChip

I think it is common notation to denote a diagonal matrix such as
$$\begin{pmatrix} \lambda_1 & 0 & 0 & \cdots & 0 \\ 0 & \lambda_2 & 0 & \cdots & 0 \\ 0 & 0 & \lambda_3 & & \vdots \\ \vdots & 0 & 0 & \ddots & 0 \\ 0 & 0 & 0 & 0 & \lambda_n \\ \end{pmatrix}$$
as
$$\operatorname{diag}(\lambda_1, \lambda_2, \cdots, \lambda_n)$$.
So you could write
$$\operatorname{diag}(a_1, a_2, \cdots, a_n)$$
and everyone will know what you mean, and you can even write
$$\operatorname{diag}(\vec a)$$
to mean just that (though you should define it explicitly, just to be clear).

3. Jul 1, 2008

### bilgealp

$$\operatorname{diag}(\lambda_1, \lambda_2, \cdots, \lambda_n)$$ seems OK but does not look good in long equations.

Some writers prefer to add a superscript $$D$$ as in $$a^D$$.
I always use small letters for vectors and capital letters for matrices. And if you combine this rule with the difference between braces and brackets, then the case is also resolved. In general braces ($$\{...\}$$) are used to denote vectors, and brackets for matrices ($$[...]$$). So a small letter in brackets is nothing but a diagonal matrix with the elements of a vector as its diagonal entries.
If you would like...

4. Jun 15, 2011

### boman131

you can use a vector times a bold 1, i.e a1

5. Jun 15, 2011

### micromass

Staff Emeritus
This thread is 3 years old...

6. Jul 3, 2013

### jbgm

So what? This information stays online for years. A delayed answer might not help the person who asked the question in the first place, but it could help the larger community.

7. Jul 3, 2013

### CompuChip

Wow... and you registered just to make that remark? :)

8. Jul 3, 2013

9. Jul 3, 2013

### D H

Staff Emeritus
A nearly perfect answer was given over 5 years ago in post #2:

My only gripe: the parenthetical remark though you should define it explicitly, just to be clear. I can see only two possible outcomes if some reviewer said that about my use $\operatorname{diag}(\vec a)$ in some math:
• Aggressive. Reject the comment with
Really?! Are you serious? We lost the people who don't understand $\operatorname{diag}(\vec a)$ on page 2.

• Passive aggressive. Modify the offending equation with
$$\mathrm A = \cdots \operatorname{diag}(\vec a) \cdots \ \ \text{where} \operatorname{diag}(\vec a) = \sum\nolimits_i a_i e_i e_i^T$$