11 Matrix Environment

Matrices

Like arrays, we use matrix  in math mode.
(a) Set the matrix in math mode with [latex].
(b) Type \begin{pmatrix}.
(c) Type your data, using & to separate columns and \\ to move to the next row.
(d) End the matrix with \end{pmatrix} and[/latex].

Example: 

\begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{pmatrix}

\begin{pmatrix} 1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1 \\
\end{pmatrix}

The other environments in this family are bmatrix (square brackets []), Bmatrix (curly braces {}), vmatrix (vertical lines | |), and Vmatrix (double vertical lines || ||).

Small Matrices

You can also provide small matrices to fit in-line [latex](\begin{smallmatrix} a & b \\ c & d \\ \end{smallmatrix})[/latex] with text. 

[latex](\begin{smallmatrix}a & b\\c & d\\ \end{smallmatrix})[/latex]

More Examples

Let us construct more complicated matrices.

Example: 

a)   \begin{bmatrix} 0 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 0 & \cdots & 0 \end{bmatrix}

\begin{bmatrix} 0 & \cdots & 0 \\ \vdots & \ddots & \vdots \\ 
0 & \cdots & 0 \end{bmatrix}
  • Note the use of the \vdots command to produce three vertical dots in that cell. You get horizontal dots by using \cdots and diagonal ones by using \ddots.

b) \begin{align}\begin{bmatrix} xz & xw\\ yz & yw \end{bmatrix}= \begin{bmatrix} x \\ y \end{bmatrix} \times \begin{bmatrix} z & w \end{bmatrix}\end{align}

\begin{align}\begin{bmatrix} xz & xw\\ yz & yw \end{bmatrix}= 
\begin{bmatrix} x \\ y \end{bmatrix} \times 
\begin{bmatrix} z & w \end{bmatrix}\end{align}

Exercises

Typeset the following equation:

\begin{align}\begin{vmatrix} a & b & c \\ d & e & f \\ g & h & i \end{vmatrix}= det \begin{bmatrix} a & b & c \\ d & e & f \\ g & h & i\\ \end{bmatrix}\end{align}

When you write a matrix whose entries are fractions, you might feel the lines are cramped. So to widen the gap between lines, use \\[6pt] instead of \\ .

Example: Using \\

[latex]A=\begin{bmatrix} \frac{1}{3} & \frac{1}{3} & \frac{1}{3} \\ \frac{2}{3} &\frac{-1}{3} &\frac{-1}{3} \\ \frac{1}{3} & \frac{1}{3} & \frac{-2}{3} \end{bmatrix}[/latex]

[latex]
A=\begin{bmatrix}
  \frac{1}{3} & \frac{1}{3} & \frac{1}{3} \\
   \frac{2}{3} &\frac{-1}{3} &\frac{-1}{3} \\
   \frac{1}{3} & \frac{1}{3} & \frac{-2}{3}
\end{bmatrix}
[/latex]

Example: Using \\[6pt]

[latex]A=\begin{bmatrix} \frac{1}{3} & \frac{1}{3} & \frac{1}{3} \\[6pt] \frac{2}{3} &\frac{-1}{3} &\frac{-1}{3} \\[6pt] \frac{1}{3} & \frac{1}{3} & \frac{-2}{3} \end{bmatrix}[/latex]

[latex]
A=\begin{bmatrix}
  \frac{1}{3} & \frac{1}{3} & \frac{1}{3} \\[6pt]
   \frac{2}{3} &\frac{-1}{3} &\frac{-1}{3} \\[6pt]
   \frac{1}{3} & \frac{1}{3} & \frac{-2}{3}
\end{bmatrix}
[/latex]

 


 

License

Icon for the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License

Using Latex in Pressbooks Copyright © 2021 by Sanja Krajisnik and Jelena Loncar is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License, except where otherwise noted.

Share This Book