A matrix is a convenient way to organize many numbers in a table so you can work with them using clear rules. You’ll run into matrices all the time in linear algebra, numerical methods, programming, and data analysis. Why does this matter? Because a matrix lets you write systems of equations in a compact form, describe transformations, and perform calculations without confusion. So let’s go step by step: what a matrix is, where it’s used, and the most basic operations.
Matrix as a Table of Numbers: Definition and Notation
A matrix \( A \) of size \( m\times n \) is a rectangular table of numbers with \( m \) rows and \( n \) columns, where \( m,n\in\mathbb{N} \). It is written like this:
\[
A=\begin{pmatrix}
a_{11} & a_{12} & a_{13} & \dots & a_{1n}\\
a_{21} & a_{22} & a_{23} & \dots & a_{2n}\\
a_{31} & a_{32} & a_{33} & \dots & a_{3n}\\
\vdots & \vdots & \vdots & \ddots & \vdots\\
a_{m1} & a_{m2} & a_{m3} & \dots & a_{mn}
\end{pmatrix}.
\]
The numbers \( a_{ij} \) are called the elements of the matrix. The first index \( i \) shows the row number, and the second index \( j \) shows the column number. So the element \( a_{ij} \) is located at the intersection of the \( i \)-th row and the \( j \)-th column. A simple rule helps here: rows first, then columns.
For example, let
\[
A=\begin{pmatrix}
7 & 0 & -3\\
1 & 8 & -5
\end{pmatrix}.
\]
This matrix has size \( 2\times 3 \). In particular, \( a_{11}=7 \) and \( a_{23}=-5 \). It’s convenient: you can immediately see both the value and the position of an element.
Next, it’s useful to know two special cases. If there is only one row, we get a row matrix:
\[
A=\begin{pmatrix}
a_{11} & a_{12} & a_{13} & \dots & a_{1n}
\end{pmatrix}.
\]
And if there is only one column, we get a column matrix:
\[
B=\begin{pmatrix}
b_{11}\\
b_{21}\\
b_{31}\\
\vdots\\
b_{m1}
\end{pmatrix}.
\]
Such objects are often called vectors, and you’ll see them all the time in problems.
Matrix in Problems: Where It’s Used in Practice
Now a logical question: why introduce matrices at all if we could just write the numbers as a simple list? The point is that matrix notation gives a standard form for many problems and helps you apply well-known methods without rewriting everything again and again.
First, linear systems of equations. In numerical methods, this is one of the central topics. For example, the system
\[
\begin{cases}
2 \cdot x_1+3 \cdot x_2=5,\\
-x_1+4 \cdot x_2=6
\end{cases}
\]
can be written compactly as
\[
A \cdot x=b,
\quad
A=\begin{pmatrix}
2 & 3\\
-1 & 4
\end{pmatrix},
\quad
x=\begin{pmatrix}
x_1\\
x_2
\end{pmatrix},
\quad
b=\begin{pmatrix}
5\\
6
\end{pmatrix}.
\]
From here, you can apply Gaussian elimination, iterative methods, and error estimates. In practice, the solution is often found approximately, and the matrix form makes these computations much easier to organize and check.
Second, linear transformations in geometry and physics. Rotations, stretching, and reflections are often described by multiplying a matrix by a vector:
\[
y=T \cdot x.
\]
With one compact expression, you define the transformation rule and then compute the result for many different vectors.
Third, data and models. Matrices are widely used to represent data: rows can correspond to objects, and columns can correspond to features. On top of that, matrix computations are at the core of regression, the least squares method, and many algorithms for working with data.
So, a matrix helps you describe a problem compactly and work with it using clear rules. And with examples, you’ll see how this looks in real calculations step by step.
Matrix and Special Types: Square, Diagonal, Triangular
Let’s move on: matrices come in different forms, and some types have especially simple properties that are very useful in computations.
A matrix is called square if the number of its rows equals the number of its columns:
\[
A=\begin{pmatrix}
a_{11} & a_{12} & a_{13} & \dots & a_{1n}\\
a_{21} & a_{22} & a_{23} & \dots & a_{2n}\\
a_{31} & a_{32} & a_{33} & \dots & a_{3n}\\
\vdots & \vdots & \ddots & \ddots & \vdots\\
a_{n1} & a_{n2} & a_{n3} & \dots & a_{nn}
\end{pmatrix}.
\]
The elements \( a_{11},a_{22},a_{33},\dots,a_{nn} \) form the main diagonal.
For example,
\[
A=\begin{pmatrix}
1 & 5\\
4 & 2
\end{pmatrix}
\]
is a \( 2\times 2 \) square matrix. The main diagonal consists of the elements \( 1 \) and \( 2 \).
Next, if all elements below the main diagonal are zero, the matrix is upper triangular:
\[
U=\begin{pmatrix}
u_{11} & u_{12} & u_{13} & \dots & u_{1n}\\
0 & u_{22} & u_{23} & \dots & u_{2n}\\
0 & 0 & u_{33} & \dots & u_{3n}\\
\vdots & \vdots & \vdots & \ddots & \vdots\\
0 & 0 & 0 & \dots & u_{nn}
\end{pmatrix}.
\]
And if the zeros are above the main diagonal, we get a lower triangular matrix:
\[
L=\begin{pmatrix}
\ell_{11} & 0 & 0 & \dots & 0\\
\ell_{21} & \ell_{22} & 0 & \dots & 0\\
\ell_{31} & \ell_{32} & \ell_{33} & \dots & 0\\
\vdots & \vdots & \vdots & \ddots & \vdots\\
\ell_{n1} & \ell_{n2} & \ell_{n3} & \dots & \ell_{nn}
\end{pmatrix}.
\]
These matrices often appear in algorithms such as LU decomposition and during the steps of Gaussian elimination.
There is also a diagonal matrix, where all elements outside the main diagonal are zeros:
\[
D=\begin{pmatrix}
d_{1} & 0 & 0 & \dots & 0\\
0 & d_{2} & 0 & \dots & 0\\
0 & 0 & d_{3} & \dots & 0\\
\vdots & \vdots & \vdots & \ddots & \vdots\\
0 & 0 & 0 & \dots & d_{n}
\end{pmatrix}.
\]
A special case is the identity matrix:
\[
I=\begin{pmatrix}
1 & 0 & 0 & \dots & 0\\
0 & 1 & 0 & \dots & 0\\
0 & 0 & 1 & \dots & 0\\
\vdots & \vdots & \vdots & \ddots & \vdots\\
0 & 0 & 0 & \dots & 1
\end{pmatrix}.
\]
It plays the role of “one” in matrix calculations: multiplying by \( I \) does not change a matrix or a vector. In some literature, it may also be denoted by the letter \( E \).
And finally, the zero matrix:
\[
O=\begin{pmatrix}
0 & 0 & 0 & \dots & 0\\
0 & 0 & 0 & \dots & 0\\
0 & 0 & 0 & \dots & 0\\
\vdots & \vdots & \vdots & \ddots & \vdots\\
0 & 0 & 0 & \dots & 0
\end{pmatrix}.
\]
Just like zero in ordinary arithmetic, it follows simple rules in addition and multiplication.
Basic Operations with Matrices: Rules and Important Checks
Now let’s get to the most practical part: which matrix operations are used most often? There is one key point here—before doing any operation, it’s really helpful to check the dimensions first. This is where mistakes happen most frequently, and examples make that especially clear.
Multiplying a Matrix by a Number
If \( \alpha \) is a number, then multiplying \( \alpha \cdot A \) means that every element of the matrix is multiplied by \( \alpha \):
\[
B=\alpha \cdot A,\qquad b_{ij}=\alpha \cdot a_{ij}.
\]
Addition and Subtraction
You can add matrices only if they have the same dimensions. If \( A \) and \( B \) are the same size, then
\[
C=A+B,\qquad c_{ij}=a_{ij}+b_{ij}.
\]
Subtraction is defined in the same way:
\[
C=A-B,\qquad c_{ij}=a_{ij}-b_{ij}.
\]
If the dimensions are different, then addition and subtraction are not defined—so it’s worth checking this right away.
Matrix Multiplication
The product \( A \cdot B \) is defined only when the matrices are compatible in size. Let \( A \) have dimensions \( m \times k \), and let \( B \) have dimensions \( k\times n \). Then the product exists:
\[
A_{m\times k}\cdot B_{k\times n}=C_{m\times n}.
\]
The elements of the matrix \( C \) are computed by the formula
\[
c_{ij}=\sum_{s=1}^{k} a_{is} \cdot b_{sj}.
\]
In other words, you take the \( i \)-th row of \( A \) and the \( j \)-th column of \( B \), multiply the corresponding entries, and add them up.
One more important point: in general, \( A \cdot B\neq B \cdot A \). It can even happen that \( A \cdot B \) exists, but \( B \cdot A \) does not, because the dimensions do not match. So the order of multiplication always matters.
Raising a Square Matrix to a Power
If \( A \) is a square matrix and \( m>0 \), then
\[
A^{m}=\underbrace{A\cdot A\cdot A\cdot \dots \cdot A}_{m}.
\]
Transposition
Transposition swaps rows and columns:
\[
A=\begin{pmatrix}
a_{11} & a_{12} & a_{13} & \dots & a_{1n}\\
a_{21} & a_{22} & a_{23} & \dots & a_{2n}\\
a_{31} & a_{32} & a_{33} & \dots & a_{3n}\\
\vdots & \vdots & \vdots & \ddots & \vdots\\
a_{m1} & a_{m2} & a_{m3} & \dots & a_{mn}
\end{pmatrix},
\qquad
A^{T}=\begin{pmatrix}
a_{11} & a_{21} & a_{31} & \dots & a_{m1}\\
a_{12} & a_{22} & a_{32} & \dots & a_{m2}\\
a_{13} & a_{23} & a_{33} & \dots & a_{m3}\\
\vdots & \vdots & \vdots & \ddots & \vdots\\
a_{1n} & a_{2n} & a_{3n} & \dots & a_{mn}
\end{pmatrix}.
\]
This operation is often needed both in theory and in numerical methods—for example, when working with symmetric matrices or when moving to expressions of the form \( A^{T}\cdot A \).
Matrix in Practice: Step-by-Step Calculation Examples
Now let’s move to practice. Examples are the best way to see where it’s easy to make a mistake and what you should check before doing calculations. Each example below includes a complete solution, but it’s better to try solving it on your own first and only then compare your answer step by step.
Example 1. Find the sum of matrices \( A \) and \( B \)
\[
A=\begin{pmatrix}
2 & -1\\
3 & 4
\end{pmatrix},
\qquad
B=\begin{pmatrix}
5 & 6\\
-2 & 1
\end{pmatrix}.
\]
Both matrices have size \( 2\times 2 \), so addition is defined. We add them element by element:
\[
A+B=\begin{pmatrix}
2+5 & -1+6\\
3+(-2) & 4+1
\end{pmatrix}
=\begin{pmatrix}
7 & 5\\
1 & 5
\end{pmatrix}.
\]
We got a matrix of the same size \( 2\times 2 \), as expected.
Example 2. Find the product of matrix \( A \) and the number \( \alpha \)
\[
A=\begin{pmatrix}
-3 & 2 & 0\\
1 & -4 & 5
\end{pmatrix},
\qquad \alpha=2.
\]
Multiplying \( \alpha\cdot A \) means that every element of the matrix is multiplied by \( \alpha \). In our case \( \alpha=2 \), so we get:
\[
2 \cdot A=\begin{pmatrix}
2\cdot(-3) & 2\cdot 2 & 2\cdot 0\\
2\cdot 1 & 2\cdot(-4) & 2\cdot 5
\end{pmatrix}
=\begin{pmatrix}
-6 & 4 & 0\\
2 & -8 & 10
\end{pmatrix}.
\]
The dimensions do not change when you multiply by a number: it was \( 2\times 3 \) and it stays \( 2\times 3 \).
Example 3. Find the product of matrices \( A\cdot B \)
\[
A=\begin{pmatrix}
1 & 2 & -1\\
0 & 3 & 4
\end{pmatrix},
\qquad
B=\begin{pmatrix}
2 & 1\\
-1 & 0\\
3 & 2
\end{pmatrix}.
\]
Matrix \( A \) has size \( 2\times 3 \), and matrix \( B \) has size \( 3\times 2 \). The number of columns of the first equals the number of rows of the second, so the product \( A\cdot B \) exists and will have size \( 2\times 2 \). We compute the elements:
\[
A \cdot B=\begin{pmatrix}
c_{11} & c_{12}\\
c_{21} & c_{22}
\end{pmatrix}.
\]
Find \( c_{11} \) as the product of the first row of \( A \) with the first column of \( B \):
\[
c_{11}=1\cdot 2+2\cdot(-1)+(-1)\cdot 3=2-2-3=-3.
\]
Next, \( c_{12} \) is the first row of \( A \) times the second column of \( B \):
\[
c_{12}=1\cdot 1+2\cdot 0+(-1)\cdot 2=1+0-2=-1.
\]
Now move to the second row:
\[
\begin{gathered}
c_{21}=0\cdot 2+3\cdot(-1)+4\cdot 3=0-3+12=9,\\[4pt]
c_{22}=0\cdot 1+3\cdot 0+4\cdot 2=0+0+8=8.
\end{gathered}
\]
So,
\[
A \cdot B=\begin{pmatrix}
-3 & -1\\
9 & 8
\end{pmatrix}.
\]
Notice: if we swapped the order and took \( B\cdot A \), the sizes would be \( 3\times 2 \) and \( 2\times 3 \). That product would also exist, but the result would have a completely different size \( 3\times 3 \). The order of multiplication really matters.
Example 4. Find the transposed matrix \( A^{T} \)
\[
A=\begin{pmatrix}
4 & -2 & 7\\
1 & 0 & -3
\end{pmatrix}.
\]
Transposition swaps rows and columns. So the columns of \( A \) become the rows of \( A^{T} \):
\[
A^{T}=\begin{pmatrix}
4 & 1\\
-2 & 0\\
7 & -3
\end{pmatrix}.
\]
The check is simple: \( A \) has size \( 2\times 3 \), so \( A^{T} \) should have size \( 3\times 2 \). That’s exactly what we got.
Example 5. Raise the matrix to the second power
\[
A=\begin{pmatrix}
1 & 2\\
3 & 0
\end{pmatrix}.
\]
Let’s find \( A^{2} \). By definition,
\[
A^{2}=A\cdot A.
\]
Multiply:
\[
A^{2}=\begin{pmatrix}
1 & 2\\
3 & 0
\end{pmatrix} \cdot
\begin{pmatrix}
1 & 2\\
3 & 0
\end{pmatrix}
=
\begin{pmatrix}
1\cdot 1+2\cdot 3 & 1\cdot 2+2\cdot 0\\
3\cdot 1+0\cdot 3 & 3\cdot 2+0\cdot 0
\end{pmatrix}
=
\begin{pmatrix}
7 & 2\\
3 & 6
\end{pmatrix}.
\]
This is a common mistake: \( A^{2} \) is not the square of each element. It is the product \( A\cdot A \) (for a square matrix \( A \)) using the rules of matrix multiplication.
Matrix at the Next Level: Topics to Continue With
You already understand the basic operations with matrices, so it naturally makes you want to go further, right? Below are three topics that logically build on this material and greatly expand your understanding of matrix computations.
- Inverse of a Matrix: How to “Undo” Multiplication — We will briefly explain when an inverse matrix exists, how it is found, and what it means in calculations.
- Pseudoinverse of a Matrix: A Solution when an Inverse Doesn’t Exist — We will explain the idea of the pseudoinverse and why it is useful for stable numerical computations.
- Determinant of a Matrix: What It Shows and Why It Is Computed — We will show what the determinant actually represents, how to interpret it, and what conclusions it gives about a matrix.
Matrix in Code: Turning Flowcharts into Small Programs
If you want to see how matrix rules work not only on paper but also in real practice, these flowcharts can be a great support. Pick any programming language you like and try writing small programs that perform the basic matrix operations: addition and subtraction, multiplying a matrix by a number, transposition, matrix multiplication, and raising a matrix to a power. This is truly motivating, because you immediately see the result, you can plug in your own data, and you can check yourself without extra doubts. Plus, these mini-programs can easily grow into useful tools for learning or for your own projects—where matrices show up more often than it might seem at first glance.
