Matrices in Latex

amsmath is an extension package that provides various features for writing math formulas.

Example (one Dimensional)

\documentclass[12pt]{article}
\usepackage{amsmath} % including amsmath package
\begin{document}

$$
\frac{1}{2}
 \begin{bmatrix}
  -1 & 8 & 0 & -8 & 1 \\
 \end{bmatrix}
$$

\end{document}

Output


matrix

Example (Two Dimensional)

\documentclass[12pt]{article}
\usepackage{amsmath} % including amsmath package
\begin{document}

$$
 \begin{bmatrix}
  1/256 & 1/64 & 22 & 1/64 & 1/256 \\
  1/64   &  1/16 & 3/32 & 3 & 1/64 \\
  21 & 33 & 9/64 & 2 & 3/128 \\
  1/64 & 1/16 & 3/32 & 1/16 & 1/64 \\
  1/256 & 1/64 & 18 & 1/64 & 56
 \end{bmatrix}
$$
\end{document}

Output


matrix

Example (Matrix Multiplication)

\documentclass[12pt]{article}
\usepackage{amsmath} % including amsmath package
\begin{document}

$$
\begin{bmatrix}
\sum{wI_x}^2 \hspace{6 mm}  \vspace{2mm} \sum{wI_x I_y}^2 \\
\sum{wI_x I_y} \hspace{5 mm}  \vspace{2mm} \sum{wI_y}^2 
\end{bmatrix}
\begin{bmatrix}
\vspace{4mm}
a \\ 
b
\end{bmatrix}
= 
 -\begin{bmatrix}
\vspace{4mm}
\sum{wI_x I_y}^2 \\

\sum{wI_x I_y}^2
\end{bmatrix}
$$
\end{document}

Output


matrix

Share

You may also like...