Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Excuse me for this basic question, but when reading some mathematic books I have encountered the following matrix:

W = 2diag([1 1 0,01])

Could anybody explain to me how can I read this? Is it just a diagonal matrix multiplied by 2?

share|cite|improve this question
In which book have you read? – lavkush Jul 3 '14 at 14:27
Actually it is PhD thesis of one of my lecturers (unfortunatelly not in English) and I am wondering what did he think about writing matrix this way. – Niemand Jul 3 '14 at 14:30
I am not sure, he may mean decimal by , this. – lavkush Jul 3 '14 at 14:34
Yup, sometimes I forget than in my country we use , instead of ., it's sick :(. – Niemand Jul 3 '14 at 15:02
up vote 5 down vote accepted

My guess would be $\texttt{2diag([1 1 0,01])}=\begin{bmatrix}2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 0,02 \end{bmatrix}.$

share|cite|improve this answer
Presumably the comma is then a decimal separator? – Théophile Jul 3 '14 at 14:32
@Théophile, Yes. – user35603 Jul 3 '14 at 14:33
I thought that it was more matlab-like style to separate rows, but you kind of opened my eyes. Thank you! – Niemand Jul 3 '14 at 14:35
Ahhhh! The different radix fooled me. – John Jul 3 '14 at 14:45
I was thinking "second diagonal", perhaps the antidiagonal or the diagonal right above or below the main diagonal. – user2357112 Jul 3 '14 at 15:44

The most reliable way could be to ask your lecturer, otherwise there could be a missing or extra multiplication by $2$.

The line

W = 2diag([1 1 0,01])

in the question has been typeset as it could be a code from the program. It is not clear whether this is deliberate or occasional, and whether this is exactly how it looks like in the thesis. Moreover, []-brackets inside ()-brackets strengthen the conjecture that it could be a code from the program. It seems quite viable that the program has a function 2diag (using a naming convention to put 2 instead of to) that takes a list (cf. [...] syntax) and creates a corresponding diagonal matrix of an appropriate dimension. This way, 2diag([1 1 0,01]) will create $3x3$ matrix with $1$, $1$ and $0,01$ on its main diagonal. However, if this notation actually means $$2\,\times\,\text{diag}\{1,1,0.01\}$$ then the diagonal of the resulting matrix will be $2$, $2$ and $0,02$. That's why one should be careful.

share|cite|improve this answer
There are languages where a number followed by identifier is parsed as number multiplied by that identifier, e.g. in Mathematica 2a would be equivalent to 2*a. – Ruslan Jul 3 '14 at 18:30
@Ruslan - thanks! This remark shows that there could be even more confusion if the formula is taken out of context. As for Mathematica, I presume in this case the 1st character of the identifier can not be a digit? – Alexander Konovalov Jul 3 '14 at 19:47
Yes, a digit can't start identifier name. Frankly, I don't even know what languages do allow this. – Ruslan Jul 3 '14 at 21:07
@Ruslan: for example, in GAP, an identifier may contain letters, digits, symbols _ and @, and must contain at least one non-digit, but the position of that is not specified; thus, 100x is a valid identifier in GAP - see here – Alexander Konovalov Jul 3 '14 at 21:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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