IDENTITY & DIAGONAL MATRICES
Write identity, diagonal and rectangular matrices in LaTeX
Examples checked with MathTexLab’s base and AMS math renderer · Display style
An identity matrix is square, with ones on the main diagonal and zeros elsewhere. A diagonal matrix can use other values on that diagonal. These are patterns of entries, not different bracket environments.
Write an explicit identity matrix
For three rows and columns, put a one in cells (1,1), (2,2) and (3,3), and zeros elsewhere. The subscript on the letter records the intended size. The example writes every entry so the source is easy to inspect.
I_3=\begin{bmatrix}1&0&0\\0&1&0\\0&0&1\end{bmatrix}Open example in editor Change the diagonal values
To build a diagonal example, replace those three ones with values such as 2, 5 and 7. Keep the off-diagonal cells zero. Blank cells in the Matrix Generator also output zero, but writing zeros explicitly can make the grid easier to check before copying.
Separate dimensions from notation
A matrix can be rectangular. Three rows and two columns describe a 3-by-2 shape; it is not a square identity matrix. Changing brackets does not change dimensions. Count the columns in each source row if you are checking copied TeX by hand.
Avoid implying an evaluated result
A generator preset writes a pattern into the grid; it does not test whether an arbitrary matrix is invertible or calculate its inverse. If you include a statement about multiplication or a determinant beside the matrix, verify that claim independently. For a large example, inspect the scrollable preview and export at a readable size rather than forcing every entry into a narrow paragraph.
Syntax reference
MathJax supported-command reference. The examples above are limited to the features described here; additional packages are not implied.
Continue with LaTeX Matrix Generator.