Matrix Calculator
Perform calculations with matrices including addition, subtraction, and multiplication.
Understanding Matrix Calculator
A matrix is a rectangular arrangement of numbers organized into rows and columns. Matrices are commonly written using dimensions such as 2 × 2, 2 × 3, or 3 × 4, where the first number represents the number of rows and the second represents the number of columns. They are an important part of linear algebra and are widely used in systems of equations, geometry, computer graphics, statistics, physics, engineering, data analysis, and numerical methods.
This Matrix Calculator performs three common operations: matrix addition, matrix subtraction, and matrix multiplication. The rules for these operations are different, so the dimensions of the input matrices must be checked before a calculation can be performed.
How to get a useful estimate
Matrix Calculator is intended to show the mathematical relationship behind the answer, not just return a number. Enter the quantities requested by the selected method—such as Matrix A, Matrix B, Operation—and keep their units or mathematical meaning consistent. Where this calculator offers different shapes, methods, or forms, choose the one that matches the problem before entering the values.
When the result is an estimate
For a useful check, look at the units and the scale of the answer before accepting it. A formula can be evaluated correctly while an input is still inappropriate for the problem. Repeating the calculation with a simple test value or checking the result against the expected direction of change can help identify an input mistake.
Matrix Calculator
A matrix is a rectangular arrangement of numbers organized into rows and columns. Matrices are commonly written using dimensions such as 2 × 2, 2 × 3, or 3 × 4, where the first number represents the number of rows and the second represents the number of columns. They are an important part of linear algebra and are widely used in systems of equations, geometry, computer graphics, statistics, physics, engineering, data analysis, and numerical methods.
This Matrix Calculator performs three common operations: matrix addition, matrix subtraction, and matrix multiplication. The rules for these operations are different, so the dimensions of the input matrices must be checked before a calculation can be performed.
How to Enter a Matrix
Enter each row on a separate line and separate values within a row using commas. For example, the following represents a 2 × 2 matrix:
1, 2
3, 4
The same matrix can also be entered using a semicolon between rows:
1, 2; 3, 4
Every row must contain the same number of elements. For example, a matrix with three rows and two columns must have exactly two numbers in each of its three rows.
Matrix Dimensions
The dimensions of a matrix are written as m × n, where m is the number of rows and n is the number of columns.
A =
[
1 2 3
4 5 6
]
Matrix A has 2 rows and 3 columns, so its dimensions are 2 × 3.
Matrix Addition
Matrix addition is performed by adding corresponding elements from two matrices. The matrices must have exactly the same dimensions. A 2 × 3 matrix can therefore be added to another 2 × 3 matrix, but not to a 2 × 2 or 3 × 2 matrix.
Cij = Aij + Bij
For example:
A =
[
1 2
3 4
]
B =
[
5, 6
7, 8
]
A + B =
[
1+5 2+6
3+7 4+8
]
=
[
6 8
10 12
]
Matrix Subtraction
Matrix subtraction follows the same dimension rule as addition. Both matrices must have the same number of rows and columns. Corresponding elements are subtracted from one another.
Cij = Aij − Bij
For example:
A − B =
[
1−5 2−6
3−7 4−8
]
=
[
−4 −4
−4 −4
]
Matrix Multiplication
Matrix multiplication follows a different rule from addition and subtraction. An m × n matrix can be multiplied by an n × p matrix. The number of columns in the first matrix must equal the number of rows in the second matrix.
(m × n)(n × p) = m × p
For example, a 2 × 3 matrix can be multiplied by a 3 × 4 matrix. The result will be a 2 × 4 matrix.
How Matrix Multiplication Works
Each element of the product is calculated by taking the dot product of one row from the first matrix and one column from the second matrix. The corresponding values are multiplied and then added together.
Cij = Ai1B1j + Ai2B2j + ... + AinBnj
Consider:
A =
[
1 2
3 4
]
B =
[
5 6
7 8
]
C1,1 = 1×5 + 2×7 = 19
C1,2 = 1×6 + 2×8 = 22
C2,1 = 3×5 + 4×7 = 43
C2,2 = 3×6 + 4×8 = 50
Therefore:
A × B =
[
19 22
43 50
]
Matrix Addition vs. Multiplication
Addition and multiplication have different dimension requirements. For addition, the matrices must have identical dimensions. For multiplication, only the inner dimensions must match.
Addition: (m × n) + (m × n)
Multiplication: (m × n)(n × p) = m × p
Why Matrix Multiplication Is Not Commutative
Unlike ordinary numbers, matrix multiplication is generally not commutative. In other words:
A × B ≠ B × A
In some cases A × B may be defined while B × A is not even mathematically possible because the dimensions do not satisfy the multiplication rule.
Square and Rectangular Matrices
A matrix is called square when it has the same number of rows and columns, such as 2 × 2 or 3 × 3. A matrix with different numbers of rows and columns is called rectangular.
Square matrices have several additional concepts associated with them, including determinants, inverses, eigenvalues, eigenvectors, and matrix powers. These concepts are important in more advanced linear algebra.
Common Matrix Examples
2 × 2 Matrix
[
1 2
3 4
]
2 × 3 Matrix
[
1 2 3
4 5 6
]
3 × 2 Matrix
[
1 2
3 4
5 6
]
Applications of Matrices
Matrices are used in many areas of mathematics, science, and computing. They can represent systems of linear equations, geometric transformations, coordinate transformations, datasets, probabilities, physical models, and computer graphics operations.
In computer graphics, for example, matrices can be used to rotate, scale, translate, and transform objects. In data science and statistics, matrices provide a convenient way to organize and manipulate large collections of numerical data.
Matrix Formulas
Addition: Cij = Aij + Bij
Subtraction: Cij = Aij − Bij
Multiplication: Cij = Σ AikBkj
Dimension rule: (m × n)(n × p) = m × p
Using This Matrix Calculator
Enter Matrix A and Matrix B using commas between columns and separate rows with new lines or semicolons. Select Addition, Subtraction, or Multiplication, then calculate the result. The result includes the resulting matrix, dimensions, relevant formulas, calculation steps, dimension checks, and an explanation of how the operation was performed.
Disclaimer
This calculator is intended for informational purposes only. While we strive for accuracy, we cannot guarantee that every result is correct for every situation.