In general any linear transformation can be represented using matrices in the following way:
This said, i won't explain the math behind matrices any further and i will go on now with the Latex code necessary to replicate both the linear transformation and the matrix above.
For starting i will assume that the basics of latex mathematical enviroment are known (if this isn't the case, the reader is invited to read this first), and therefore they won't be re-explained here.
I will now make an example to clarify:
\begin{align}
ax= a_1 +a_2+a_3+a_4\cdots a_n\\
y=b_1 + b_2 +b_3+b_4\cdots b_m\\
a_n,b_n\in\mathbb{b}\quad m,n\in\mathbb{N}\\
\end{align}
\begin{align}
&x= a_1 +a_2+a_3+a_4\cdots a_n\\
&y=b_1 + b_2 +b_3+b_4\cdots b_m\\
&a_n,b_n\in\mathbb{b}\quad m,n\in\mathbb{N}\\
\end{align}
\begin{align*}
&x: & a_1 +a_2+a_3+a_4\cdots a_n\\
&y: &b_1 + b_2 +b_3+b_4\cdots b_m\\
&a_n,b_n\in\mathbb{R} & m,n\in\mathbb{N}\\
\end{align*}
\end{align*}
The reader should now notice clearly the similarities between this enviroment and a table.
To sum up the important concepts:
To align multiple expressions to 1 or multiple points the following code is necessary.\begin{align}
0-th field (if any) & first field to align &second field to align...& n-th field to align\\
0-th field (if any) & first field to align &second field to align...&b-th field to align\\
...
\end{align}
\begin{align*}...\end{align*}
We saw that the align enviroment share some similarities with the tables, this said matrices are almost identical to tables. In fact the \\ indicates the end of a row and the & symbols indicates that end of the element of that coloumn in that row. It is also worth noting that three different parenthesis can be made for the matrices. Let's make an example to clarify:
\begin{pmatrix}
a_{11}&a_{12}\\
a_{21}&a_{22}}\\
\end{pmatrix}
Of corse the members of the matrix can be any symbol or expression:
\begin{vmatrix}
a_{11}&a_{12}&\cdots&a_{1n}\\
a_{21}&a_{22}&\cdots&a_{2n}\\
\vdots &\vdots& \ddots&\vdots\\
\displaystyle\sum_{k=1}^n k&\cdots&
\sin\epsilon&x^{\frac{\phi}{3}}\\
\end{vmatrix}
To sum up the important concepts
To make a matrix with square brackets:\begin{bmatrix}...\end{bmatrix}
\begin{pmatrix}...\end{pmatrix}
\begin{vmatrix}...\end{vmatrix}
\begin{matrix}...\end{matrix}
\begin{matrix}
firstrow first element & firstrow second element & ...firstrow n-th element\\
2-ndrow first element & 2-ndrow second element & ...2-ndrow n-th element\\
...
m-throw first element & m-throw second element & ...m-throw n-th element\\
\end{matrix}
Example:
$\vec{v}=
\begin{pmatrix}
a1\\
a2\\
\end{pmatrix}$