Diagonal matrix formula

westin

Junior Member
Joined
Sep 11, 2021
Messages
68
Assume a matrix of size 3 x 3 (n x n). In this case, n =3

From a solution, it stated that all the diagonals (i , j) has the same value using this formula [(i + (n-1 -j)) mod n]

for example, below, the main light blue diagonal coordinates (0,0) , (1,1) , (2,2) . all has a value of 2 [using (0,0) as an example, formula (0 + (3-1-1)) mod 3 = 2]

also, the dark blue diagonal (1,0), (2,1), (0,2), all has value of 1

I tried to search the internet and could not see anything article related to this formula. I like to understand the rationale behind it in layman terms so that I do not have to memorize it. Anything that can help me understand it more will be great. Thanks!!!

1649801804266.png
 
[imath]\left ( \begin{matrix} 2 & 1 & 0 \\ 0 & 2 & 1 \\ 1 & 0 & 2 \end{matrix} \right )[/imath]

What is your question?

-Dan
 
The question is why do that formula works? Like to understand the rationale behind it.
 
The question is why do that formula works? Like to understand the rationale behind it.
Let me be more clear. You gave a definition for the matrix. But that is all you gave. What are you trying to use it for?

-Dan
 
Assume a matrix of size 3 x 3 (n x n). In this case, n =3

From a solution, it stated that all the diagonals (i , j) has the same value using this formula [(i + (n-1 -j)) mod n]

for example, below, the main light blue diagonal coordinates (0,0) , (1,1) , (2,2) . all has a value of 2 [using (0,0) as an example, formula (0 + (3-1-1)) mod 3 = 2]

also, the dark blue diagonal (1,0), (2,1), (0,2), all has value of 1

I tried to search the internet and could not see anything article related to this formula. I like to understand the rationale behind it in layman terms so that I do not have to memorize it. Anything that can help me understand it more will be great. Thanks!!!

View attachment 32102
Where did you get the formula, and what does it claim to do?

You say this is "from a solution". What problem is it a solution to, and can you show the whole thing to us, so we can determine the context of the formula?
 
Hi, this is a coding problem (below). basically, the coding algorithm solution is based on the formula i + (n-1-j) mod n. I am just wondering why all the same diagonal coordinates have the same value. Is there a easy to understand mathematical reason/proof behind it.

 
Hi Dan,

When you said that is the definition of matrix. is that formula a simple properties of matrix? do you have something that I can read to better understand how it works?

thanks
 
Maybe I need some coffee. You gave a rule that gives the numbers for the elements of the matrix I posted in post #2. I still don't know what you are asking about. How to get those numbers from the formula you gave? Are you asking how to use that matrix? What properties that specific matrix has?

-Dan
 
Maybe I need some coffee. You gave a rule that gives the numbers for the elements of the matrix I posted in post #2. I still don't know what you are asking about. How to get those numbers from the formula you gave? Are you asking how to use that matrix? What properties that specific matrix has?

-Dan
I suspect the coffee (and a good night's sleep) are the right idea for you, Dan. ?

The link the OP posted doesn't even mention the "formula" s/he's asking about and it looks to me (not that I understand much of anything that s/he is saying, lol) that it's not so much about matrices themselves (or their content or usage) but rather about patterns that evolve based on connections between matrices' elements' subscript indices. (But what the heck do I know? lmao)

Might this be more related to a series of parallel lines with the equations: \(\displaystyle y=-kx\)??? ?
 
the main light blue diagonal coordinates (0,0) , (1,1) , (2,2) . all has a value of 2 [using (0,0) as an example, formula (0 + (3-1-1)) mod 3 = 2]
For the main diagonal [imath]i=j[/imath], thus [math](i + (n-1 -j)) \mod n\\ (\cancel{i} + (n-1 -\cancel{i})) \mod n \\ (n-1) \mod n\\ n-1[/math]

For the upper dark blue diagonal, [imath]i=j-1[/imath], thus [math](i + (n-1 -j)) \mod n\\ (j-1 + (n-1 -j)) \mod n\\ (n-2) \mod n \\ n-2[/math]
the dark blue diagonal (1,0), (2,1), (0,2), all has value of 1
Not true for the lower dark blue diagonal, they're all 0. Since [imath]j=i-1[/imath], thus [math](i + (n-1 -j)) \mod n\\ (i + (n-1 -(i-1))) \mod n\\ n \mod n\\ 0[/math]
 
Last edited:
Hi,

hope this is more clear. Why when I use the formula to convert the i, j coordinates, the cells within the same diagonal has the same constant value. for example, the main diagonal (yellow) has a constant value of 3. I know this formula works but I don't know the rationale behind it and would like to learn and read more if there is anything related to it. When doing the coding, I am not sure how to think about this algorithm without someone telling me. Just like to learn what is the thought process of coming up with this formula. THANKS again.

1649862840632.png
 
Hi,

hope this is more clear. Why when I use the formula to convert the i, j coordinates, the cells within the same diagonal has the same constant value. for example, the main diagonal (yellow) has a constant value of 3. I know this formula works but I don't know the rationale behind it and would like to learn and read more if there is anything related to it. When doing the coding, I am not sure how to think about this algorithm without someone telling me. Just like to learn what is the thought process of coming up with this formula. THANKS again.

View attachment 32113
I have no context to the problem, so I can't tell you why they make the diagonal values equal to n-1 i.e. 3 in the case of 4x4.
 
Please disregard the coding problem. This should be a property of a diagonal matrix that they have a constant value based on this or any formula if they are in the same diagonal. I just like someone to explain it in an intuitive way to think of such formula so that I don't have to memorize it. Maybe an intuitive way does not exist, just want to tap you maths gurus to get more out of it. No worries if there is none.
 
Here's what I think (which may help you understand what's going on?):-   ?

Your formula: \(\displaystyle [i-(n-1-j)] mod n\)

may be re-arranged as: \(\displaystyle [(n-1)+(i-j)] mod n\)

and thence as: \(\displaystyle [(n-1) mod n + (i-j)] mod n\)

but \(\displaystyle [(n-1) mod n\) is just equal to \(\displaystyle (n-1)\)!

So, on the main diagonal, where \(\displaystyle i=j (\Rightarrow(i-j)=0)\), then every entry is just (n-1)!

Then, when you move to diagonals above and to the right, (i-j) becomes -1, -2 , -3, etc., hence the entries along these diagonals become:- [(n-2), (n-3), (n-4),...,2, 1, 0].

But, when you move to diagonals below and to the left, (i-j) becomes 1, 2 , 3, etc., hence the entries along these diagonals become:- [n, (n+1), (n+2),...] mod n.

Maybe someone else who is an absolute whiz at modular arithmetic can say whether my analysis is correct (or not) but I doubt whether you're going to get any better "explanation" about your query.

Hope that helps. :)
 
Afterthought:-

If you want a "simple" way to think of it, when an (n x n) matrix is defined by your "formula", then the main diagonal is always (n-1) and those above reduce to zero while, below the main diagonal, the pattern from the top right-hand corner to the main diagonal:-

([0, 1, 2, ..... (n-2), (n-1)])
is repeated until the bottom left-hand corner is reached.
??
 
Here's what I think (which may help you understand what's going on?):-   ?
Your formula: \(\displaystyle [i-(n-1-j)] mod n\)
may be re-arranged as: \(\displaystyle [(n-1)+(i-j)] mod n\)
Shouldn't that last line be \(\displaystyle [(1-n)+(i+j)] mod n\).
In fact I am sure that what I wrote is correct. In case what you wrote is also correct can you please show me how you get that. Thanks Highlander
 
Hi Highlander, This is great stuff!!!. Thank you very much exactly what I am looking for. I think I understand it more now instead of memorizing the "formula". thanks!!! thanks!! and thank you all for the help!!!
 
Shouldn't that last line be \(\displaystyle [(1-n)+(i+j)] mod n\).
Hi Steven,

No, I don't think so.

What you've written
(\(\displaystyle [(1-n)+(i+j)] mod n\)) would be correct if the first line in my post were also correct but I'm afraid it is wrong! ?

Whereas I typed:-
               Your formula: \(\displaystyle [i-(n-1-j)] mod n\)

               may be re-arranged as: \(\displaystyle [(n-1)+(i-j)] mod n\)

What I should have typed was:-

               Your formula: \(\displaystyle [i+(n-1-j)] mod n\)

               may be re-arranged as: \(\displaystyle [(n-1)+(i-j)] mod n\)

Which I believe is (now) correct and consistent with the remainder of the post's 'algebraic manipulation'. (If you check back to the OP you will see that I have mistyped the original "formula" in my first line, inserting a -sign instead of a +sign!)

However, do let me know if there are any other errors you spot. Modular arithmetic is something I have spent virtually zero time using; it's pretty much just a 'curiosity' as far as I'm concerned so I have no great confidence in my subsequent re-arrangements' accuracies, lol.

But the OP seems happy and if nobody else wants to challenge it then I think we may have reached a happy conclusion on this particular thread. ?

Does that address your concern?
 
Hi Steven,

No, I don't think so.

What you've written
(\(\displaystyle [(1-n)+(i+j)] mod n\)) would be correct if the first line in my post were also correct but I'm afraid it is wrong! ?

Whereas I typed:-
               Your formula: \(\displaystyle [i-(n-1-j)] mod n\)

               may be re-arranged as: \(\displaystyle [(n-1)+(i-j)] mod n\)

What I should have typed was:-

               Your formula: \(\displaystyle [i+(n-1-j)] mod n\)

               may be re-arranged as: \(\displaystyle [(n-1)+(i-j)] mod n\)

Which I believe is (now) correct and consistent with the remainder of the post's 'algebraic manipulation'. (If you check back to the OP you will see that I have mistyped the original "formula" in my first line, inserting a -sign instead of a +sign!)

However, do let me know if there are any other errors you spot. Modular arithmetic is something I have spent virtually zero time using; it's pretty much just a 'curiosity' as far as I'm concerned so I have no great confidence in my subsequent re-arrangements' accuracies, lol.

But the OP seems happy and if nobody else wants to challenge it then I think we may have reached a happy conclusion on this particular thread. ?

Does that address your concern?
I concentrated on that last line and never verified the first line. All looks good to me.
 
Top