# Thread: Help Creating A Matrix in Latex

1. ## Help Creating A Matrix in Latex

Hi, I need to make an nxn square matrix using Latex with 1's starting in the bottom left (n,1) all the way up to the top right (1,n) on that sort of opposite diagonal. I can't figure out to do it. Also, maybe I'm wrong, but I didn't think there was a way to do diagonal dots that go the opposite way of ddots. Ideally, I would like to place ones in row n, column 1 and then row 1, column n, with a kind of reverse diagonal dots in between, and no other elements anywhere else. I cannot figure out how to do this for the life of me. Can anyone help? Thank you.

2. Originally Posted by azdang
Hi, I need to make an nxn square matrix using Latex with 1's starting in the bottom left (n,1) all the way up to the top right (1,n) on that sort of opposite diagonal. I can't figure out to do it. Also, maybe I'm wrong, but I didn't think there was a way to do diagonal dots that go the opposite way of ddots. Ideally, I would like to place ones in row n, column 1 and then row 1, column n, with a kind of reverse diagonal dots in between, and no other elements anywhere else. I cannot figure out how to do this for the life of me. Can anyone help? Thank you.

3. I've tried looking at very similar websites with no such luck. I don't understand how to get blank spots where I want them and only put elements in the bottom left and top right of the matrix. And, I'm assuming the center of the matrix will have to be blank because there are no diagonal dots that go the reverse way so I would just have to draw them in after printing. I'm just completely confused on what to do. I've tried a bunch of ways, and I can't get anything to work.

4. Originally Posted by azdang
I've tried looking at very similar websites with no such luck. I don't understand how to get blank spots where I want them and only put elements in the bottom left and top right of the matrix. And, I'm assuming the center of the matrix will have to be blank because there are no diagonal dots that go the reverse way so I would just have to draw them in after printing. I'm just completely confused on what to do. I've tried a bunch of ways, and I can't get anything to work.
do you mean like this?

$\displaystyle \begin{pmatrix} & & a \\ & & \\ b & & \end{pmatrix}$

5. $\displaystyle I_{n}=\left[ \begin{matrix} 1 & 0 & \cdots & 0 \\ 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & 1 \end{matrix} \right]$

¿?

6. Originally Posted by azdang
Hi, I need to make an nxn square matrix using Latex with 1's starting in the bottom left (n,1) all the way up to the top right (1,n) on that sort of opposite diagonal. I can't figure out to do it. Also, maybe I'm wrong, but I didn't think there was a way to do diagonal dots that go the opposite way of ddots. Ideally, I would like to place ones in row n, column 1 and then row 1, column n, with a kind of reverse diagonal dots in between, and no other elements anywhere else. I cannot figure out how to do this for the life of me. Can anyone help? Thank you.
The control sequence \ddots is not a TeX primitive. It is constructed by a formula that is given on p.359 of Knuth's The TeXbook. You can modify this formula to define a "reverse \ddots", call it \revdots. The formula is

\def\revdots{\mathinner{\mkern1mu\raise1pt\vbox{\k ern7pt\hbox{.}}\mkern2mu\raise4pt\hbox{.}\mkern2mu \raise7pt\hbox{.}\mkern1mu}}

Using that macro, the input \begin{bmatrix}0&0&\ldots&1\\ \vdots&\vdots&\revdots&\vdots\\ 0&1&\ldots&0\\ 1&0&\ldots&0\end{bmatrix} will then generate the output $\displaystyle \begin{bmatrix}0&0&\ldots&1\\ \vdots&\vdots&\mathinner{\mkern1mu\raise1pt\vbox{\ kern7pt\hbox{.}}\mkern2mu\raise4pt\hbox{.}\mkern2m u\raise7pt\hbox{.}\mkern1mu}&\vdots\\ 0&1&\ldots&0\\ 1&0&\ldots&0\end{bmatrix}$.

(The implementation of TeX in this forum does not allow user-defined macros. So I had to incorporate the full definition of "\revdots" at the point where I wanted to use it. But in a normal TeX document you can put the definition at the beginning of the file, and then invoke it by writing \revdots each time you need it.)

7. Originally Posted by Jhevon
do you mean like this?

$\displaystyle \begin{pmatrix} & & a \\ & & \\ b & & \end{pmatrix}$
Yesss!!! Thank you so so much. I've been going crazy over this. Matrices in Latex are definitely not my strong suit. Thank you again!!

8. Originally Posted by azdang
Yesss!!! Thank you so so much. I've been going crazy over this. Matrices in Latex are definitely not my strong suit. Thank you again!!
i'm curious as to why you would want want such a form, the other forms given in this thread seem more conventional. but if that's what you want, i'm glad you're happy

9. I was working on a problem using Arnoldi's method to generate orthonormal bases for Krylov Spaces. I needed to show the matrix with these bases as its orthonormal columns, and the columns were $\displaystyle e_n,e_{n-1},...,e_1$, so I needed a sort of opposite Identity matrix. Whenever we use matrices in class with 0's elsewhere, my teacher just leaves those parts blank, so I didn't know how to do that.