# MandysNotes

Monday, 17 March 2014 15:07

## Matrices with Latex

By  Gideon
Rate this item

There are several matrix environments in Latex.

A very simple 2X2 matrix such as:

$\begin{pmatrix} a_{11} & a_{12} \\ \\ a_{21} & a_{22} \end{pmatrix}$

would be written as follows:

$\begin{pmatrix} a_{11} & a_{12} \\ \\ a_{21} & a_{22} \end{pmatrix}$

Note that the members of each row are separated by an "&" sign, and that the end of a row is signaled by a "\\."

The last row does not rquire a "\\."

The "\\" between rows is used to create space.

If we entered:

$\begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix}$

The resulting matrix would look like this:

$\begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix}$

A 3X3 matrix:

$\begin{pmatrix} a_{11} & a_{12} & a_{13} \\ \\ a_{21} & a_{22} & a_{23} \\ \\ a_{31} & a_{32} & a_{33} \end{pmatrix}$

is entered as:

$\begin{pmatrix} a_{11} & a_{12} & a_{13} \\ \\ a_{21} & a_{22} & a_{23} \\ \\ a_{31} & a_{32} & a_{33} \end{pmatrix}$

Here is an example of a matrix equation from special relativity (a Lorentz boost) using the "pmatrix" environment:

$\begin{pmatrix} v'_{0}\\ \\ v'_{1}\\ \\ v'_{2}\\ \\ v'_{3} \end{pmatrix} = \begin{pmatrix} \cosh{a} & \sinh{a} & 0 & 0 \\ \\ \sinh{a} & \cosh{a} & 0 & 0\\ \\ 0 & 0 & 1 & 0\\ \\ 0 & 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} v_{0}\\ \\ v_{1}\\ \\ v_{2}\\ \\ v_{3} \end{pmatrix}.$

$\begin{pmatrix} v'_{0}\\ \\ v'_{1}\\ \\ v'_{2}\\ \\ v'_{3} \end{pmatrix} = \begin{pmatrix} \cosh{a} & \sinh{a} & 0 & 0 \\ \\ \sinh{a} & \cosh{a} & 0 & 0\\ \\ 0 & 0 & 1 & 0\\ \\ 0 & 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} v_{0}\\ \\ v_{1}\\ \\ v_{2}\\ \\ v_{3} \end{pmatrix}.$

Here is the same matrix from the equation above written using the "bmatrix":

$\begin{bmatrix} \cosh{a} & \sinh{a} & 0 & 0 \\ \\ \sinh{a} & \cosh{a} & 0 & 0\\ \\ 0 & 0 & 1 & 0\\ \\ 0 & 0 & 0 & 1 \end{bmatrix}$

$\begin{bmatrix} \cosh{a} & \sinh{a} & 0 & 0 \\ \\ \sinh{a} & \cosh{a} & 0 & 0\\ \\ 0 & 0 & 1 & 0\\ \\ 0 & 0 & 0 & 1 \end{bmatrix}$

Here it is with the "vmatrix":

$\begin{vmatrix} \cosh{a} & \sinh{a} & 0 & 0 \\ \\ \sinh{a} & \cosh{a} & 0 & 0\\ \\ 0 & 0 & 1 & 0\\ \\ 0 & 0 & 0 & 1 \end{vmatrix}$

$\begin{vmatrix} \cosh{a} & \sinh{a} & 0 & 0 \\ \\ \sinh{a} & \cosh{a} & 0 & 0\\ \\ 0 & 0 & 1 & 0\\ \\ 0 & 0 & 0 & 1 \end{vmatrix}$

This is the "Bmatrix":

$\begin{Bmatrix} \cosh{a} & \sinh{a} & 0 & 0 \\ \\ \sinh{a} & \cosh{a} & 0 & 0\\ \\ 0 & 0 & 1 & 0\\ \\ 0 & 0 & 0 & 1 \end{Bmatrix}$

$\begin{Bmatrix} \cosh{a} & \sinh{a} & 0 & 0 \\ \\ \sinh{a} & \cosh{a} & 0 & 0\\ \\ 0 & 0 & 1 & 0\\ \\ 0 & 0 & 0 & 1 \end{Bmatrix}$

This is the "Vmatrix":

$\begin{Vmatrix} \cosh{a} & \sinh{a} & 0 & 0 \\ \\ \sinh{a} & \cosh{a} & 0 & 0\\ \\ 0 & 0 & 1 & 0\\ \\ 0 & 0 & 0 & 1 \end{Vmatrix}$

$\begin{Vmatrix} \cosh{a} & \sinh{a} & 0 & 0 \\ \\ \sinh{a} & \cosh{a} & 0 & 0\\ \\ 0 & 0 & 1 & 0\\ \\ 0 & 0 & 0 & 1 \end{Vmatrix}$